BLE: Add an option to inject the random static address during the reset sequence.

pull/8998/head
Vincent Coubard 2018-12-07 12:33:31 +00:00
parent 0d398bc8c8
commit a36b04fde5
2 changed files with 31 additions and 1 deletions

View File

@ -17,6 +17,7 @@
#include <stddef.h>
#include <string.h>
#include "CordioBLE.h"
#include "CordioHCIDriver.h"
#include "hci_api.h"
#include "hci_cmd.h"
@ -139,10 +140,26 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
HciReadBdAddrCmd();
break;
case HCI_OPCODE_READ_BD_ADDR:
case HCI_OPCODE_READ_BD_ADDR: {
/* parse and store event parameters */
BdaCpy(hciCoreCb.bdAddr, pMsg);
ble::address_t static_address;
if (get_random_static_address(static_address)) {
// note: will send the HCI command to send the random address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
static_address.data()
);
} else {
/* send next command in sequence */
HciLeReadBufSizeCmd();
}
break;
}
case HCI_OPCODE_LE_SET_RAND_ADDR:
/* send next command in sequence */
HciLeReadBufSizeCmd();
break;
@ -246,6 +263,11 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
}
}
bool CordioHCIDriver::get_random_static_address(ble::address_t& address)
{
return false;
}
void CordioHCIDriver::signal_reset_sequence_done()
{
hci_mbed_os_signal_reset_sequence_done();

View File

@ -19,6 +19,7 @@
#include <stddef.h>
#include <stdint.h>
#include <BLETypes.h>
#include "wsf_buf.h"
#include "CordioHCITransportDriver.h"
@ -108,6 +109,13 @@ public:
*/
virtual void handle_reset_sequence(uint8_t *msg);
/**
* Get the random static address of the controller
*
* @return false if the address has not been set and true otherwise.
*/
virtual bool get_random_static_address(ble::address_t& address);
/**
* Signal to the stack that the reset sequence has been done.
*/