ConnectionObserver.onDeviceDisconnected() can never report REASON_TERMINATE_PEER_USER
See original GitHub issueConnectionObserver.onDeviceDisconnected()
always reports REASON_LINK_LOSS
even if the peripheral initiate disconnection with BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION
. Expected to report REASON_TERMINATE_PEER_USER
in that case.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The behavior could keep the same, but at least give a way for developer to differentiate whether the connection is initiated by the peripheral, in case that information is necessary for the App to determine what to do. In my case, I want to auto reconnect my peripheral if it is disconnected due to let say out of range, but stop auto reconnect if the peripheral explicitly initiates disconnection (e.g. there could be an unpair button or a factory reset button on the peripheral) . Even if the phone keeps auto reconnecting, at least I can write my own code to explicitly call
disconnect().enqueue()
if I know the disconnection was intentionally initiated by the peripheral.The problem describe by @rickymohk still exist on some devices (with Android-BLE-Library v2.3.1). I’m using a Redmi note 7 (Android 10) I got no problems but with a Samsung Galaxy S20 (Android 12) I always have
REASON_LINK_LOSS
when my BLE device perform a disconnection. I also tried with the last version of the Android-BLE-Library (v2.5.1) and it’s the same.