BLE: move privacy configuration type in ble namespace.

pull/8738/head
Vincent Coubard 2018-11-25 11:46:00 +00:00
parent dff8f25d49
commit 0407ee8c81
4 changed files with 152 additions and 146 deletions

View File

@ -649,6 +649,16 @@ public:
}
};
/**
* @copydoc ble::peripheral_privacy_configuration_t
*/
typedef ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t;
/**
* @copydoc ble::central_privay_configuration_t
*/
typedef ble::central_privay_configuration_t CentralPrivacyConfiguration_t;
/**
* Number of microseconds in 1.25 milliseconds.
*/

View File

@ -1075,146 +1075,16 @@ public:
coded_symbol_per_bit_t codedSymbol
);
protected:
#if !defined(DOXYGEN_ONLY)
/* Override the following in the underlying adaptation layer to provide the
* functionality of scanning. */
/** Can only be called if use_non_deprecated_scan_api() hasn't been called.
* This guards against mixed use of deprecated and nondeprecated API.
*/
virtual void useVersionOneAPI() const
{
}
/** Can only be called if use_deprecated_scan_api() hasn't been called.
* This guards against mixed use of deprecated and nondeprecated API.
*/
virtual void useVersionTwoAPI() const
{
}
#endif
/* -------- soon to be deprecated API -------- */
public:
/**
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
struct PeripheralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* peripheral advertises non connectable packets.
*
* Resolvable random address continues to be used for connectable packets.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy for initiator resolvable addresses when a
* connection request is received.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address of the initiator and accept the
* connection request.
*/
DO_NOT_RESOLVE,
/**
* If a bond is present in the secure database and the address
* resolution fail then reject the connection request with the error
* code AUTHENTICATION_FAILLURE.
*/
REJECT_NON_RESOLVED_ADDRESS,
/**
* Perform the pairing procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_PAIRING_PROCEDURE,
/**
* Perform the authentication procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_AUTHENTICATION_PROCEDURE
};
/**
* Connection strategy to use when a connection request contains a
* private resolvable address.
*/
ResolutionStrategy resolution_strategy;
};
/**
* Privacy Configuration of the central role.
*
* @note This configuration is also used when the local device operates as
* an observer.
*/
struct CentralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* central or observer sends scan request packets.
*
* Resolvable random address continue to be used for connection requests.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy of resolvable addresses received in advertising
* packets.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address received in advertising packets.
*/
DO_NOT_RESOLVE,
/**
* Resolve the resolvable addresses in the advertising packet and
* forward advertising packet to the application independently of
* the address resolution procedure result.
*/
RESOLVE_AND_FORWARD,
/**
* Filter out packets containing a resolvable that cannot be resolved
* by this device.
*
* @note Filtering is applied if the local device contains at least
* one bond.
*/
RESOLVE_AND_FILTER
};
/**
* Resolution strategy applied to advertising packets received by the
* local device.
*/
ResolutionStrategy resolution_strategy;
};
/**
* Default peripheral privacy configuration.
*/
static const PeripheralPrivacyConfiguration_t
* Default peripheral privacy configuration.
*/
static const peripheral_privacy_configuration_t
default_peripheral_privacy_configuration;
/**
* Default peripheral privacy configuration.
*/
static const CentralPrivacyConfiguration_t
static const central_privay_configuration_t
default_central_privacy_configuration;
/**
@ -1260,7 +1130,7 @@ public:
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setPeripheralPrivacyConfiguration(
const PeripheralPrivacyConfiguration_t *configuration
const peripheral_privacy_configuration_t *configuration
);
/**
@ -1272,7 +1142,7 @@ public:
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getPeripheralPrivacyConfiguration(
PeripheralPrivacyConfiguration_t *configuration
peripheral_privacy_configuration_t *configuration
);
/**
@ -1283,7 +1153,7 @@ public:
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setCentralPrivacyConfiguration(
const CentralPrivacyConfiguration_t *configuration
const central_privay_configuration_t *configuration
);
/**
@ -1295,11 +1165,34 @@ public:
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getCentralPrivacyConfiguration(
CentralPrivacyConfiguration_t *configuration
central_privay_configuration_t *configuration
);
protected:
#if !defined(DOXYGEN_ONLY)
/* Override the following in the underlying adaptation layer to provide the
* functionality of scanning. */
/** Can only be called if use_non_deprecated_scan_api() hasn't been called.
* This guards against mixed use of deprecated and nondeprecated API.
*/
virtual void useVersionOneAPI() const
{
}
/** Can only be called if use_deprecated_scan_api() hasn't been called.
* This guards against mixed use of deprecated and nondeprecated API.
*/
virtual void useVersionTwoAPI() const
{
}
#endif
protected:
#if !defined(DOXYGEN_ONLY)
/**

View File

@ -846,6 +846,109 @@ struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
}
};
/**
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
struct peripheral_privacy_configuration_t {
/**
* Indicates if non resolvable random address should be used when the
* peripheral advertises non connectable packets.
*
* Resolvable random address continues to be used for connectable packets.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy for initiator resolvable addresses when a
* connection request is received.
*/
enum resolution_strategy_t {
/**
* Do not resolve the address of the initiator and accept the
* connection request.
*/
DO_NOT_RESOLVE,
/**
* If a bond is present in the secure database and the address
* resolution fail then reject the connection request with the error
* code AUTHENTICATION_FAILLURE.
*/
REJECT_NON_RESOLVED_ADDRESS,
/**
* Perform the pairing procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_PAIRING_PROCEDURE,
/**
* Perform the authentication procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_AUTHENTICATION_PROCEDURE
};
/**
* Connection strategy to use when a connection request contains a
* private resolvable address.
*/
resolution_strategy_t resolution_strategy;
};
/**
* Privacy Configuration of the central role.
*
* @note This configuration is also used when the local device operates as
* an observer.
*/
struct central_privay_configuration_t {
/**
* Indicates if non resolvable random address should be used when the
* central or observer sends scan request packets.
*
* Resolvable random address continue to be used for connection requests.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy of resolvable addresses received in advertising
* packets.
*/
enum resolution_strategy_t {
/**
* Do not resolve the address received in advertising packets.
*/
DO_NOT_RESOLVE,
/**
* Resolve the resolvable addresses in the advertising packet and
* forward advertising packet to the application independently of
* the address resolution procedure result.
*/
RESOLVE_AND_FORWARD,
/**
* Filter out packets containing a resolvable that cannot be resolved
* by this device.
*
* @note Filtering is applied if the local device contains at least
* one bond.
*/
RESOLVE_AND_FILTER
};
/**
* Resolution strategy applied to advertising packets received by the
* local device.
*/
resolution_strategy_t resolution_strategy;
};
/**
* @}
* @}

View File

@ -317,14 +317,14 @@ ble_error_t Gap::setPhy(
/* -------------------- Future deprecation ------------------------- */
const Gap::PeripheralPrivacyConfiguration_t Gap::default_peripheral_privacy_configuration = {
const peripheral_privacy_configuration_t Gap::default_peripheral_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ PeripheralPrivacyConfiguration_t::PERFORM_PAIRING_PROCEDURE
/* resolution_strategy */ peripheral_privacy_configuration_t::PERFORM_PAIRING_PROCEDURE
};
const Gap::CentralPrivacyConfiguration_t Gap::default_central_privacy_configuration = {
const central_privay_configuration_t Gap::default_central_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ CentralPrivacyConfiguration_t::RESOLVE_AND_FORWARD
/* resolution_strategy */ central_privay_configuration_t::RESOLVE_AND_FORWARD
};
ble_error_t Gap::enablePrivacy(bool enable)
@ -333,28 +333,28 @@ ble_error_t Gap::enablePrivacy(bool enable)
}
ble_error_t Gap::setPeripheralPrivacyConfiguration(
const PeripheralPrivacyConfiguration_t *configuration
const peripheral_privacy_configuration_t *configuration
)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::getPeripheralPrivacyConfiguration(
PeripheralPrivacyConfiguration_t *configuration
peripheral_privacy_configuration_t *configuration
)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::setCentralPrivacyConfiguration(
const CentralPrivacyConfiguration_t *configuration
const central_privay_configuration_t *configuration
)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::getCentralPrivacyConfiguration(
CentralPrivacyConfiguration_t *configuration
central_privay_configuration_t *configuration
)
{
return BLE_ERROR_NOT_IMPLEMENTED;