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

softreset after call sd_ble_gap_disconnect()

Hi support team,

In my case, i want to auto disconnect to ble central after some minutes with no message transfered, so i create an timmer and set event compare and clear timmer insite event nus_data_handler(). It's working, but my device was reset after execute function sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION). I use NRF connect tool to check connection handle and i got reason BLE_HCI_CONNECTION_TIMEOUT (maybe my device was disconnected but it not send any message to ble central so that after 4s event timeout triggered). Could you show me how to safety disconnect to ble central.
Thanks.

Parents
  • Hi,

    It's working, but my device was reset after execute function sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION)

    You should never see a reset out of the blue. If you see a reset in this case, I suspect an error handler has been hit. Could you have used an invalid connection handle in the call to sd_ble_gap_disconnect()? If the nRF is reset before a disconnect occurs, this will be seen as a timeout on the peer side. Can you debug to check what actually happens when you attempt to disconnect? What is the return value of sd_ble_gap_disconnect()? If that is NRF_SUCCESS, then I suggest you keep debugging to see what else is causing the reset.

    Could you show me how to safety disconnect to ble central.

    the safe and correct way to disconnect is to call sd_ble_gap_disconnect() with the correct connection handle. Please remember that from this point the connection will no longer be valid, so if you continue to use the connection handle that will cause problems (typically an invalid sate error from the API where it is used).

Reply
  • Hi,

    It's working, but my device was reset after execute function sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION)

    You should never see a reset out of the blue. If you see a reset in this case, I suspect an error handler has been hit. Could you have used an invalid connection handle in the call to sd_ble_gap_disconnect()? If the nRF is reset before a disconnect occurs, this will be seen as a timeout on the peer side. Can you debug to check what actually happens when you attempt to disconnect? What is the return value of sd_ble_gap_disconnect()? If that is NRF_SUCCESS, then I suggest you keep debugging to see what else is causing the reset.

    Could you show me how to safety disconnect to ble central.

    the safe and correct way to disconnect is to call sd_ble_gap_disconnect() with the correct connection handle. Please remember that from this point the connection will no longer be valid, so if you continue to use the connection handle that will cause problems (typically an invalid sate error from the API where it is used).

Children
No Data
Related