-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
[iOS] Characteristic.WriteAsync() hangs #785
Comments
Hi @softeip, I'm the friendly issue checker. If you think it's fine to make an exception, just ignore this message. Thanks! |
Since passing CancellationToken to WriteAsync() does not return control to my code, I applied a temp hack:
Moreover, when WriteAsync() hangs, adapter events like DeviceConnectionError, DeviceConnectionLost, DeviceDisconnected seem to be not fired. Added more logging on this - will see how it goes for others |
I've had the same issue. Currently I've inlined the library and changed the following:
Not 100% sure what the downsides are of this change, but from her on I'm able to use the library on iOS. |
Thank you for the reply! |
I have a MAUI app which needs to monitor realtime data from BLE device.
Usually I send ~20 bytes to the device and expect to receive ~300-500 bytes back. Each packet gets sliced by 155 bytes per notification, so smartphone sends one notification in this case and receives multiple. What I noticed is that the app stops sending and receiving notifications after some random time (usually after 30-45 mins, but sometimes it hangs after 5-10 mins).
I've tried to add more logging and spent hours on debugging and now I see that Characteristic.WriteAsync() call hangs for unknown reasons. I tried to pass cancellation token to its params and cancel it after ~200 ms - no reaction. Also I ensured that I call the method on the main thread.
About characteristic - WriteType is set to WithoutResponse. Trying to write data WithResponse throws an error saying that it is not supported by device or sth like that.
Sometimes I also gets an exception saying that my device disconnected but I don't know if it is related to my issue:
Configuration
Version of the Plugin: 3.0.0 but also used all -pre versions and had the same issue.
Platform & devices:
Only iOS affected. Android app works without issues.
iPhone XR / iOS 16.6
iPhone 14 Pro / iOS 17.1.2
iPad Air 3 (Wi-Fi) / iPadOS 17.1.1
I would love to share an example or a project to reproduce the issue, but I'm not sure how to create one without exposing implementation details due to NDA.
What can be the reason of such behaviour on iOS?
What could I try to do to get more information on what's going on and how to fix it?
The text was updated successfully, but these errors were encountered: