This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bonding Information not stored in Flash memory

I am using nrf52 with SDK 14.2.0 and SD is S132.

The issue I am facing is that after Central is paired with one peripheral and bonding is done, the bonding information is not stored by central and so the next time when the already bonded peripheral tries to connect with the Central, it follows pairing and bonding procedure. Below are the peer manager events that I am getting:

1. PM_EVT_CONN_SEC_PARAMS_REQ

2. PM_EVT_CONN_SEC_SUCCEEDED

3. PM_EVT_CONN_SEC_PARAMS_REQ

4. PM_EVT_CONN_SEC_SUCCEEDED

The above events are coming for new device as well as already paired device.

Also, one issue I think is I am never getting PM_EVT_PEER_DATA_UPDATE_SUCCEEDED event even after bonding is done. Also one more strange behavior is that my system event handler, which I registered using NRF_SDH_SOC_OBSERVER, is never called.

Can you please help me to resolve this issue?

Parents
  • Debugging further I found that inside the SDK, /peer_data_storage.c file has registered fds_evt_handler. This handler is called only twice, one for INIT event and once for GC (Garbage Collection) event. This both are done before pairing started. I doubt the issue is with FDS? Not sure though.

  • I think it would be best if you could provide a stripped down version of the project as Matt suggested earlier. But please try the following:

    1. Place a breakpoint in peer_data_storage -> pds_peer_data_store() to see if it is being called after BLE_GAP_EVT_AUTH_STATUS. Make sure that any bond info is erased on both devices before you do the test.

    2. Check the pm_evt_t::pm_conn_sec_procedure_t value when you receive the PM_EVT_CONN_SEC_SUCCEEDED event. 

    3. If you have a BLE sniffer, try to capture the initial bonding procedure. 

  • 1.  pds_peer_data_store() gets called. 

    2. procedure is PM_LINK_SECURED_PROCEDURE_BONDING

    I have doubt on the FDS/FSTORAGE module. I have registered SOC handler using NRF_SDH_SOC_OBSERVER but that handler is never called. I believe it should be called for every flash Write operation. Can that be issue? 

    Also, I am using first the device as peripheral to connect to a Mobile APP, and then after this connection is broken and then I use the device as a central to connect with a peripheral. 

  • That's good,  it's trying to store the data at least. 

    The fstorage backend registers its own observer instance so it is not necessary add a new observer. All observers should however receive the same events.

    Have you registered other FDS/fstorage instances in your app, or is it just the peer manager that uses it?Also, have you tried to see if  the fds callback for the PM receives any write/update events (peer_data_storage.c->fds_evt_handler)? 

Reply
  • That's good,  it's trying to store the data at least. 

    The fstorage backend registers its own observer instance so it is not necessary add a new observer. All observers should however receive the same events.

    Have you registered other FDS/fstorage instances in your app, or is it just the peer manager that uses it?Also, have you tried to see if  the fds callback for the PM receives any write/update events (peer_data_storage.c->fds_evt_handler)? 

Children
Related