-
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
Services should be re-discovered once onServiceChanged is called #662
Comments
Thanks for reporting this! I'll try to find time soon to work on it. The device you're experiencing this issue with, and testing with, does it happen to be a publicly available device? As I don't believe any of the devices I currently have perform a peripheral side service change that would trigger this. If there isn't a publicly available device to test against, I'll probably end up just calling |
Unfortunately, I am not using a publicly available device. It's probably possible to mock such behaviour on Android, but I haven't had the time to try. |
In API 31, onServiceChanged was added to BluetoothGattCallback, which Kable currently does not override and handle.
When this callback is called, Kable needs to rediscover services and turn on notifications/indications again. I am currently experiencing an issue where none of the previously set observers work as Android silently clears up all of the existing notification/indication registrations when this occurs - see L1141 in bta_gattc_act.cc.
I'm not sure if rediscovering services and re-enabling notifications/indications is sufficient in this scenario for everything to work properly, but I can confirm that manually calling
BluetoothGatt#setCharacteristicNotification
fixes my issue.As for reproducing the issue, it should occur when the server changes one (or more) of its services while you're already connected to it and subscribed to some characteristics.
The text was updated successfully, but these errors were encountered: