mirror of https://github.com/ARMmbed/mbed-os.git
BLE: merge ble::scanning_policy_mode_t and gap::scanning_filter_policy_t
This change set also introduce ble::initiator_filter_policy_t and fix a type issue ble::ConnectionParameters.pull/8738/head
parent
3b334b814d
commit
07d73d5e20
|
|
@ -548,6 +548,23 @@ public:
|
|||
ADV_POLICY_FILTER_ALL_REQS = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Scanning policy filter mode.
|
||||
*
|
||||
* @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
|
||||
*/
|
||||
enum ScanningPolicyMode_t {
|
||||
/**
|
||||
* The whitelist is not used for scanning operations.
|
||||
*/
|
||||
SCAN_POLICY_IGNORE_WHITELIST = 0,
|
||||
|
||||
/**
|
||||
* The whitelist is used to filter incoming advertising.
|
||||
*/
|
||||
SCAN_POLICY_FILTER_ALL_ADV = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Connection initiation policy filter mode.
|
||||
*
|
||||
|
|
@ -635,14 +652,6 @@ public:
|
|||
*/
|
||||
typedef ble::target_peer_address_type_t TargetPeerAddressType_t;
|
||||
|
||||
/**
|
||||
* Scanning filter policy based on the whitelist
|
||||
*/
|
||||
typedef ble::scanning_policy_mode_t ScanningPolicyMode_t;
|
||||
|
||||
static const ScanningPolicyMode_t SCAN_POLICY_IGNORE_WHITELIST = ble::SCAN_POLICY_IGNORE_WHITELIST;
|
||||
static const ScanningPolicyMode_t SCAN_POLICY_FILTER_ALL_ADV = ble::SCAN_POLICY_FILTER_ALL_ADV;
|
||||
|
||||
/**
|
||||
* Enumeration of BLE PHY
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class ConnectionParameters {
|
|||
static const uint8_t MAX_PARAM_PHYS = 3;
|
||||
public:
|
||||
ConnectionParameters() :
|
||||
_filterPolicy(ble::SCAN_POLICY_IGNORE_WHITELIST),
|
||||
_filterPolicy(initiator_filter_policy_t::NO_FILTER),
|
||||
_ownAddressType(ble::own_address_type_t::PUBLIC)
|
||||
{
|
||||
for (uint8_t i = 0; i < MAX_PARAM_PHYS; ++i) {
|
||||
|
|
@ -104,9 +104,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
ConnectionParameters &setFilterPolicy(
|
||||
ble::scanning_policy_mode_t filterPolicy
|
||||
)
|
||||
ConnectionParameters &setFilterPolicy(initiator_filter_policy_t filterPolicy)
|
||||
{
|
||||
_filterPolicy = filterPolicy;
|
||||
|
||||
|
|
@ -151,7 +149,7 @@ public:
|
|||
return _ownAddressType;
|
||||
}
|
||||
|
||||
ble::scanning_policy_mode_t getFilterPolicy() const
|
||||
initiator_filter_policy_t getFilterPolicy() const
|
||||
{
|
||||
return _filterPolicy;
|
||||
}
|
||||
|
|
@ -160,8 +158,8 @@ public:
|
|||
{
|
||||
return (
|
||||
_enabledPhy[ble::phy_t::LE_1M] * 1 +
|
||||
_enabledPhy[ble::phy_t::LE_2M] * 1 +
|
||||
_enabledPhy[ble::phy_t::LE_CODED] * 1
|
||||
_enabledPhy[ble::phy_t::LE_2M] * 1 +
|
||||
_enabledPhy[ble::phy_t::LE_CODED] * 1
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +307,7 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
ble::scanning_policy_mode_t _filterPolicy;
|
||||
initiator_filter_policy_t _filterPolicy;
|
||||
ble::own_address_type_t _ownAddressType;
|
||||
|
||||
uint16_t _scanInterval[MAX_PARAM_PHYS]; /* 0.625 ms */
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
ScanParameters() :
|
||||
own_address_type(own_address_type_t::PUBLIC),
|
||||
scanning_filter_policy(ble::SCAN_POLICY_IGNORE_WHITELIST),
|
||||
scanning_filter_policy(scanning_filter_policy_t::NO_FILTER),
|
||||
phys(ble::phy_set_t::PHY_SET_1M),
|
||||
phy_1m_configuration(
|
||||
scan_interval_t::min(), scan_window_t::min(), true
|
||||
|
|
@ -77,13 +77,13 @@ public:
|
|||
return own_address_type;
|
||||
}
|
||||
|
||||
ScanParameters& set_scanning_filter_policy(ble::scanning_policy_mode_t filter_policy)
|
||||
ScanParameters& set_scanning_filter_policy(ble::scanning_filter_policy_t filter_policy)
|
||||
{
|
||||
scanning_filter_policy = filter_policy;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ble::scanning_policy_mode_t get_scanning_filter_policy() const
|
||||
ble::scanning_filter_policy_t get_scanning_filter_policy() const
|
||||
{
|
||||
return scanning_filter_policy;
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ public:
|
|||
|
||||
private:
|
||||
own_address_type_t own_address_type;
|
||||
ble::scanning_policy_mode_t scanning_filter_policy;
|
||||
ble::scanning_filter_policy_t scanning_filter_policy;
|
||||
|
||||
ble::phy_set_t phys;
|
||||
|
||||
|
|
|
|||
|
|
@ -285,39 +285,69 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
|
|||
*
|
||||
* @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
|
||||
*/
|
||||
enum scanning_policy_mode_t {
|
||||
/**
|
||||
* The whitelist is not used for scanning operations.
|
||||
*/
|
||||
SCAN_POLICY_IGNORE_WHITELIST = 0,
|
||||
struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* Accept all advertising packets except directed advertising packet not
|
||||
* addressed to this device.
|
||||
*/
|
||||
NO_FILTER = 0x00,
|
||||
|
||||
/**
|
||||
* Accept only advertising packets from devices in the whitelist except
|
||||
* directed advertising packet not addressed to this device.
|
||||
*/
|
||||
FILTER_ADVERTISING = 0x01,
|
||||
|
||||
|
||||
/**
|
||||
* Accept all advertising packets except directed advertising packets
|
||||
* where the initiator's identity address does not address this device.
|
||||
*
|
||||
* @note Directed advertising packets where the initiator's address is a
|
||||
* resolvable private address that cannot be resolved are also accepted.
|
||||
*/
|
||||
NO_FILTER_INCLUDE_UNRESOLVABLE_DIRECTED = 2,
|
||||
|
||||
/**
|
||||
* Accept all advertising packets except:
|
||||
* - advertising packets where the advertiser's
|
||||
* identity address is not in the White List,
|
||||
* - directed advertising packets where the initiator's identity address
|
||||
* does not address this device.
|
||||
*
|
||||
* @note Directed advertising packets where the initiator's address is a
|
||||
* resolvable private address that cannot be resolved are also accepted.
|
||||
*/
|
||||
FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* The whitelist is used to filter incoming advertising.
|
||||
* Construct a new instance of scanning_filter_policy_t.
|
||||
*/
|
||||
SCAN_POLICY_FILTER_ALL_ADV = 1,
|
||||
|
||||
/**
|
||||
* Accept all advertising packets except directed advertising packets
|
||||
* where the initiator's identity address does not address this device.
|
||||
*
|
||||
* @note Directed advertising packets where the initiator's address is a
|
||||
* resolvable private address that cannot be resolved are also accepted.
|
||||
*/
|
||||
SCAN_POLICY_IGNORE_WHITELIST_INCLUDE_UNRESOLVABLE = 2,
|
||||
|
||||
/**
|
||||
* Accept all advertising packets except:
|
||||
* - advertising packets where the advertiser's
|
||||
* identity address is not in the White List,
|
||||
* - directed advertising packets where the initiator's identity address
|
||||
* does not address this device.
|
||||
*
|
||||
* @note Directed advertising packets where the initiator's address is a
|
||||
* resolvable private address that cannot be resolved are also accepted.
|
||||
*/
|
||||
SCAN_POLICY_FILTER_ALL_ADV_INCLUDE_UNRESOLVABLE = 3
|
||||
scanning_filter_policy_t(type value) : SafeEnum(value) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* Filter policy which can be used during connection initiation.
|
||||
*/
|
||||
struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* The whitelist is not used to determine which advertiser to connect to.
|
||||
*/
|
||||
NO_FILTER,
|
||||
|
||||
/**
|
||||
* Whitelist is used to determine which advertiser to connect to.
|
||||
*/
|
||||
USE_WHITE_LIST
|
||||
};
|
||||
|
||||
initiator_filter_policy_t(type value) : SafeEnum(value) { }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Scanning policy filter mode.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -299,54 +299,9 @@ struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
|
|||
|
||||
typedef ble::advertising_filter_policy_t advertising_filter_policy_t;
|
||||
|
||||
/**
|
||||
* Filter policy which can be used during a scan.
|
||||
*/
|
||||
struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* Accept all advertising packets except directed advertising packet not
|
||||
* addressed to this device.
|
||||
*/
|
||||
NO_FILTER = 0x00,
|
||||
typedef ble::scanning_filter_policy_t scanning_filter_policy_t;
|
||||
|
||||
/**
|
||||
* Accept only advertising packets from devices in the whitelist except
|
||||
* directed advertising packet not addressed to this device.
|
||||
*/
|
||||
FILTER_ADVERTISING = 0x01
|
||||
|
||||
// EXTENDED ADVERTISING FILTER POLICY (accept private resolvable direct advertising)
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a new instance of scanning_filter_policy_t.
|
||||
*/
|
||||
scanning_filter_policy_t(type value) :
|
||||
SafeEnum<scanning_filter_policy_t, uint8_t>(value) { }
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Filter policy which can be used during connection initiation.
|
||||
*/
|
||||
struct initiator_policy_t : SafeEnum<initiator_policy_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* The whitelist is not used to determine which advertiser to connect to.
|
||||
*/
|
||||
NO_FILTER,
|
||||
|
||||
/**
|
||||
* Whitelist is used to determine which advertiser to connect to.
|
||||
*/
|
||||
USE_WHITE_LIST
|
||||
};
|
||||
|
||||
initiator_policy_t(type value) :
|
||||
SafeEnum<initiator_policy_t, uint8_t>(value) { }
|
||||
};
|
||||
typedef ble::initiator_filter_policy_t initiator_policy_t;
|
||||
|
||||
/**
|
||||
* Hold advertising data.
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ ble_error_t GenericGap::connect(
|
|||
}
|
||||
|
||||
return _pal_gap.extended_create_connection(
|
||||
(ble::pal::initiator_policy_t::type)connectionParams.getFilterPolicy(),
|
||||
connectionParams.getFilterPolicy(),
|
||||
(ble::pal::own_address_type_t::type)connectionParams.getOwnAddressType().value(),
|
||||
(ble::peer_address_type_t::type)peerAddressType.value(),
|
||||
peerAddress,
|
||||
|
|
@ -2387,7 +2387,7 @@ ble_error_t GenericGap::setScanParameters(const ScanParameters ¶ms)
|
|||
|
||||
return _pal_gap.set_extended_scan_parameters(
|
||||
(pal::own_address_type_t::type) params.get_own_address_type().value(),
|
||||
(pal::scanning_filter_policy_t::type) params.get_scanning_filter_policy(),
|
||||
params.get_scanning_filter_policy(),
|
||||
params.get_scanning_phys(),
|
||||
active_scanning,
|
||||
scan_interval,
|
||||
|
|
@ -2406,7 +2406,7 @@ ble_error_t GenericGap::setScanParameters(const ScanParameters ¶ms)
|
|||
legacy_configuration.interval.value(),
|
||||
legacy_configuration.window.value(),
|
||||
(pal::own_address_type_t::type) params.get_own_address_type().value(),
|
||||
(pal::scanning_filter_policy_t::type) params.get_scanning_filter_policy()
|
||||
params.get_scanning_filter_policy()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue