Skip to content

Commit 5f5ce45

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

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "mbed_critical.h"
2626

2727
// Cordio Includes
28+
#include "ll_math.h"
2829
#include "ll_init_api.h"
2930
#include "ll_defs.h"
3031
#include "custom_chci_tr.h"
@@ -350,9 +351,17 @@ void NRFCordioHCIDriver::start_reset_sequence()
350351

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

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

357366
return true;
358367
}

0 commit comments

Comments
 (0)