-
Notifications
You must be signed in to change notification settings - Fork 75
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
Cannot reobserve a characteristic after canceling a job containing a call to observe #677
Comments
Thanks for the thorough bug report! I'll try to take a look at it soon. PRs are also welcome. |
Thanks for the quick response @twyatt! I'd be happy to submit a PR if I could figure out the root cause! I was able to work around this issue by using a different un-observation strategy -- |
I have the same use case as in Q&A answer #592 except that I sometimes need to re-observe the characteristic during the same connection.
Using kable 0.31.1 on Android, I did exactly as the answer suggested, using
cancelAndJoin()
to cancel alaunch
ed job. This does successfully writeDISABLE_NOTIFICATION_VALUE
to the descriptor. However, when I callobserve()
on the characteristic again, kable seems to think the characteristic is already being observed, and does not writeENABLE_NOTIFICATION_VALUE
.I've tracked this down (using the debugger) to the fact that
didStartObservation
is never set tofalse
-- I set a breakpoint at this line, and it is never reached. AFAICT, this is because the cancellation of the job causes the nextsuspend
function, which happens to beBluetoothDeviceAndroidPeripheral.setConfigDescriptor()
, to throw aCancellationException
on completion, which is propagated back to the previous line inObservation.kt
.The text was updated successfully, but these errors were encountered: