You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using ClientBleGatt.connect(...) to connect to a ServerDevice retrieved from scanning. Once in a while, the connect function will hang. I first ran into this while still using version 1.0.7 of this library. I am currently updating to use the latest version, 1.0.15, but I have seen it happen in this latest version as well. The major difference with this newest version is that the connect call can now be cancelled so it is at least recoverable.
This issue has been difficult to reproduce in a normal environment. I've only been able to reproduce this semi-reliably by either:
Having the nRF Connect app connect to the bluetooth device that I'm using first and then connecting to it through my own application.
Using breakpoints in a debugger when connecting with my own application.
From what I've seen poking around in the library so far, it looks like there may be a race condition after connectGatt is called on the BluetoothDevice object with the gattCallback (ClientBleGattFactory.kt line 167) between when that gattCallback gets a connection state change to propagate into the ClientBleGatt object and when the ClientBleGatt::waitForConnection function sets the onConnectionStateChangedCallback (ClientBleGatt.kt line 183) so that it can be resumed.
The callback passed into Android can be called asynchronously. I have seen the connection state change event get triggered and propagated on one thread before the ClientBleGatt's waitForConnection could set its own onConnectionStateChangedCallback on another thread.
Thank you.
The text was updated successfully, but these errors were encountered:
I am also having this same issue when Connect hangs and never releases. I spent almost a week investigating this and found that someone is a race condition and it is somehow bug internally in the library.
Hello,
I've been using
ClientBleGatt.connect(...)
to connect to aServerDevice
retrieved from scanning. Once in a while, the connect function will hang. I first ran into this while still using version 1.0.7 of this library. I am currently updating to use the latest version, 1.0.15, but I have seen it happen in this latest version as well. The major difference with this newest version is that the connect call can now be cancelled so it is at least recoverable.This issue has been difficult to reproduce in a normal environment. I've only been able to reproduce this semi-reliably by either:
From what I've seen poking around in the library so far, it looks like there may be a race condition after
connectGatt
is called on theBluetoothDevice
object with thegattCallback
(ClientBleGattFactory.kt line 167) between when thatgattCallback
gets a connection state change to propagate into theClientBleGatt
object and when theClientBleGatt::waitForConnection
function sets theonConnectionStateChangedCallback
(ClientBleGatt.kt line 183) so that it can be resumed.The callback passed into Android can be called asynchronously. I have seen the connection state change event get triggered and propagated on one thread before the
ClientBleGatt
'swaitForConnection
could set its ownonConnectionStateChangedCallback
on another thread.Thank you.
The text was updated successfully, but these errors were encountered: