gap: extracted gap_store_link_key_for_bd_addr

This commit is contained in:
Matthias Ringwald 2016-06-20 12:08:59 +02:00
parent 4dfd504ad1
commit 55597469a7
2 changed files with 17 additions and 6 deletions

View File

@ -353,9 +353,18 @@ void gap_local_bd_addr(bd_addr_t address_buffer);
/**
* @brief Deletes link key for remote device with baseband address.
* @param addr
*/
void gap_drop_link_key_for_bd_addr(bd_addr_t addr);
/**
* @brief Store link key for remote device with baseband address
* @param addr
* @param link_key
* @param link_key_type
*/
void gap_store_link_key_for_bd_addr(bd_addr_t addr, link_key_t link_key, link_key_type_t type);
// LE
/**

View File

@ -263,9 +263,13 @@ int hci_authentication_active_for_handle(hci_con_handle_t handle){
}
void gap_drop_link_key_for_bd_addr(bd_addr_t addr){
if (hci_stack->link_key_db) {
hci_stack->link_key_db->delete_link_key(addr);
}
if (!hci_stack->link_key_db) return;
hci_stack->link_key_db->delete_link_key(addr);
}
void gap_store_link_key_for_bd_addr(bd_addr_t addr, link_key_t link_key, link_key_type_t type){
if (!hci_stack->link_key_db) return;
hci_stack->link_key_db->put_link_key(addr, link_key, type);
}
static int hci_is_le_connection(hci_connection_t * connection){
@ -273,7 +277,6 @@ static int hci_is_le_connection(hci_connection_t * connection){
connection->address_type == BD_ADDR_TYPE_LE_RANDOM;
}
/**
* count connections
*/
@ -1631,8 +1634,7 @@ static void event_handler(uint8_t *packet, int size){
if (link_key_type != CHANGED_COMBINATION_KEY){
conn->link_key_type = link_key_type;
}
if (!hci_stack->link_key_db) break;
hci_stack->link_key_db->put_link_key(addr, &packet[8], conn->link_key_type);
gap_store_link_key_for_bd_addr(addr, &packet[8], conn->link_key_type);
// still forward event to allow dismiss of pairing dialog
break;
}