Languages

Menu
Sites
Language
Bluetooth Advertising Stopping

I'm not having any luck with getting the Bluetooth advertising to stay running.

I'm using VS.NET 2019 with Tizen 4.0 as the target.  The device I'm deploying to is a Samsung Galaxy Active2 watch.

The advertising starts ok, and I can see a few packets, but then it just stops by itself.

Here is the code (mostly just copied from this guide: docs.tizen.org/application/dotnet/guides/connectivity/bluetooth):

 

            BluetoothLeAdvertiseData advertiseData = new BluetoothLeAdvertiseData();

            advertiseData = new BluetoothLeAdvertiseData();
            advertiseData.AdvertisingMode = BluetoothLeAdvertisingMode.BluetoothLeAdvertisingBalancedMode;
            advertiseData.AdvertisingConnectable = true;
            advertiseData.Appearance = 192;

            BluetoothLePacketType packetType = BluetoothLePacketType.BluetoothLeAdvertisingPacket;
            string serviceUuid = "1805"; /// time_svc_uuid_16
            advertiseData.AddAdvertisingServiceUuid(packetType, serviceUuid);


            /// Add sample service data for testing
            BluetoothServiceData serviceData = new BluetoothServiceData();
            serviceData.Uuid = "1805";
            serviceData.DataLength = 3;
            serviceData.Data = new byte[3] { 0x01, 0x02, 0x03 };
            advertiseData.AddAdvertisingServiceData(packetType, serviceData);

            advertiseData.IncludeDeviceName = true;
            advertiseData.IncludeTxPowerLevel = true;

            advertiser.StartAdvertising(advertiseData);

 

And here is what I see in the Tizen debug log:

 

05-06 14:53:48.523 : Info / CAPI_NETWORK_BLUETOOTH ( 7064 : 7064 ) : bluetooth-common.c: __bt_event_proxy(2576) > BLUETOOTH_EVENT_ADVERTISING_STARTED
05-06 14:53:48.527 : Info / Tizen.Network.Bluetooth ( 7064 : 7064 ) : BluetoothLeAdapterImpl.cs: StartAdvertising(430) > Setting advertising state changed callback !! 
05-06 14:53:48.663 : Debug / FM_Bluetooth ( 7064 : 7064 ) : FM_Bluetooth.cs: AdvertisingChangedEventHandler(133) > advertising callback... advertisingFlag: True
05-06 14:53:48.731 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-adapter-le.c: bluetooth_is_advertising(450) >  Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_IS_ADVERTISING(0x23) 
05-06 14:53:48.767 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-common.c: _bt_print_api_caller_name(1318) > Caller : com.fluid-mobility.Tiz
05-06 14:53:48.767 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-adapter-le.c: bluetooth_set_advertising(249) >  Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_SET_ADVERTISING(0x1b) 
05-06 14:53:48.791 : Info / POWER_MANAGER ( 2647 : 2647 ) : core.c: proc_condition_lock(1491) > [S_LCDOFF] locked by  3175 with 0 ms
05-06 14:53:48.791 : Info / POWER_MANAGER ( 2647 : 2647 ) : core.c: reset_timeout(973) > Reset Timeout (300 ms)
05-06 14:53:48.799 : Info / BLUETOOTH_FRWK_SERVICE ( 2644 : 2644 ) : bt-service-adapter-le.c: _bt_set_advertising(382) >  ### Set advertising [0], Slot id [2] 
05-06 14:53:48.799 : Info / BLUETOOTH_FRWK_SERVICE ( 2644 : 2644 ) : bt-service-event-sender.c: _bt_send_event_to_dest(591) >  Signal : AdvertisingStopped 
05-06 14:53:48.799 : Info / BLUETOOTH_FRWK_SERVICE ( 2644 : 2644 ) : bt-service-tds.c: _bt_tds_handle_adv_disabled(1187) > sender: :1.316, adv_handle:26187280
05-06 14:53:48.799 : Info / BLUETOOTH_FRWK_SERVICE ( 2644 : 2644 ) : bt-service-tds.c: _bt_tds_handle_adv_disabled(1194) > Provider not found
05-06 14:53:48.799 : Info / POWER_MANAGER ( 2647 : 2647 ) : core.c: proc_condition_unlock(1522) > [S_LCDOFF] unlocked by  3175
05-06 14:53:48.803 : Info / POWER_MANAGER ( 2647 : 2647 ) : core.c: reset_timeout(973) > Reset Timeout (300 ms)
05-06 14:53:48.811 : Info / CAPI_NETWORK_BLUETOOTH ( 7064 : 7064 ) : bluetooth-common.c: __bt_event_proxy(2590) > BLUETOOTH_EVENT_ADVERTISING_STOPPED
05-06 14:53:48.811 : Error / CAPI_NETWORK_BLUETOOTH ( 7064 : 7064 ) : bluetooth-adapter.c: _bt_adapter_le_invoke_advertising_state_cb(2624) > No available advertiser
05-06 14:53:48.907 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-adapter-le.c: bluetooth_is_advertising(450) >  Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_IS_ADVERTISING(0x23) 
05-06 14:53:48.943 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-common.c: _bt_print_api_caller_name(1318) > Caller : com.fluid-mobility.Tiz
05-06 14:53:48.943 : Info / BLUETOOTH_FRWK_API ( 7064 : 7073 ) : bt-adapter-le.c: bluetooth_set_advertising(249) >  Sync Request => type=BT_BLUEZ_SERVICE, fn=BT_SET_ADVERTISING(0x1b) 
05-06 14:53:48.955 : Info / BLUETOOTH_FRWK_SERVICE ( 2644 : 2644 ) : bt-request-handler.c: __bt_service_method(350) >  Request is failed [NOT_IN_OPERATION] [0xffffffe6] 
05-06 14:53:48.959 : Error / CAPI_NETWORK_BLUETOOTH ( 7064 : 7073 ) : bluetooth-adapter.c: bt_adapter_le_destroy_advertiser(1699) > NOT_IN_PROGRESS(0xfe400105)

 

Any help would be greatly appreciated!

 

Edited by: Mike Bolgar on 06 May, 2020

Responses

10 Replies
Pyun DoHyun

Can you add the code to get "advertiser"?

 

Normally, we can use this code to get the default "advertiser".

If you don't call next function, please add under line.

advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();

 

* You can refer next code to enable advertisement.

https://review.tizen.org/gerrit/gitweb?p=test/tct/csharp/api.git;a=blob;f=tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeAdvertiser.cs;h=e9b016aaa1788114afca4cdccde414592f0c3c93;hb=refs/heads/tizen

Mike Bolgar

Thank you for the quick response.  I do have this line: BluetoothAdapter advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();

It was just cut off in my paste here.

I'm still not able to get this to work.  Do you have any other ideas?

 

Mike Bolgar

Correction... the line is: BluetoothLeAdvertiser advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();

 

Pyun DoHyun

Can you add under callback for advertisement event?

 

            BluetoothLeAdvertiser advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();

            BluetoothLeAdvertiseData advertiseData = new BluetoothLeAdvertiseData();

            advertiseData = new BluetoothLeAdvertiseData();
            advertiseData.AdvertisingMode = BluetoothLeAdvertisingMode.BluetoothLeAdvertisingBalancedMode;
            advertiseData.AdvertisingConnectable = true;
            advertiseData.Appearance = 192;

            BluetoothLePacketType packetType = BluetoothLePacketType.BluetoothLeAdvertisingPacket;
            string serviceUuid = "1805"; /// time_svc_uuid_16
            advertiseData.AddAdvertisingServiceUuid(packetType, serviceUuid);


            /// Add sample service data for testing
            BluetoothServiceData serviceData = new BluetoothServiceData();
            serviceData.Uuid = "1805";
            serviceData.DataLength = 3;
            serviceData.Data = new byte[3] { 0x01, 0x02, 0x03 };
            advertiseData.AddAdvertisingServiceData(packetType, serviceData);

            advertiseData.IncludeDeviceName = true;
            advertiseData.IncludeTxPowerLevel = true;

            EventHandler<AdvertisingStateChangedEventArgs> AdvertisingChangedEventHandler = null;

            AdvertisingChangedEventHandler = (object sender, AdvertisingStateChangedEventArgs e) => {

            };

            advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;

            advertiser.StartAdvertising(advertiseData);

Mike Bolgar

I have this event registration already under the class constructor along with the initial advertiser declaration, which I made a global variable.

The event does fire when the advertiser starts, but I've never seen anything in the log about when the advertiser stops.  

I can try moving the event handler registration into this function as you've shown and will report back.

Mike Bolgar

No luck... It still just starts advertising, and I can see 1-3 packets from it, then it just stops.

Pyun DoHyun

Can you share 'com.fluid-mobility.Tiz' tpk file? -> dh79.pyun@samsung.com

In my environment, above code works nomral. (Galaxy Watch Active2)

So I need to check with the application samely

Pyun DoHyun

The issue was resolved by application's modification

Csaba Huszár

I have the same issue, can you help me, how did you solve it?

Csaba Huszár

Couldn't figure it out exactly, but same thing with this approach works: https://review.tizen.org/gerrit/gitweb?p=test/tct/csharp/api.git;a=blob;f=tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs;h=8c52eceabb22d3ae7a198ac9b5c84b34ef5f0239;hb=refs/heads/tizen