Hi, I'm using SDK15.3 on a NRF52840 chip and have some questions wrt to the peer manager and its ranking system. Once we bond with a peer, we print the full list of peers using:
void PrintBondList() { pm_peer_id_t currentPeerId = pm_next_peer_id_get(PM_PEER_ID_INVALID); uint8_t i = 1; while (currentPeerId != PM_PEER_ID_INVALID) { pm_peer_data_bonding_t peerData; pm_peer_data_bonding_load(currentPeerId, &peerData); uint32_t rank; uint16_t rankLenght = sizeof(rank); pm_peer_data_load(currentPeerId, PM_PEER_DATA_ID_PEER_RANK, &rank, &rankLenght); // Print mac address and rank here. currentPeerId = pm_next_peer_id_get(currentPeerId); } }
Each time, we get a new device to be bonded, we rank this peer ID as highest in the event coming from the peer manager:
case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED: { if ( event.params.peer_data_update_succeeded.action == PM_PEER_DATA_OP_UPDATE && event.params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_BONDING) { ret_code_t result = pm_peer_rank_highest(event.peer_id); assert(result == NRF_SUCCESS); } }
When we execute the following scenario:
- Bond with peer
- Disconnect
- Print list of peers - this gives us a total of one bond with rank '1'
- Delete all peers using pm_peers_delete
- Bond with SAME peer
- Disconnect
- Print list of peers - this shows a single peer but the rank is a unexpected number (e.g. 537132104). Once we trigger a system reset, the peer address (mac address) is still OK, but the rank is changed.
Is there anything we miss here, or are we facing an issue in the SDK?