gap: add gap_delete_all_link_keys

This commit is contained in:
Matthias Ringwald 2018-02-05 18:31:36 +01:00
parent c4023def38
commit ceecb9d95a
2 changed files with 21 additions and 0 deletions

View File

@ -418,6 +418,11 @@ void gap_local_bd_addr(bd_addr_t address_buffer);
*/
void gap_drop_link_key_for_bd_addr(bd_addr_t addr);
/**
* @brief Delete all stored link keys
*/
void gap_delete_all_link_keys(void);
/**
* @brief Store link key for remote device with baseband address
* @param addr

View File

@ -353,6 +353,22 @@ void gap_store_link_key_for_bd_addr(bd_addr_t addr, link_key_t link_key, link_ke
hci_stack->link_key_db->put_link_key(addr, link_key, type);
}
void gap_delete_all_link_keys(void){
bd_addr_t addr;
link_key_t link_key;
link_key_type_t type;
btstack_link_key_iterator_t it;
int ok = gap_link_key_iterator_init(&it);
if (!ok) {
log_error("could not initialize iterator");
return;
}
while (gap_link_key_iterator_get_next(&it, addr, link_key, &type)){
gap_drop_link_key_for_bd_addr(addr);
}
gap_link_key_iterator_done(&it);
}
int gap_link_key_iterator_init(btstack_link_key_iterator_t * it){
if (!hci_stack->link_key_db) return 0;
if (!hci_stack->link_key_db->iterator_init) return 0;