Reload GATT Handlers after reboot when GATT caching is active

Hi 

I'm using two nRF52840 devices, one central and one peripheral, and sdk version 3.0.1.

On the central side I enabled:

CONFIG_BT_GATT_CACHING=y

So far GATT caching works as expected, on normal reconnection, service and characteristic rediscovery is no needed to reuse attribute handlers. 

However, when I reboot the central, I’m not sure how attribute handle restoration is supposed to work.

After settings_load(), is there a way to restore previously discovered attribute handles automatically? Or must the central always perform full service discovery again after reboot? Currently I'm doing a rediscovery after each reboot as workaround. 

As I understand it, only the attribute database hash is stored but not the actual characteristic handles or discovery results.

Is that correct? What should be the correct workflow when central reboots?

Thanks

Parents
  • Hi

    If the central reboots and repopulates the attribute table there is no guarantee that the attribute handles stay the same I'm afraid. Using bt_gatt_resubscribe() on the central side would be the recommended way to handle reboots by the central here I think. The the attribute handle you get from attr_handle = load_handle_by_uuid(my_char_uuid) would be invalid after a server reboot as you are not getting the new handle from the central . Invalid here meaning it most likely won't point to the same attribute anymore. We cannot guarantee the central repopulates the attributes in the same order and the attribute of the interest is never guaranteed to have the same attribute handle after reboot on the server side.

    Best regards,

    Simon

Reply
  • Hi

    If the central reboots and repopulates the attribute table there is no guarantee that the attribute handles stay the same I'm afraid. Using bt_gatt_resubscribe() on the central side would be the recommended way to handle reboots by the central here I think. The the attribute handle you get from attr_handle = load_handle_by_uuid(my_char_uuid) would be invalid after a server reboot as you are not getting the new handle from the central . Invalid here meaning it most likely won't point to the same attribute anymore. We cannot guarantee the central repopulates the attributes in the same order and the attribute of the interest is never guaranteed to have the same attribute handle after reboot on the server side.

    Best regards,

    Simon

Children
No Data
Related