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

Force disconnect of all devices

Custom nRF51822 SD130 SDK V11

So sometimes my disconnects seem to fail, the return code says success, but when I try to reconnect I get an error 18, NRF_ERROR_CONN_COUNT, so something didn't really close.

I connect and reconnect a lot, it's my remote control app. So I connect and disconnect for every button press.

I'd like to just tell the stack to disconnect everything so I can go to sleep. Any ideas?

Thanks! Keith

  • If sd_ble_gap_disconnect() returns NRF_SUCCESS the link should be disconnect, but you cannot be sure that it has disconnected until you the BLE_GAP_EVT_DISCONNECTED event. Are you getting this? Could you include some code that shows what you are doing?

  • Not really an answer to my question, sometimes I don't get said BLE_GAP_EVT_DISCONNECTED, thats the problem.

    The question was, and is, how to force a disconnect of everything, Pull the rug out from under the stack and shut down.

  • I thought maybe you wanted to figure out why you get this unexpected behavior. The SoftDevice doesn't have a "disconnect everything" function. Then you must do something like disabling and re-enabling it.

  • Solving the error is of course desirable, and is being pursued, but it would still be nice to just force everything to shut down. Restarting the SD may be an interesting solution depending on the side effects. Thanks