-
Notifications
You must be signed in to change notification settings - Fork 424
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
Using asFlow() from no.nordicsemi.android.ble.ktx #605
Comments
Hello, |
Could you do an experiment? Android-BLE-Library/ble-ktx/src/main/java/no/nordicsemi/android/ble/ktx/ValueChangedCallbackExt.kt Lines 24 to 34 in 9504515
In line 28 we're calling trySend(..) , which may fail, if the buffer is full (last event wasn't consumed). I suspect that this is the reason why you would loose packets. The documentation for callbackFlow says:
Could you add Another option would be to replace |
Could you try the PR made and
|
Hi! |
Hi!
Last year we upgraded our Android app to use android.ble.ktx:2.7.5 to communicate with sensors we develop. We are working on upgrading to 2.9.0 but there are a few extra changes we have to do on our side.
Recently we've noticed an increase on delays in the communication and discovered that most of the time some packages are going missing.
We decided to use asFlow to get notifications from the sensor like this:
notificationsFlow = setNotificationCallback(readCharacteristic).asFlow() enableNotifications(readCharacteristic).enqueue()
which we call in the initialize function.
In our app, we scan for the sensor, connect to it and then we request some information from the sensor which we collect from
notificationsFlow
. For some reason, the first packet we are expecting, sometimes is not received. Is there an specific way of doing this?I haven't found an example using
asFlow()
, could somebody maybe send across an example or is it not reliable to be use as it's annotated with@ExperimentalCoroutinesApi
?Thanks!
Nbl
The text was updated successfully, but these errors were encountered: