the idx_found is not -1 when compare irk or mac_addr matchs, but the idx_found is renewed when idx_emtpy_slot_found == -1, so here why not just replace the exsisted bond info if the idx_found != -1 ?
if (-1 != idx_emtpy_slot_found) { idx_found = idx_emtpy_slot_found; } else { if(idx_found != -1){ //should I add this line here? // no empty slot found - delete the oldest bond data slot idx_found = bdb.next_slot++; bdb.next_slot = bdb.next_slot % APP_BOND_DB_MAX_BONDED_PEERS; } }
Device:
Hi cgha,
I assume that you are working on the ble_app_sleepmode example of the SDK5.0.4. Is my understanding correct? If yes, according to the implementation of bond_db_store API, the oldest bonding data will be erased if there not enough slot level to add a new master's bonding information. From the function procedure, if there is an empty slot (denoted by idx_emtpy_slot_found), no matter the case that there is an address match, the bond info will always be put in the new slot.
Thanks, PM_Dialog
Do you mean the comparison with irk and mac_addr is redundancy? Since the idx_found will always be reassigned regardless of matching of irk or mac_addr.
Hi cgha,
The oldest bonding data will be erased if there not enough slot level to add a new master's bonding information. In case of idx_emtpy_slot_found, no matter the case that there is an address match, the bond info will always be put in the new slot.
Thanks, PM_Dialog