Prevent central device from reconnecting when actively disconnected from peripheral side

Hi, we have the requirement for our peripheral to be able to disable Bluetooth functionality, i.e. disconnect any connected central device and not accept any new connections. We are running nRF52832 with SDK 15.3. We have functionality in place to bond with a central device.

At this stage in the development I am using the nRF Connect app from Google play. I can bond the peripheral with my phone and I have the "Use autoconnect" checkbox ticked.

Now when disabling the Bluetooth functionality I try the following:

(void)ble_advertising_start(&m_advertising, BLE_ADV_MODE_IDLE);
(void)sd_ble_gap_adv_stop(m_advertising.adv_handle);

if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
    ret_code_t result = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
}

With this I expect advertising to be disabled and if any device is connected it should be disconnected. What happens is that the connected central device is disconnected briefly but immediately reconnects. How can I prevent this from happening?

Kind regards

ozh

Parents Reply
  • Good thing you found it! I was about to write that you need to stop advertising, but I didn't realize that you were just looking for that setting. I thought that you wanted to keep advertising (for other devices), and in that case, it wouldn't be possible to "blacklist" single devices.

    But in this case, it is much easier. Just stop advertising after the disconnect Slight smile

    Best regards,

    Edvin

Children
No Data
Related