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

Android: Disconnect Reason?

In Android, is there any way to distinguish between an explicit disconnect requested by the remote device, and a disconnect due to loss of comms; eg, the remote device going out of range?

Parents
  • Hello, Sorry for the late reply. If depends how gracefully you disconnect from a device. If you send disconnect request from your peripheral, you get onConnectionStateChanged with status = 19 (0x13 = GATT CONN TERMINATE PEER USER). If you just restart your device, or you go out of range, or other reason of loss of comms, you will get status = 8 (0x08 = GATT CONN TIMEOUT). Foe example, DFU since SDK 8 (AFAIR) sends graceful disconnect.

    Here it's shown on the log from nRF Master Control Panel: image description

Reply
  • Hello, Sorry for the late reply. If depends how gracefully you disconnect from a device. If you send disconnect request from your peripheral, you get onConnectionStateChanged with status = 19 (0x13 = GATT CONN TERMINATE PEER USER). If you just restart your device, or you go out of range, or other reason of loss of comms, you will get status = 8 (0x08 = GATT CONN TIMEOUT). Foe example, DFU since SDK 8 (AFAIR) sends graceful disconnect.

    Here it's shown on the log from nRF Master Control Panel: image description

Children
Related