nRF51822 as peripheral: how to delete pairing/bonding data of all previously paired centrals but current one

Hello,

I have a peripheral (nRF51822, S130, using the peer manager) that should be paired/bonded with at most one central. This means that if I want to pair the terminal with central#2, I should somehow delete central#1 to not allow to connect. So, I think I cannot use whitelisting. I tried to use pm_peers_delete on the event PM_EVT_CONN_SEC_START to delete all previously bonded data, but obviously it failed!

Could you please help me to know how to use pm_peer_delete in order to delete all already paired/bonded centrals when I want to pair with a new central?

1. Where do I need to call pm_peer_delete(pm_peer_id_t peer_id);

2. How can I get all peer_id that have already been saved not the new one? 

Thanks.

  • The problem is that I am on the peripheral side not central/scanner. It seems that the last recently paired peer does not always have the highest rank. So, I call pm_peer_rank_highest on PM_EVT_BONDED_PEER_CONNECTED and set the flag. Upon disconnection, I do the erase procedure by first calling pm_peer_ranks_get and then erasing all peers but the highest one.

    This has completely resolved my issues, but I am looking for a better way to not call pm_peer_rank_highest  on every PM_EVT_BONDED_PEER_CONNECTED. 

Related