How to store/retrieve bonding information

Hello, I'm trying to figure out how to use the settings subsystem to store bonding information on my central device. I'm confused on how the settings subsystem works. I'm on nrf connect sdk v1.9.1 and programming on nrf52840.

Is information automatically stored in memory whenever a device is bonded? If so, what information is stored when a device is bonded? I have called settings_load() during the initialization of my project, but I'm not sure how to access the information stored.

I'm trying to store bonding information so I can reconnect to the peer device after a power cycle. I need to restore the Bluetooth address of the bonded device so I can add it to scanning filters before attempting to connect to the peer device. Is this information that is stored after a connection? 

I've tried looking at examples, but they only seem to call settings_load() and I don't see any other calls to the settings subsystem.

Thanks

  • Hi,

    You are right that bonds are stored using the settings sybsystem.

    I'm trying to store bonding information so I can reconnect to the peer device after a power cycle.

    You generally do not need to think about how it is stored, as the Bluetooth stack stores and retreives the informaiton as needed. As long as you have properly configured the device for bonding and the peer supports bonding, and you see bonding occur, the bonding information will be stored in non-volatile memory (flash on the nRF52 series).

    Is this information that is stored after a connection? 

    Yes. The bonding information includes the address (and IRK if privacy/resolvable random address is used), as well as the long term key (LTK). It also includes othe rinformaiton likestates of CCCD for GATT as that is maintained across connnetions for bonded devices. I am not sure if you are asking about this, but if you want to advertise (or scan) for a specific device that you are bonded with, you can use the filter accept list. That is explaiend and demonstratd in lesson5 exercise 2 of our Bluetooth Low Energy Fundamentals course.

    I've tried looking at examples, but they only seem to call settings_load() and I don't see any other calls to the settings subsystem.

    That is because this is handled by the Bluetooth stack.

Related