Skip to content

Commit a59a2e9

Browse files
pan-Cruz Monrreal II
authored andcommitted
BLE: Add an option to inject the random static address during the reset sequence.
1 parent d1af84a commit a59a2e9

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCIDriver.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <stddef.h>
1818
#include <string.h>
1919

20+
#include "CordioBLE.h"
2021
#include "CordioHCIDriver.h"
2122
#include "hci_api.h"
2223
#include "hci_cmd.h"
@@ -139,10 +140,26 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
139140
HciReadBdAddrCmd();
140141
break;
141142

142-
case HCI_OPCODE_READ_BD_ADDR:
143+
case HCI_OPCODE_READ_BD_ADDR: {
143144
/* parse and store event parameters */
144145
BdaCpy(hciCoreCb.bdAddr, pMsg);
145146

147+
ble::address_t static_address;
148+
149+
if (get_random_static_address(static_address)) {
150+
// note: will send the HCI command to send the random address
151+
cordio::BLE::deviceInstance().getGap().setAddress(
152+
BLEProtocol::AddressType::RANDOM_STATIC,
153+
static_address.data()
154+
);
155+
} else {
156+
/* send next command in sequence */
157+
HciLeReadBufSizeCmd();
158+
}
159+
break;
160+
}
161+
162+
case HCI_OPCODE_LE_SET_RAND_ADDR:
146163
/* send next command in sequence */
147164
HciLeReadBufSizeCmd();
148165
break;
@@ -246,6 +263,11 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
246263
}
247264
}
248265

266+
bool CordioHCIDriver::get_random_static_address(ble::address_t& address)
267+
{
268+
return false;
269+
}
270+
249271
void CordioHCIDriver::signal_reset_sequence_done()
250272
{
251273
hci_mbed_os_signal_reset_sequence_done();

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCIDriver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <stddef.h>
2121
#include <stdint.h>
22+
#include <BLETypes.h>
2223
#include "wsf_buf.h"
2324
#include "CordioHCITransportDriver.h"
2425

@@ -108,6 +109,13 @@ class CordioHCIDriver {
108109
*/
109110
virtual void handle_reset_sequence(uint8_t *msg);
110111

112+
/**
113+
* Get the random static address of the controller
114+
*
115+
* @return false if the address has not been set and true otherwise.
116+
*/
117+
virtual bool get_random_static_address(ble::address_t& address);
118+
111119
/**
112120
* Signal to the stack that the reset sequence has been done.
113121
*/

0 commit comments

Comments
 (0)