-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Bluetooth: settings: CCC not stored on device reset #10312
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
Comments
This can be reproduced on HIDS peripheral sample for latest Zephyr master with Android peer. Windows peer writes the CCC to the Bluetooth HID peripheral with every connection establishment, so the issue is not visible there. When the bonded peer disconnects, CCC is saved correctly and loaded after reconnection:
However, when the device is reset, the CCC is not stored, and after connect re-establishment the |
cc @carlescufi |
@Qbicz What is the device reset procedure? Don't you have to disconnect, or have some event before shutting down? That could then be used to cleanup the connection and then save the states otherwise even if we do save on every write there is a risk that the device is reset while storing so you will need a cleanup procedure anyway. |
@Vudentz if we can gracefully shutdown that's great. I'm concerned about scenarios where the battery life ends or user just removes the batteries. In such case, we should provide a correct behaviour after restart of system and reconnection to peer. That's why I think the CCC should be stored earlier, maybe just after it is changed. |
@Vudentz I decided to fix this behaviour, but wanted to ask if you think it's a good idea to store CCC in persistent memory on the peripheral side after CCC change, instead of on disconnection only. |
@joerchan @nvlsianpu can you please advise on this one? There was a conversation on IRC about this in #zephyr-bt, hopefully you have the logs. |
I see no obstacles for saving this just after case. In normal device life storing CCC Is expected to be rare event -like paring is.. In case a device might subscribe to more than one characteristic it is better to save all CCC at once (this will decrees wear levering - understand that we don't know how many subscription request will received, so nice to have only). We disused this together with @Qbicz off-chanel as well. |
As discussed with @Vudentz and @nvlsianpu, I'm adding an optional behaviour: store CCC to flash after it has been changed (in However there is another bug in loading from settings which holds me back: in |
@Qbicz did you report the |
@Qbicz ok, thanks. I will check with your PR once merged 👍 |
Uh oh!
There was an error while loading. Please reload this page.
The only situation where CCC is stored is on Bluetooth disconnection -
bt_gatt_store_ccc()
is only called inbt_gatt_disconnected()
.However, if the device resets, there is no Bluetooth disconnection event and the CCC is not stored. Because of this fact, on reconnection with bonded peer the CCC is incorrect: e.g. HID device cannot send HID input.
I think the CCC should be stored to persistent memory on every CCC change or maybe periodically.
The text was updated successfully, but these errors were encountered: