This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Stop and Start Bluetooth Advertising

Hello Everyone,

I need to turn off the bluetooth advertising on certain event/interrupt and start advertising again on another event/interrupt.

I have gone through the forums and found similar questions and probable answers to do the same, but none of them is working properly.

When i implement the solutions available on the forum as below

// If connected, disconnect
if (temp_conn_handle != BLE_CONN_HANDLE_INVALID)
{
err_code = sd_ble_gap_disconnect(temp_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
if (err_code != NRF_SUCCESS) return err_code;
}

At this stage the device is getting disconnected as expected.

// Stop advertising
err_code = sd_ble_gap_adv_stop();
if (err_code != NRF_SUCCESS) return err_code;

But here the device doesn't stop advertising, it still keeps advertising

Can you please help me why it is not stopping advertisement after this statement.

Best,

Krishna

Parents Reply Children
Related