Skip to content

Commit 4c1afe8

Browse files
committed
BLE: Update identity address when retrieved from the DB
1 parent 7c8a754 commit 4c1afe8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,12 @@ ble_error_t SecurityManager::init_identity()
10381038
ble::Gap& gap = BLE::Instance().gap();
10391039

10401040
irk_t irk = _db->get_local_irk();
1041+
address_t identity_address;
1042+
bool public_identity_address = false;
10411043
if (irk != irk_t()) {
10421044
pirk = &irk;
1045+
public_identity_address = _db->is_local_identity_address_public();
1046+
identity_address = _db->get_local_identity_address();
10431047

10441048
if (!_db->is_local_identity_address_public()) {
10451049
// Some controllers doesn't store their random static address and
@@ -1060,16 +1064,15 @@ ble_error_t SecurityManager::init_identity()
10601064
}
10611065

10621066
pirk = &irk;
1063-
address_t random_static_address = gap.getRandomStaticAddress();
1064-
if (ret != BLE_ERROR_NONE) {
1065-
return ret;
1066-
}
1067-
_db->set_local_identity(irk, random_static_address, /* public_address */ false);
1067+
public_identity_address = false;
1068+
identity_address = gap.getRandomStaticAddress();
1069+
_db->set_local_identity(irk, identity_address, public_identity_address);
10681070
}
10691071

10701072
auto err = _pal.set_irk(*pirk);
10711073
if (!err) {
10721074
_private_address_controller.set_local_irk(*pirk);
1075+
_pal.set_identity_address(identity_address, public_identity_address);
10731076
}
10741077
return err;
10751078
}

0 commit comments

Comments
 (0)