Skip to content

Commit cf6e487

Browse files
create a random static address using random data
1 parent c3a39e9 commit cf6e487

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,17 @@ void NRFCordioHCIDriver::start_reset_sequence()
350350

351351
bool NRFCordioHCIDriver::get_random_static_address(ble::address_t& address)
352352
{
353-
PalCfgLoadData(PAL_CFG_ID_BD_ADDR, address.data(), sizeof(bdAddr_t));
353+
/* Load address from nRF configuration. */
354+
uint64_t address_int = (((uint64_t)NRF_FICR->DEVICEID[0]) << 0) |
355+
(((uint64_t)NRF_FICR->DEVICEID[1]) << 32);
354356

355-
MBED_ASSERT((address[5] & 0xC0) == 0xC0);
357+
unsigned int i = 0;
358+
while (i++ < BDA_ADDR_LEN) {
359+
address[i] = address_int >> (i * 8);
360+
}
361+
362+
/* Top two bits of static address must be 11 (Vol C, Part 3, section 10.8.1) */
363+
address[5] |= 0xC0;
356364

357365
return true;
358366
}

0 commit comments

Comments
 (0)