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

Peer manager bonds handling

Hello,

If I understand well, when the part of the flash reserved for the PM is full, new bonds cannot be saved until the application deletes older bonding data.

I would like my app to automaticaly delete the oldest bonds so that the flash never gets full.

I was able to do that with the device manager in using the following contributed code (many thanks to his author):

https://github.com/NordicPlayground/nRF51-ble-peripheral-bond-handling

Is there a simple way to know what bond has not been used lately and get rid of it when the number of peers is higher than a given number ?

Is there example code that already does it ?

Thanks in advance,

Christian

  • Hello,

    I am not sure if this is already available. I don't think it is in any of the examples in the SDK (I might be wrong), but I assume that there exists some github repository doing this.

     

    However, these are likely SDK - dependent (since some function names, and especially softdevice calls, are changed between the major SDK versions).

     

    I assume you have seen the function pm_peer_delete(). The only thing you need to do is to make sure that you use the correct peer ID, to remove e.g. the peer that has not been connected for the longest.

     

    To handle these, you will find the functions pm_peer_rank_highest() and pm_peer_ranks_get() (you will find their descriptions in the same link above).

    You typically call pm_peer_rank_highest() whenever you store a new bond, and whenever you need to delete a bond, call pm_peer_ranks_get(), which will return the ID of the highest ranked and the lowest ranked. Then you would want to delete the peer with the lowest rank.

    Take a look at it, and let me know if something isn't clear.

     

    Best regards,

    Edvin

Related