-
Notifications
You must be signed in to change notification settings - Fork 88
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
peripheral.observe didUpdateNotificationStateForCharacteristic #653
Comments
What version of Kable are you using? |
hi twyatt, the Kable version I use is 0.24.0, this problem occurs on iOS, Android is normal |
I added the observationExceptionHandler method, and the program can receive the notification data from the Bluetooth device normally. val peripheral = defaultScope.peripheral(it) {
onServicesDiscovered {
bleLogger.i("""BleClient/startScan/onServicesDiscovered:${it.peripheralName}""")
}
observationExceptionHandler { cause ->
// Log failure instead of propagating associated `observe` flow.
bleLogger.i("""BleClient/startScan/observationExceptionHandler:$cause""")
}
} Log:
Why does the program become normal after adding the observationExceptionHandler method? |
same here |
@DayDayUpAllInOne based on your nRF Connect screenshot, I believe your peripheral is missing the "Client Characteristic Configuration Descriptor" ( Generally, when a characteristic is observed, the "Client Characteristic Configuration Descriptor" needs to be written to in order to enable the indication or notification of the associated characteristic. On Android, Kable handles this for you, but if the "Client Characteristic Configuration Descriptor" is missing, Kable simply logs a warning. On iOS, the system handles writing to "Client Characteristic Configuration Descriptor" automatically, and as you've found: if it cannot, it results in a failure which Kable propagates. As you've seen, the behavior between the two platforms is not consistent. I'm inclined to change Android (to be in parity w/ iOS) to also raise an exception if the "Client Characteristic Configuration Descriptor" does not exist. Ultimately, you should have the firmware fixed on your peripheral to provide the "Client Characteristic Configuration Descriptor" for any characteristics that you intend to observe. For example, nRF Connect should see your characteristics that you intend to observe like this: |
When I use the code below,The kable library reports an error
error message:
How to solve this problem? Thanks!
The text was updated successfully, but these errors were encountered: