diff --git a/features/FEATURE_BLE/ble/gap/AdvertisingParameters.h b/features/FEATURE_BLE/ble/gap/AdvertisingParameters.h index 4f6bd1eef3..942f504254 100644 --- a/features/FEATURE_BLE/ble/gap/AdvertisingParameters.h +++ b/features/FEATURE_BLE/ble/gap/AdvertisingParameters.h @@ -82,7 +82,7 @@ public: _maxInterval(maxInterval), _peerAddressType(ble::target_peer_address_type_t::PUBLIC), _ownAddressType(ble::own_address_type_t::PUBLIC), - _policy(ble::ADV_POLICY_IGNORE_WHITELIST), + _policy(advertising_filter_policy_t::NO_FILTER), _primaryPhy(ble::phy_t::LE_1M), _secondaryPhy(ble::phy_t::LE_1M), _peerAddress(), @@ -273,7 +273,7 @@ public: * * @return A reference to this object. */ - AdvertisingParameters &setPolicyMode(advertising_policy_mode_t mode) + AdvertisingParameters &setPolicyMode(advertising_filter_policy_t mode) { _policy = mode; return *this; @@ -283,7 +283,7 @@ public: * * @return Policy used. */ - ble::advertising_policy_mode_t getPolicyMode() const + ble::advertising_filter_policy_t getPolicyMode() const { return _policy; } @@ -458,7 +458,7 @@ private: target_peer_address_type_t _peerAddressType; own_address_type_t _ownAddressType; - advertising_policy_mode_t _policy; + advertising_filter_policy_t _policy; phy_t _primaryPhy; phy_t _secondaryPhy; address_t _peerAddress; diff --git a/features/FEATURE_BLE/ble/gap/Types.h b/features/FEATURE_BLE/ble/gap/Types.h index dbd9360264..b3717540ca 100644 --- a/features/FEATURE_BLE/ble/gap/Types.h +++ b/features/FEATURE_BLE/ble/gap/Types.h @@ -250,26 +250,34 @@ typedef int8_t advertising_power_t; * * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2. */ -enum advertising_policy_mode_t { - /** - * The whitelist is not used to filter peer request during advertising. - */ - ADV_POLICY_IGNORE_WHITELIST = 0, +struct advertising_filter_policy_t : SafeEnum { + enum type { + /** + * Process connection and scan requests from all devices. The whitelist is + * not used. + */ + NO_FILTER = 0x00, - /** - * The whitelist is used to filter peer scan requests. - */ - ADV_POLICY_FILTER_SCAN_REQS = 1, + /** + * Process connection requests from all devices but filter out scan requests + * of devices which are not in the whitelist. + */ + FILTER_SCAN_REQUESTS = 0x01, - /** - * The whitelist is used to filter peer connection requests. - */ - ADV_POLICY_FILTER_CONN_REQS = 2, + /** + * Process scan requests from all devices but filter out connection requests + * of devices which are not in the whitelist. + */ + FILTER_CONNECTION_REQUEST = 0x02, - /** - * The whitelist is used to filter peer scan and connection requests. - */ - ADV_POLICY_FILTER_ALL_REQS = 3, + /** + * Filter out scan or connection requests of devices which are not in the + * whitelist. + */ + FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03 + }; + + advertising_filter_policy_t(type value) : SafeEnum(value) { } }; /** diff --git a/features/FEATURE_BLE/ble/pal/GapTypes.h b/features/FEATURE_BLE/ble/pal/GapTypes.h index 6dd2beb689..4f320ea2a5 100644 --- a/features/FEATURE_BLE/ble/pal/GapTypes.h +++ b/features/FEATURE_BLE/ble/pal/GapTypes.h @@ -297,45 +297,7 @@ struct disconnection_reason_t : SafeEnum { SafeEnum(value) { } }; - -/** - * Filter policy which can be used during advertising. - */ -struct advertising_filter_policy_t : - SafeEnum { - enum type { - /** - * Process connection and scan requests from all devices. The whitelist is - * not used. - */ - NO_FILTER = 0x00, - - /** - * Process connection requests from all devices but filter out scan requests - * of devices which are not in the whitelist. - */ - FILTER_SCAN_REQUESTS = 0x01, - - /** - * Process scan requests from all devices but filter out connection requests - * of devices which are not in the whitelist. - */ - FILTER_CONNECTION_REQUEST = 0x02, - - /** - * Filter out scan or connection requests of devices which are not in the - * whitelist. - */ - FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03 - }; - - /** - * Construct a new instance of advertising_filter_policy_t. - */ - advertising_filter_policy_t(type value) : - SafeEnum(value) { } -}; - +typedef ble::advertising_filter_policy_t advertising_filter_policy_t; /** * Filter policy which can be used during a scan. diff --git a/features/FEATURE_BLE/source/generic/GenericGap.cpp b/features/FEATURE_BLE/source/generic/GenericGap.cpp index 8f066c6ab6..b0c3ab9a8e 100644 --- a/features/FEATURE_BLE/source/generic/GenericGap.cpp +++ b/features/FEATURE_BLE/source/generic/GenericGap.cpp @@ -1766,7 +1766,7 @@ ble_error_t GenericGap::setAdvertisingParams( (pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(), params.getPeerAddress(), channel_map, - (pal::advertising_filter_policy_t::type) params.getPolicyMode() + params.getPolicyMode() ); } else { return setExtendedAdvertisingParameters(handle, params); @@ -1802,7 +1802,7 @@ ble_error_t GenericGap::setExtendedAdvertisingParameters( (pal::own_address_type_t::type) params.getOwnAddressType().value(), (pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(), params.getPeerAddress(), - (pal::advertising_filter_policy_t::type) params.getPolicyMode(), + params.getPolicyMode(), params.getTxPower(), params.getPrimaryPhy(), params.getSecondaryMaxSkip(),