-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BleClient Becomes Non-Responsive (Hangs Indefinitely) #734
Comments
Hi @wittigtech It's possible there is a quirk difference here between the Google/Samsung devices. It's also worth looking at the behaviour when using nrf Connect with the Samsung tablets to see if that application shows any issues subscribing to notifications. Another possibility is that this is a peripheral issue that is handled slightly differently by the different Android Bluetooth stacks. The
Are you able to see if these callbacks are being triggered on the Samsung devices? |
@peitschie, thanks for the feedback. I was able to put some breakpoints and confirmed onDescriptoreWrite() is being triggered consistently for all devices, including Samsung and Pixel devices. However, this helped me to narrow it down. Prior to this descriptor write event, the phone will prompt the user to Pair with the peripheral. If this prompt is reached, connectivity and functionality works as expected. In the instances where the plugin hangs, we never got the prompt to Pair. Here is a side by side order of events between the Samsung and Google Pixel:
I am thinking the Pixel's 2nd connect() is resolving prematurely. Is there a way to confirm at this point (before calling startNotifications) to verify successful connection? |
This is some great research @wittigtech Apologies, I haven't had time to dig into this further. Out of interest... which characteristics are marked as encrypted here (triggering the pairing dialog)? |
Thanks @peitschie We are connecting to a proprietary peripheral device. The characteristic is an internal key. |
@peitschie, thought I'd check in if you had any further questions or ideas. |
@peitschie, Happy New Year! I had some more information to share with you on this issue. We upgraded to capacitor 6.x and the corresponding bluetooth-le plugin to 6.x, the issue remains. When testing on the Pixel device, we noticed that after having disconnected from the peripheral, the Pixel had a widget on the home screen that was still showing as connected to that peripheral. However we did not see it listed in the Settings > Bluetooth connected devices. Our suspicion is that the disconnect() is not functioning as expected for the Pixel, leaving a lingering connection, so that the next attempt to connect results in a hang. Thoughts? |
I have definitely seen manufacturer-specific bugs that cause the Bluetooth connection to remain in strange connected states (e.g., if there are active notification subscriptions) at various points in time. So... what you're describing here is definitely possible in my experience. The bit that I can't figure out though is that in your testing matrix above, the second connection for each phone seemed to work... it was only on the subsequent start notifications call (which triggers the pairing) that everything went wrong. Still... something to try is calling Another random thought I had is whether you can attempt to call |
Describe the bug
After successfully connecting and disconnecting, the next connection attempt causes the plugin to hang indefinitely. After the subsequent BleClient.connect(), the following call to BleClient.startNotifications() never resolves. Instead, after a brief pause onDisconnect callback is triggered. At this point, the plugin functionality is not recoverable. Attempting a connect() retry (or call to any BleClient function) results in no response. When in this state, the only resolution seems to be to restart to application.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Functions for Connect, StartNotifications, StopNotifications, Disconnect should work consistently across supported Android devices.
Plugin version:
Smartphone (please complete the following information):
Additional context
This issue does not affect all Android devices. The following devices reproduce this bug fairly consistently:
The following devices work as expected:
The text was updated successfully, but these errors were encountered: