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

Does sd_ble_gap_disconnect support BLE_CONN_HANDLE_ALL ?

I would like to write code to disconnect from any connected device.  My system is a ble peripheral with s132 6.0.0.  

My code calls:

result=sd_ble_gap_disconnect(BLE_CONN_HANDLE_ALL,BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK_BOOL(((result==NRF_SUCCESS)||(result==NRF_ERROR_INVALID_STATE)||(result==NRF_ERROR_SOFTDEVICE_NOT_ENABLED)));

However I'm getting an NRF_ERROR_INVALID_CONN_HANDLE response.  Is this because I'm not connected to any device or does sd_ble_gap_disconnect not support BLE_CONN_HANDLE?

Parents
  • Hi,

    You will get BLE_ERROR_INVALID_CONN_HANDLE if you supply an invalid connection handle. But you will get nRF_ERROR_INVALID_STATE if there is no link or the linke is already in the process of being disconnected. So without testing it myself I would say BLE_CONN_HANDLE_ALL is not supported for the disconnect command. Simply loop through the connection handles and call disconnect?

Reply
  • Hi,

    You will get BLE_ERROR_INVALID_CONN_HANDLE if you supply an invalid connection handle. But you will get nRF_ERROR_INVALID_STATE if there is no link or the linke is already in the process of being disconnected. So without testing it myself I would say BLE_CONN_HANDLE_ALL is not supported for the disconnect command. Simply loop through the connection handles and call disconnect?

Children
No Data
Related