mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Add an HCI driver API to set the random static address.
parent
f469f710bc
commit
c66dd7fd1f
|
@ -1257,6 +1257,13 @@ public:
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
|
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
/*
|
||||||
|
* API reserverved for the controller driver to set the random static address.
|
||||||
|
* Setting a new random static address while the controller is operating is
|
||||||
|
* forbidden by the Bluetooth specification.
|
||||||
|
*/
|
||||||
|
ble_error_t setRandomStaticAddress(const ble::address_t& address);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Can only be called if use_non_deprecated_scan_api() hasn't been called.
|
/** Can only be called if use_non_deprecated_scan_api() hasn't been called.
|
||||||
* This guards against mixed use of deprecated and nondeprecated API.
|
* This guards against mixed use of deprecated and nondeprecated API.
|
||||||
|
@ -1407,6 +1414,7 @@ protected:
|
||||||
ble_error_t getCentralPrivacyConfiguration_(
|
ble_error_t getCentralPrivacyConfiguration_(
|
||||||
central_privay_configuration_t *configuration
|
central_privay_configuration_t *configuration
|
||||||
);
|
);
|
||||||
|
ble_error_t setRandomStaticAddress_(const ble::address_t& address);
|
||||||
void useVersionOneAPI_() const;
|
void useVersionOneAPI_() const;
|
||||||
void useVersionTwoAPI_() const;
|
void useVersionTwoAPI_() const;
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,11 @@ public:
|
||||||
const BLEProtocol::AddressBytes_t address
|
const BLEProtocol::AddressBytes_t address
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Gap::setRandomStaticAddress
|
||||||
|
*/
|
||||||
|
ble_error_t setRandomStaticAddress_(const ble::address_t& address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Gap::getAddress
|
* @see Gap::getAddress
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -494,6 +494,12 @@ ble_error_t Gap<Impl>::getCentralPrivacyConfiguration(
|
||||||
#endif // BLE_ROLE_OBSERVER
|
#endif // BLE_ROLE_OBSERVER
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
|
|
||||||
|
template<class Impl>
|
||||||
|
ble_error_t Gap<Impl>::setRandomStaticAddress(const ble::address_t& address)
|
||||||
|
{
|
||||||
|
return impl()->setRandomStaticAddress_(address);
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/* ------------------------- Default implementations ------------------------ */
|
/* ------------------------- Default implementations ------------------------ */
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -861,6 +867,12 @@ ble_error_t Gap<Impl>::getCentralPrivacyConfiguration_(
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Impl>
|
||||||
|
ble_error_t Gap<Impl>::setRandomStaticAddress_(const ble::address_t& address)
|
||||||
|
{
|
||||||
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace interface
|
} // namespace interface
|
||||||
} // namespace ble
|
} // namespace ble
|
||||||
|
|
||||||
|
|
|
@ -510,6 +510,26 @@ ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||||
|
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::setRandomStaticAddress_(
|
||||||
|
const ble::address_t& address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (is_random_static_address(address.data()) == false) {
|
||||||
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
ble_error_t err = _pal_gap.set_random_address(address);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
_address_type = LegacyAddressType::RANDOM_STATIC;
|
||||||
|
_address = address;
|
||||||
|
_random_static_identity_address = address;
|
||||||
|
return BLE_ERROR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
template <template<class> class PalGapImpl, class PalSecurityManager, class ConnectionEventMonitorEventHandler>
|
||||||
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getAddress_(
|
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::getAddress_(
|
||||||
LegacyAddressType_t *type,
|
LegacyAddressType_t *type,
|
||||||
|
|
|
@ -96,6 +96,13 @@ buf_pool_desc_t CordioHCIDriver::get_default_buffer_pool_description()
|
||||||
return buf_pool_desc_t(buffer, pool_desc);
|
return buf_pool_desc_t(buffer, pool_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CordioHCIDriver::set_random_static_address(const ble::address_t& address)
|
||||||
|
{
|
||||||
|
ble_error_t err = cordio::BLE::deviceInstance().getGap().setRandomStaticAddress(address);
|
||||||
|
MBED_ASSERT(err == BLE_ERROR_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CordioHCIDriver::start_reset_sequence()
|
void CordioHCIDriver::start_reset_sequence()
|
||||||
{
|
{
|
||||||
/* send an HCI Reset command to start the sequence */
|
/* send an HCI Reset command to start the sequence */
|
||||||
|
@ -148,10 +155,7 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
|
||||||
|
|
||||||
if (get_random_static_address(static_address)) {
|
if (get_random_static_address(static_address)) {
|
||||||
// note: will send the HCI command to send the random address
|
// note: will send the HCI command to send the random address
|
||||||
cordio::BLE::deviceInstance().getGap().setAddress(
|
set_random_static_address(static_address.data());
|
||||||
BLEProtocol::AddressType::RANDOM_STATIC,
|
|
||||||
static_address.data()
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
/* send next command in sequence */
|
/* send next command in sequence */
|
||||||
HciLeReadBufSizeCmd();
|
HciLeReadBufSizeCmd();
|
||||||
|
|
|
@ -151,6 +151,13 @@ protected:
|
||||||
*/
|
*/
|
||||||
buf_pool_desc_t get_default_buffer_pool_description();
|
buf_pool_desc_t get_default_buffer_pool_description();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the driver to set a random static address. Unlike the HCI command
|
||||||
|
* this function reports the random static address to the whole BLE system.
|
||||||
|
* @param random_static_address The random static address to set.
|
||||||
|
*/
|
||||||
|
void set_random_static_address(const ble::address_t& random_static_address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Initialize the chip.
|
* Initialize the chip.
|
||||||
|
|
Loading…
Reference in New Issue