From 0407ee8c810c42f3fe0efd33b29b2d2f63b35a06 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Sun, 25 Nov 2018 11:46:00 +0000 Subject: [PATCH] BLE: move privacy configuration type in ble namespace. --- features/FEATURE_BLE/ble/Gap.h | 10 ++ features/FEATURE_BLE/ble/gap/Gap.h | 169 +++++------------------- features/FEATURE_BLE/ble/gap/Types.h | 103 +++++++++++++++ features/FEATURE_BLE/source/gap/Gap.cpp | 16 +-- 4 files changed, 152 insertions(+), 146 deletions(-) diff --git a/features/FEATURE_BLE/ble/Gap.h b/features/FEATURE_BLE/ble/Gap.h index c74b729458..eb500cd30e 100644 --- a/features/FEATURE_BLE/ble/Gap.h +++ b/features/FEATURE_BLE/ble/Gap.h @@ -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. */ diff --git a/features/FEATURE_BLE/ble/gap/Gap.h b/features/FEATURE_BLE/ble/gap/Gap.h index baa9422498..b2d0023aee 100644 --- a/features/FEATURE_BLE/ble/gap/Gap.h +++ b/features/FEATURE_BLE/ble/gap/Gap.h @@ -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) /** diff --git a/features/FEATURE_BLE/ble/gap/Types.h b/features/FEATURE_BLE/ble/gap/Types.h index d56ed9fc52..21c50d7713 100644 --- a/features/FEATURE_BLE/ble/gap/Types.h +++ b/features/FEATURE_BLE/ble/gap/Types.h @@ -846,6 +846,109 @@ struct disconnection_reason_t : SafeEnum { } }; +/** + * 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; +}; + + /** * @} * @} diff --git a/features/FEATURE_BLE/source/gap/Gap.cpp b/features/FEATURE_BLE/source/gap/Gap.cpp index 3f69641368..8b62805df3 100644 --- a/features/FEATURE_BLE/source/gap/Gap.cpp +++ b/features/FEATURE_BLE/source/gap/Gap.cpp @@ -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;