Start and stopping BLE adverstisement

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi All,

I am trying to modify the BLE hello sensor app to control BLE advertisement. I am using WICED_SDK_3.5.2.

I have seen that when that BLE peripheral is connected to a master BLE advertisement stops and restart again once it is disconnected from the central.

Now I want to control start and stop advertisement irrespective of connection status. For this I have used the below APIs

        result =  wiced_bt_start_advertisements( BTM_BLE_ADVERT_UNDIRECTED_HIGH, 0, NULL );   //to start BLE adv

        result =  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL );  //to stop BLE

I have observed that BLE starts adverting successfully with above API, but Stop does not seems to work.

So my query is that is it possible to stop BLE adv irrespective of connection status. If so, why is it failing with the api is used? Is there any additional steps required for Stopping BLE adv?

I would really help me if i get a link/reference document giving a brief on the API used in the WICED_SDK. Any help is highly appriciated.

Thanks in advance.

0 Likes
1 Solution
Anonymous
Not applicable

Hi all,

I found that the below API was successfully stopping advertisement.

result =  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL );

It can be validated using below API

wiced_bt_ble_advert_mode_t wiced_bt_ble_get_current_advert_mode(void);

Earlier the problem was once the  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL) is called, we get the ble link callback (event BTM_BLE_ADVERT_STATE_CHANGED_EVT) and it was enabling advertisement again. Disabling the hello_sensor_advertisement_stopped() function call in the callback solved this issue.

Thanks.

View solution in original post

5 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Moving to the WICED Wi-Fi Forums

0 Likes
Anonymous
Not applicable

Hello Nishal,

  You can use the following function to stop adverstisements...

// Stop advertising
bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

At least this is how you would do so with the WICED Smart SDK...being that it looks like this got moved to the WIFI section maybe you are using a different SDK...

Regards,

Frank

0 Likes
Anonymous
Not applicable

Hi ,

Thanks for the reply

I am using WICED-SDK-3.5.2.

In this I could not find the bleprofile_Discoverable API. Please give more details so that I can use this api.

Thanks in advance.

0 Likes
Anonymous
Not applicable

Hi all,

I found that the below API was successfully stopping advertisement.

result =  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL );

It can be validated using below API

wiced_bt_ble_advert_mode_t wiced_bt_ble_get_current_advert_mode(void);

Earlier the problem was once the  wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL) is called, we get the ble link callback (event BTM_BLE_ADVERT_STATE_CHANGED_EVT) and it was enabling advertisement again. Disabling the hello_sensor_advertisement_stopped() function call in the callback solved this issue.

Thanks.

Thanks for sharing the solution nishal

0 Likes