-
Notifications
You must be signed in to change notification settings - Fork 52
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
Characteristic changed BroadcastChannel losing values #60
Comments
Hi, I think that the problem is with the channel capacity. Line 62 in 4a61774
Now capacity is 1, so every new notification will overwrite the old one. I think, that this channel should be BUFFERED |
I also thought that, but changing the channel doesn't solves the issue, as the issue is within the scopes and the callstack execution order and something else I don't remember how to explain, hehe. But some good folk explained very well in a PR a few weeks ago, I believe this is the explanation: #61 (comment) |
Quoting myself for future reference as I'll work to fix this:
|
Related to #56 |
Some values (usually the first one) that arrive at
onCharacteristicChanged
never gets to be received fromopenNotificationSubscription
.I never seen this, why you're saying that?
Take a quick look in the code ahead:
BleGattCoroutines/core/src/androidMain/kotlin/com/beepiz/bluetooth/gattcoroutines/GattConnectionImpl.kt
Lines 278 to 280 in 4a61774
What happens is that the characteristic changed value that's missing always get to this point, but while all values are correct when comming in the method param, not all values gets to the
send
call inside thelaunch
scope.So are you saying the value gets replaced by the next value when inside the
launch
scope?Yes.
Innitially I thought it could be a problem with the broadcast channel itself, but it seems the values never get to be sent on the channel, so it must be this
launch
scope messing things up. I switched thelaunch
for arunBlocking
and things seems to be running fine now. But since I'm blocking the execution now, I don't know if it's the right approach for the library, so I decided to open the issue along with a PR where I will reference this issue.Thanks in advance.
The text was updated successfully, but these errors were encountered: