Skip to content
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

Asymmetric RegisterForX and UnregisterForValues functions #26

Open
sleven79 opened this issue Apr 10, 2019 · 2 comments
Open

Asymmetric RegisterForX and UnregisterForValues functions #26

sleven79 opened this issue Apr 10, 2019 · 2 comments

Comments

@sleven79
Copy link

Note that there is no call to "gatt.writeDescriptor()" in the "unsubscribe" function called by the "UnregisterForValues" function of the BluetoothLE extension. This means that while the callback gets disabled and the App Inventor app does not receive any notifications from the BLE device any more, the BLE device still generates notifications in the background. The notification bit in the corresponding CCCD on the BLE device has not been cleared.

This is probably not the intended behavior. As BLE devices often try to save power wherever possible, being able to disable notifications on the device is important.

Note that the call to "gatt.writeDescriptor()" is used as expected in the "subscribe" function called by the "RegisterForX" functions of the BluetoothLE extension. Notifications are enabled by a write request to the corresponding CCCD.

I suggest to review the internals of the "unsubscribe" function and to include a call to "gatt.writeDescriptor()" such as to disable the notification bit in the CCCD.

@sleven79
Copy link
Author

sleven79 commented Sep 8, 2020

Hmm, unfortunately, the simple change that I proposed in the pull request has not been considered for the latest release of the extension. The bug is still alive.

@ewpatton
Copy link
Member

ewpatton commented Sep 8, 2020

@sleven79 There are a lot of changes in #27 that seem beyond the solution you've proposed here. If you want to clean up that PR to update the descriptor accordingly, that would be fine. We may want to balance the number of calls to RegisterForX(service, characteristic) and UnregisterForValues(service, characteristic) so that we only reset the notification flag once all existing registrations have been unwound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants