sm: improve le_device_db lookup and storing of IRK

This commit is contained in:
Matthias Ringwald 2018-05-15 09:25:02 +02:00
parent 9650eb2f69
commit c7e2c1a542
2 changed files with 13 additions and 6 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- SM: Fix LE Secure Connection pairing in Central role
- le_device_db_tlv: fix seq nr management
- SM: improve le_device_db lookup and storing of IRK
## Changes April 2018

View File

@ -1204,14 +1204,20 @@ static void sm_key_distribution_handle_all_received(sm_connection_t * sm_conn){
for (i=0; i < le_device_db_max_count(); i++){
sm_key_t irk;
bd_addr_t address;
int address_type;
int address_type = BD_ADDR_TYPE_UNKNOWN;
le_device_db_info(i, &address_type, address, irk);
if (memcmp(irk, setup->sm_peer_irk, 16) == 0){
log_info("sm: device found for IRK, updating");
le_db_index = i;
break;
}
// check if valid entry retrieved
if (address_type == BD_ADDR_TYPE_UNKNOWN) continue;
// compare IRK
if (memcmp(irk, setup->sm_peer_irk, 16) != 0) continue;
log_info("sm: device found for IRK, updating");
le_db_index = i;
break;
}
} else {
// assert IRK is set to zero
memset(setup->sm_peer_irk, 0, 16);
}
// if not found, lookup via public address if possible