Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Android disconnect() and close() do not disconnect

I have problems with disconnecting my Android devices from my BLE peripheral. I don't think this is Nordic-specific, but perhaps someone has an idea?

Disconnecting using the nRF Connect app is 100% successful. The BLE peripheral sees the remote disconnect as soon as I click the "DISCONNECT" button.

However my own app based on Android BLE Library does not work: when I call mBleManager.disconnect().enqueue(); my app thinks it has disconnected, but my device does not see the disconnection. (It times out and does its own disconnect later).

I wrote a simple non-Nordic app with buttons for mBluetoothGatt.disconnect(); and mBluetoothGatt.close(); In this case the peripheral sees the remote disconnect only about 10% of the time.

I get the same results with an tablet running Android 7 and a Samsung phone running Android 8. I was involved in a thread on the same topic last year (not sure if it was resolved): github.com/.../450

Any ideas? In particular, what is the nRF Connect connect/disconnect code (which works) and how does it differ from the BleManager code, which does not?

Related