Hi there
I am having issues to perform disconnections from my central device when calling sd_ble_gap_disconnect()
most of the time I am able to disconnect properly using sd_ble_gap_disconnect() where it returns NRF_SUCCESS, but some times it returns BLE_ERROR_INVALID_CONN_HANDLE from my understanding it means that for some reason the conn handle changed to something else different than 0. why it happens? and how to work around it? I am only using one link connection per time.
What I was thinking Is I was already disconnected at the moment calling sd_ble_gap_disconnect(), but I am tracking the connection status using a global variable and the conn handle at on_ble_evt(ble_evt_t * p_ble_evt) before call sd_ble_gap_disconnect();
questions:
1) A conn handle = BLE_CONN_HANDLE_INVALID can be taken as indicative I am already disconnected?
2) why err_code = sd_ble_gap_disconnect(connhandle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); // connhandle= 0 and not BLE_CONN_HANDLE_INVALID and it returns BLE_ERROR_INVALID_CONN_HANDLE, where the my variable where I track the connection still says I am connected
3) How can I know which is the connhandle for the question above? I tried a loop putting all different connhandles from 0x0000 to 0xFFFF and still in each returns BLE_ERROR_INVALID_CONN_HANDLE, that means I was already disconnected??
3) After receiving a BLE_ERROR_INVALID_CONN_HANDLE how can I get the proper connhandle for that "connection"? because it is not being reported at on_ble_evt (the last received was connhandle = 0)
4) after calling sd_ble_gap_disconnect() regarding which conn handle it uses and if it returns NRF_SUCCESS, will the connhande changed = BLE_CONN_HANDLE_INVALID ?
5) is there any mechanism to know the connection status in the SDK13?
details
SDK 13.3
Role Central