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?
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?
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:
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:
Are these status defined as constants in some android class? I want a list of status that onConnectionStateChanged() returns.
Deep in the stack code. You may find most common ones here: github.com/.../GattError.java