mirror of https://github.com/ARMmbed/mbed-os.git
privacy pass
parent
aa6342b265
commit
f8c28fcbe7
|
@ -17,6 +17,7 @@
|
||||||
#ifndef MBED_BLE_GAP_H__
|
#ifndef MBED_BLE_GAP_H__
|
||||||
#define MBED_BLE_GAP_H__
|
#define MBED_BLE_GAP_H__
|
||||||
|
|
||||||
|
#include "BLERoles.h"
|
||||||
#include "ble/common/StaticInterface.h"
|
#include "ble/common/StaticInterface.h"
|
||||||
#include "BLETypes.h"
|
#include "BLETypes.h"
|
||||||
#include "BLEProtocol.h"
|
#include "BLEProtocol.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#ifndef BLE_GAP_GAP_H
|
#ifndef BLE_GAP_GAP_H
|
||||||
#define BLE_GAP_GAP_H
|
#define BLE_GAP_GAP_H
|
||||||
|
|
||||||
|
#include "BLERoles.h"
|
||||||
#include "ble/common/StaticInterface.h"
|
#include "ble/common/StaticInterface.h"
|
||||||
#include "ble/BLETypes.h"
|
#include "ble/BLETypes.h"
|
||||||
#include "ble/BLEProtocol.h"
|
#include "ble/BLEProtocol.h"
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include "ble/gap/ScanParameters.h"
|
#include "ble/gap/ScanParameters.h"
|
||||||
#include "ble/gap/AdvertisingParameters.h"
|
#include "ble/gap/AdvertisingParameters.h"
|
||||||
#include "ble/gap/Events.h"
|
#include "ble/gap/Events.h"
|
||||||
#include "BLERoles.h"
|
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
@ -1165,19 +1165,8 @@ public:
|
||||||
coded_symbol_per_bit_t codedSymbol
|
coded_symbol_per_bit_t codedSymbol
|
||||||
);
|
);
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
|
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
/**
|
|
||||||
* Default peripheral privacy configuration.
|
|
||||||
*/
|
|
||||||
static const peripheral_privacy_configuration_t
|
|
||||||
default_peripheral_privacy_configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default peripheral privacy configuration.
|
|
||||||
*/
|
|
||||||
static const central_privay_configuration_t
|
|
||||||
default_central_privacy_configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable privacy mode of the local device.
|
* Enable or disable privacy mode of the local device.
|
||||||
*
|
*
|
||||||
|
@ -1213,7 +1202,13 @@ public:
|
||||||
*/
|
*/
|
||||||
ble_error_t enablePrivacy(bool enable);
|
ble_error_t enablePrivacy(bool enable);
|
||||||
|
|
||||||
#if BLE_ROLE_PERIPHERAL
|
#if BLE_ROLE_BROADCASTER
|
||||||
|
/**
|
||||||
|
* Default peripheral privacy configuration.
|
||||||
|
*/
|
||||||
|
static const peripheral_privacy_configuration_t
|
||||||
|
default_peripheral_privacy_configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the privacy configuration used by the peripheral role.
|
* Set the privacy configuration used by the peripheral role.
|
||||||
*
|
*
|
||||||
|
@ -1236,9 +1231,15 @@ public:
|
||||||
ble_error_t getPeripheralPrivacyConfiguration(
|
ble_error_t getPeripheralPrivacyConfiguration(
|
||||||
peripheral_privacy_configuration_t *configuration
|
peripheral_privacy_configuration_t *configuration
|
||||||
);
|
);
|
||||||
#endif // BLE_ROLE_PERIPHERAL
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
|
/**
|
||||||
|
* Default peripheral privacy configuration.
|
||||||
|
*/
|
||||||
|
static const central_privay_configuration_t
|
||||||
|
default_central_privacy_configuration;
|
||||||
|
|
||||||
#if BLE_ROLE_CENTRAL
|
|
||||||
/**
|
/**
|
||||||
* Set the privacy configuration used by the central role.
|
* Set the privacy configuration used by the central role.
|
||||||
*
|
*
|
||||||
|
@ -1261,7 +1262,7 @@ public:
|
||||||
ble_error_t getCentralPrivacyConfiguration(
|
ble_error_t getCentralPrivacyConfiguration(
|
||||||
central_privay_configuration_t *configuration
|
central_privay_configuration_t *configuration
|
||||||
);
|
);
|
||||||
#endif // BLE_ROLE_CENTRAL
|
#endif // BLE_ROLE_OBSERVER
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
|
|
||||||
#if !defined(DOXYGEN_ONLY)
|
#if !defined(DOXYGEN_ONLY)
|
||||||
|
|
|
@ -550,12 +550,12 @@ public:
|
||||||
*/
|
*/
|
||||||
ble_error_t initRadioNotification_(void);
|
ble_error_t initRadioNotification_(void);
|
||||||
|
|
||||||
|
#if BLE_FEATURE_PRIVACY
|
||||||
/**
|
/**
|
||||||
* @see Gap::enablePrivacy
|
* @see Gap::enablePrivacy
|
||||||
*/
|
*/
|
||||||
ble_error_t enablePrivacy_(bool enable);
|
ble_error_t enablePrivacy_(bool enable);
|
||||||
|
|
||||||
#if BLE_FEATURE_PRIVACY
|
|
||||||
#if BLE_ROLE_BROADCASTER
|
#if BLE_ROLE_BROADCASTER
|
||||||
/**
|
/**
|
||||||
* @see Gap::setPeripheralPrivacyConfiguration
|
* @see Gap::setPeripheralPrivacyConfiguration
|
||||||
|
@ -809,8 +809,12 @@ private:
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
#endif // BLE_FEATURE_WHITELIST
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
bool _privacy_enabled;
|
bool _privacy_enabled;
|
||||||
|
#if BLE_ROLE_BROADCASTER
|
||||||
PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
|
PeripheralPrivacyConfiguration_t _peripheral_privacy_configuration;
|
||||||
|
#endif
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
CentralPrivacyConfiguration_t _central_privacy_configuration;
|
CentralPrivacyConfiguration_t _central_privacy_configuration;
|
||||||
|
#endif
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
ble::address_t _random_static_identity_address;
|
ble::address_t _random_static_identity_address;
|
||||||
bool _random_address_rotating;
|
bool _random_address_rotating;
|
||||||
|
|
|
@ -214,7 +214,7 @@ void LegacyGap<Impl>::getPermittedTxPowerValues(
|
||||||
return impl()->getPermittedTxPowerValues_(valueArrayPP, countP);
|
return impl()->getPermittedTxPowerValues_(valueArrayPP, countP);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATEURE_WHITELIST
|
#if BLE_FEATURE_WHITELIST
|
||||||
#if BLE_ROLE_BROADCASTER
|
#if BLE_ROLE_BROADCASTER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
ble_error_t LegacyGap<Impl>::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) {
|
ble_error_t LegacyGap<Impl>::setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) {
|
||||||
|
@ -253,7 +253,7 @@ LegacyGap<Impl>::getInitiatorPolicyMode(void) const {
|
||||||
return impl()->getInitiatorPolicyMode_();
|
return impl()->getInitiatorPolicyMode_();
|
||||||
}
|
}
|
||||||
#endif // BLE_ROLE_CENTRAL
|
#endif // BLE_ROLE_CENTRAL
|
||||||
#endif // BLE_FEATEURE_WHITELIST
|
#endif // BLE_FEATURE_WHITELIST
|
||||||
|
|
||||||
#if BLE_ROLE_OBSERVER
|
#if BLE_ROLE_OBSERVER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
|
@ -582,7 +582,7 @@ typename LegacyGap<Impl>::TimeoutEventCallbackChain_t& LegacyGap<Impl>::onTimeou
|
||||||
return timeoutCallbackChain;
|
return timeoutCallbackChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_CONNECTION
|
#if BLE_FEATURE_CONNECTABLE
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
void LegacyGap<Impl>::onConnection(ConnectionEventCallback_t callback)
|
void LegacyGap<Impl>::onConnection(ConnectionEventCallback_t callback)
|
||||||
{
|
{
|
||||||
|
@ -607,6 +607,7 @@ typename LegacyGap<Impl>::DisconnectionEventCallbackChain_t& LegacyGap<Impl>::on
|
||||||
{
|
{
|
||||||
return disconnectionCallChain;
|
return disconnectionCallChain;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_FEATURE_CONNECTABLE
|
||||||
|
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
void LegacyGap<Impl>::onRadioNotification(void (*callback)(bool param))
|
void LegacyGap<Impl>::onRadioNotification(void (*callback)(bool param))
|
||||||
|
|
|
@ -409,17 +409,20 @@ Gap<Impl>::Gap() : _eventHandler(NULL)
|
||||||
/* -------------------- Future deprecation ------------------------- */
|
/* -------------------- Future deprecation ------------------------- */
|
||||||
|
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
|
#if BLE_ROLE_BROADCASTER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
const peripheral_privacy_configuration_t Gap<Impl>::default_peripheral_privacy_configuration = {
|
const peripheral_privacy_configuration_t Gap<Impl>::default_peripheral_privacy_configuration = {
|
||||||
/* use_non_resolvable_random_address */ false,
|
/* use_non_resolvable_random_address */ false,
|
||||||
/* resolution_strategy */ peripheral_privacy_configuration_t::PERFORM_PAIRING_PROCEDURE
|
/* resolution_strategy */ peripheral_privacy_configuration_t::PERFORM_PAIRING_PROCEDURE
|
||||||
};
|
};
|
||||||
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
const central_privay_configuration_t Gap<Impl>::default_central_privacy_configuration = {
|
const central_privay_configuration_t Gap<Impl>::default_central_privacy_configuration = {
|
||||||
/* use_non_resolvable_random_address */ false,
|
/* use_non_resolvable_random_address */ false,
|
||||||
/* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
|
/* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
|
||||||
};
|
};
|
||||||
|
#endif // BLE_ROLE_OBSERVER
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
|
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
|
@ -429,6 +432,7 @@ ble_error_t Gap<Impl>::enablePrivacy(bool enable)
|
||||||
return impl()->enablePrivacy_(enable);
|
return impl()->enablePrivacy_(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BLE_ROLE_BROADCASTER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
ble_error_t Gap<Impl>::setPeripheralPrivacyConfiguration(
|
ble_error_t Gap<Impl>::setPeripheralPrivacyConfiguration(
|
||||||
const peripheral_privacy_configuration_t *configuration
|
const peripheral_privacy_configuration_t *configuration
|
||||||
|
@ -444,7 +448,9 @@ ble_error_t Gap<Impl>::getPeripheralPrivacyConfiguration(
|
||||||
{
|
{
|
||||||
return impl()->getPeripheralPrivacyConfiguration_(configuration);
|
return impl()->getPeripheralPrivacyConfiguration_(configuration);
|
||||||
}
|
}
|
||||||
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
template<class Impl>
|
template<class Impl>
|
||||||
ble_error_t Gap<Impl>::setCentralPrivacyConfiguration(
|
ble_error_t Gap<Impl>::setCentralPrivacyConfiguration(
|
||||||
const central_privay_configuration_t *configuration
|
const central_privay_configuration_t *configuration
|
||||||
|
@ -460,6 +466,7 @@ ble_error_t Gap<Impl>::getCentralPrivacyConfiguration(
|
||||||
{
|
{
|
||||||
return impl()->getCentralPrivacyConfiguration_(configuration);
|
return impl()->getCentralPrivacyConfiguration_(configuration);
|
||||||
}
|
}
|
||||||
|
#endif // BLE_ROLE_OBSERVER
|
||||||
#endif // BLE_FEATURE_PRIVACY
|
#endif // BLE_FEATURE_PRIVACY
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -448,8 +448,12 @@ GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
#endif // BLE_FEATURE_WHITELIST
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
_privacy_enabled(false),
|
_privacy_enabled(false),
|
||||||
|
#if BLE_ROLE_BROADCASTER
|
||||||
_peripheral_privacy_configuration(default_peripheral_privacy_configuration),
|
_peripheral_privacy_configuration(default_peripheral_privacy_configuration),
|
||||||
|
#endif
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
_central_privacy_configuration(default_central_privacy_configuration),
|
_central_privacy_configuration(default_central_privacy_configuration),
|
||||||
|
#endif
|
||||||
_random_address_rotating(false),
|
_random_address_rotating(false),
|
||||||
#endif //BLE_FEATURE_PRIVACY
|
#endif //BLE_FEATURE_PRIVACY
|
||||||
_scan_enabled(false),
|
_scan_enabled(false),
|
||||||
|
@ -2038,11 +2042,16 @@ pal::own_address_type_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEve
|
||||||
#if BLE_FEATURE_PRIVACY
|
#if BLE_FEATURE_PRIVACY
|
||||||
if (_privacy_enabled) {
|
if (_privacy_enabled) {
|
||||||
bool use_non_resolvable_address = false;
|
bool use_non_resolvable_address = false;
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
if (address_use_type == CENTRAL_SCAN) {
|
if (address_use_type == CENTRAL_SCAN) {
|
||||||
use_non_resolvable_address = _central_privacy_configuration.use_non_resolvable_random_address;
|
use_non_resolvable_address = _central_privacy_configuration.use_non_resolvable_random_address;
|
||||||
} else if (address_use_type == PERIPHERAL_NON_CONNECTABLE) {
|
} else
|
||||||
|
#endif
|
||||||
|
#if BLE_ROLE_BROADCASTER
|
||||||
|
if (address_use_type == PERIPHERAL_NON_CONNECTABLE) {
|
||||||
use_non_resolvable_address = _peripheral_privacy_configuration.use_non_resolvable_random_address;
|
use_non_resolvable_address = _peripheral_privacy_configuration.use_non_resolvable_random_address;
|
||||||
}
|
}
|
||||||
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
|
||||||
// An non resolvable private address should be generated
|
// An non resolvable private address should be generated
|
||||||
if (use_non_resolvable_address) {
|
if (use_non_resolvable_address) {
|
||||||
|
@ -2096,15 +2105,20 @@ bool GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
||||||
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>::update_address_resolution_setting()
|
ble_error_t GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandler>::update_address_resolution_setting()
|
||||||
{
|
{
|
||||||
// Only disable if privacy is disabled or resolution is not requested in either central or peripheral mode
|
// enable if privacy is enabled and resolution is requested in either central or peripheral mode
|
||||||
bool enable = true;
|
bool enable = false;
|
||||||
|
|
||||||
if (!_privacy_enabled) {
|
if (_privacy_enabled) {
|
||||||
enable = false;
|
#if BLE_ROLE_BROADCASTER
|
||||||
}
|
if (_peripheral_privacy_configuration.resolution_strategy != PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
|
||||||
else if( (_peripheral_privacy_configuration.resolution_strategy == PeripheralPrivacyConfiguration_t::DO_NOT_RESOLVE)
|
enable = true;
|
||||||
&& (_central_privacy_configuration.resolution_strategy == CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) ) {
|
}
|
||||||
enable = false;
|
#endif // BLE_ROLE_BROADCASTER
|
||||||
|
#if BLE_ROLE_OBSERVER
|
||||||
|
if (_central_privacy_configuration.resolution_strategy != CentralPrivacyConfiguration_t::DO_NOT_RESOLVE) {
|
||||||
|
enable = true;
|
||||||
|
}
|
||||||
|
#endif // BLE_ROLE_OBSERVER
|
||||||
}
|
}
|
||||||
|
|
||||||
return _pal_gap.set_address_resolution(enable);
|
return _pal_gap.set_address_resolution(enable);
|
||||||
|
@ -2146,7 +2160,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
||||||
// This event might have been queued before we disabled address rotation
|
// This event might have been queued before we disabled address rotation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
if (is_extended_advertising_available()) {
|
if (is_extended_advertising_available()) {
|
||||||
for (uint8_t i = 0; i < MAX_ADVERTISING_SETS; ++i) {
|
for (uint8_t i = 0; i < MAX_ADVERTISING_SETS; ++i) {
|
||||||
if (_existing_sets.get(i)) {
|
if (_existing_sets.get(i)) {
|
||||||
|
@ -2164,6 +2178,7 @@ void GenericGap<PalGapImpl, PalSecurityManager, ConnectionEventMonitorEventHandl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||||
|
|
||||||
ble::address_t address;
|
ble::address_t address;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue