BLE: Merve ble::advertising_policy_mode and pal::advertising_filter_policy .

pull/8738/head
Vincent Coubard 2018-11-15 11:20:30 +00:00
parent db55540952
commit c6cdfd0b7e
4 changed files with 32 additions and 62 deletions

View File

@ -82,7 +82,7 @@ public:
_maxInterval(maxInterval), _maxInterval(maxInterval),
_peerAddressType(ble::target_peer_address_type_t::PUBLIC), _peerAddressType(ble::target_peer_address_type_t::PUBLIC),
_ownAddressType(ble::own_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), _primaryPhy(ble::phy_t::LE_1M),
_secondaryPhy(ble::phy_t::LE_1M), _secondaryPhy(ble::phy_t::LE_1M),
_peerAddress(), _peerAddress(),
@ -273,7 +273,7 @@ public:
* *
* @return A reference to this object. * @return A reference to this object.
*/ */
AdvertisingParameters &setPolicyMode(advertising_policy_mode_t mode) AdvertisingParameters &setPolicyMode(advertising_filter_policy_t mode)
{ {
_policy = mode; _policy = mode;
return *this; return *this;
@ -283,7 +283,7 @@ public:
* *
* @return Policy used. * @return Policy used.
*/ */
ble::advertising_policy_mode_t getPolicyMode() const ble::advertising_filter_policy_t getPolicyMode() const
{ {
return _policy; return _policy;
} }
@ -458,7 +458,7 @@ private:
target_peer_address_type_t _peerAddressType; target_peer_address_type_t _peerAddressType;
own_address_type_t _ownAddressType; own_address_type_t _ownAddressType;
advertising_policy_mode_t _policy; advertising_filter_policy_t _policy;
phy_t _primaryPhy; phy_t _primaryPhy;
phy_t _secondaryPhy; phy_t _secondaryPhy;
address_t _peerAddress; address_t _peerAddress;

View File

@ -250,26 +250,34 @@ typedef int8_t advertising_power_t;
* *
* @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2. * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2.
*/ */
enum advertising_policy_mode_t { struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8_t> {
enum type {
/** /**
* The whitelist is not used to filter peer request during advertising. * Process connection and scan requests from all devices. The whitelist is
* not used.
*/ */
ADV_POLICY_IGNORE_WHITELIST = 0, NO_FILTER = 0x00,
/** /**
* The whitelist is used to filter peer scan requests. * Process connection requests from all devices but filter out scan requests
* of devices which are not in the whitelist.
*/ */
ADV_POLICY_FILTER_SCAN_REQS = 1, FILTER_SCAN_REQUESTS = 0x01,
/** /**
* The whitelist is used to filter peer connection requests. * Process scan requests from all devices but filter out connection requests
* of devices which are not in the whitelist.
*/ */
ADV_POLICY_FILTER_CONN_REQS = 2, FILTER_CONNECTION_REQUEST = 0x02,
/** /**
* The whitelist is used to filter peer scan and connection requests. * Filter out scan or connection requests of devices which are not in the
* whitelist.
*/ */
ADV_POLICY_FILTER_ALL_REQS = 3, FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
};
advertising_filter_policy_t(type value) : SafeEnum(value) { }
}; };
/** /**

View File

@ -297,45 +297,7 @@ struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
SafeEnum<disconnection_reason_t, uint8_t>(value) { } SafeEnum<disconnection_reason_t, uint8_t>(value) { }
}; };
typedef ble::advertising_filter_policy_t advertising_filter_policy_t;
/**
* Filter policy which can be used during advertising.
*/
struct advertising_filter_policy_t :
SafeEnum<advertising_filter_policy_t, uint8_t> {
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<advertising_filter_policy_t, uint8_t>(value) { }
};
/** /**
* Filter policy which can be used during a scan. * Filter policy which can be used during a scan.

View File

@ -1766,7 +1766,7 @@ ble_error_t GenericGap::setAdvertisingParams(
(pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(), (pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(),
params.getPeerAddress(), params.getPeerAddress(),
channel_map, channel_map,
(pal::advertising_filter_policy_t::type) params.getPolicyMode() params.getPolicyMode()
); );
} else { } else {
return setExtendedAdvertisingParameters(handle, params); return setExtendedAdvertisingParameters(handle, params);
@ -1802,7 +1802,7 @@ ble_error_t GenericGap::setExtendedAdvertisingParameters(
(pal::own_address_type_t::type) params.getOwnAddressType().value(), (pal::own_address_type_t::type) params.getOwnAddressType().value(),
(pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(), (pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(),
params.getPeerAddress(), params.getPeerAddress(),
(pal::advertising_filter_policy_t::type) params.getPolicyMode(), params.getPolicyMode(),
params.getTxPower(), params.getTxPower(),
params.getPrimaryPhy(), params.getPrimaryPhy(),
params.getSecondaryMaxSkip(), params.getSecondaryMaxSkip(),