diff --git a/src/gap.h b/src/gap.h index a9464d03e..f90ddee8e 100644 --- a/src/gap.h +++ b/src/gap.h @@ -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 diff --git a/src/hci.c b/src/hci.c index 280970a6c..4f3d8e51c 100644 --- a/src/hci.c +++ b/src/hci.c @@ -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;