Skip to content

Commit a7d43fc

Browse files
pan-Cruz Monrreal II
authored andcommitted
BLE: Inject random static address during reset sequence.
1 parent a59a2e9 commit a7d43fc

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ void NRFCordioHCIDriver::start_reset_sequence()
313313
CordioHCIDriver::start_reset_sequence();
314314
}
315315

316+
bool NRFCordioHCIDriver::get_random_static_address(ble::address_t& address)
317+
{
318+
/* Load address from nRF configuration. */
319+
uint64_t devAddr = (((uint64_t)NRF_FICR->DEVICEADDR[0]) << 0) |
320+
(((uint64_t)NRF_FICR->DEVICEADDR[1]) << 32);
321+
322+
for (size_t i = 0; i < address.size(); ++i) {
323+
address[i] = devAddr >> (i * 8);
324+
}
325+
326+
address[5] |= 0xC0; /* cf. "Static Address" (Vol C, Part 3, section 10.8.1) */
327+
return true;
328+
}
329+
330+
316331
ble::vendor::cordio::CordioHCIDriver& ble_cordio_get_hci_driver() {
317332
static NRFCordioHCITransportDriver transport_driver;
318333

@@ -344,6 +359,4 @@ void PlatformLoadBdAddress(uint8_t *pDevAddr)
344359
pDevAddr[i] = devAddr >> (i * 8);
345360
i++;
346361
}
347-
348-
pDevAddr[5] |= 0xC0; /* cf. "Static Address" (Vol C, Part 3, section 10.8.1) */
349362
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class NRFCordioHCIDriver : public cordio::CordioHCIDriver {
5959
*/
6060
//virtual void handle_reset_sequence(uint8_t *msg);
6161

62+
/**
63+
* @copydoc cordio::CordioHCIDriver::get_random_static_address
64+
*/
65+
virtual bool get_random_static_address(ble::address_t& address);
66+
6267
private:
6368
/**
6469
* Initialize the chip.

0 commit comments

Comments
 (0)