mirror of https://github.com/ARMmbed/mbed-os.git
BLE - remove conditional directive from value types
parent
ba9aa6b641
commit
06b26d4e8a
|
|
@ -528,7 +528,6 @@ struct att_security_requirement_t : SafeEnum<att_security_requirement_t, uint8_t
|
||||||
*/
|
*/
|
||||||
NONE,
|
NONE,
|
||||||
|
|
||||||
#if BLE_FEATURE_SECURITY
|
|
||||||
/**
|
/**
|
||||||
* The operation requires security and there's no requirement towards
|
* The operation requires security and there's no requirement towards
|
||||||
* peer authentication.
|
* peer authentication.
|
||||||
|
|
@ -554,7 +553,6 @@ struct att_security_requirement_t : SafeEnum<att_security_requirement_t, uint8_t
|
||||||
*/
|
*/
|
||||||
AUTHENTICATED,
|
AUTHENTICATED,
|
||||||
|
|
||||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
|
||||||
/**
|
/**
|
||||||
* The operation require encryption with an authenticated peer that
|
* The operation require encryption with an authenticated peer that
|
||||||
* paired using secure connection pairing.
|
* paired using secure connection pairing.
|
||||||
|
|
@ -563,8 +561,6 @@ struct att_security_requirement_t : SafeEnum<att_security_requirement_t, uint8_t
|
||||||
* security is achieved with link encryption.
|
* security is achieved with link encryption.
|
||||||
*/
|
*/
|
||||||
SC_AUTHENTICATED
|
SC_AUTHENTICATED
|
||||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
|
||||||
#endif // BLE_FEATURE_SECURITY
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -641,7 +637,7 @@ struct phy_t : SafeEnum<phy_t, uint8_t> {
|
||||||
* @note This physical transport was available since Bluetooth 4.0
|
* @note This physical transport was available since Bluetooth 4.0
|
||||||
*/
|
*/
|
||||||
LE_1M = 1,
|
LE_1M = 1,
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/**
|
/**
|
||||||
* 2Mbit/s LE.
|
* 2Mbit/s LE.
|
||||||
*
|
*
|
||||||
|
|
@ -675,7 +671,6 @@ struct phy_t : SafeEnum<phy_t, uint8_t> {
|
||||||
* @note This transport has been introduced with the Bluetooth 5.
|
* @note This transport has been introduced with the Bluetooth 5.
|
||||||
*/
|
*/
|
||||||
LE_CODED
|
LE_CODED
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -722,10 +717,8 @@ public:
|
||||||
_value()
|
_value()
|
||||||
{
|
{
|
||||||
set_1m(phy_1m);
|
set_1m(phy_1m);
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
set_2m(phy_2m);
|
set_2m(phy_2m);
|
||||||
set_coded(phy_coded);
|
set_coded(phy_coded);
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -739,14 +732,12 @@ public:
|
||||||
case phy_t::LE_1M:
|
case phy_t::LE_1M:
|
||||||
set_1m(true);
|
set_1m(true);
|
||||||
break;
|
break;
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
case phy_t::LE_2M:
|
case phy_t::LE_2M:
|
||||||
set_2m(true);
|
set_2m(true);
|
||||||
break;
|
break;
|
||||||
case phy_t::LE_CODED:
|
case phy_t::LE_CODED:
|
||||||
set_coded(true);
|
set_coded(true);
|
||||||
break;
|
break;
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -761,7 +752,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/** Prefer 2M PHY. */
|
/** Prefer 2M PHY. */
|
||||||
void set_2m(bool enabled = true) {
|
void set_2m(bool enabled = true) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
@ -779,7 +769,6 @@ public:
|
||||||
_value &= ~PHY_SET_CODED;
|
_value &= ~PHY_SET_CODED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
|
|
||||||
bool get_1m() const {
|
bool get_1m() const {
|
||||||
return (_value & PHY_SET_1M);
|
return (_value & PHY_SET_1M);
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,6 @@ public:
|
||||||
return _peerAddressType;
|
return _peerAddressType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/** Set the filter policy of whitelist use during advertising;
|
/** Set the filter policy of whitelist use during advertising;
|
||||||
*
|
*
|
||||||
* @param mode Policy to use.
|
* @param mode Policy to use.
|
||||||
|
|
@ -404,7 +403,6 @@ public:
|
||||||
_policy = mode;
|
_policy = mode;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
|
|
||||||
/** Get the filter policy of whitelist use during advertising;
|
/** Get the filter policy of whitelist use during advertising;
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -121,9 +121,9 @@ namespace ble {
|
||||||
class ConnectionParameters {
|
class ConnectionParameters {
|
||||||
enum {
|
enum {
|
||||||
LE_1M_INDEX = 0,
|
LE_1M_INDEX = 0,
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
LE_2M_INDEX = 1,
|
LE_2M_INDEX = 1,
|
||||||
LE_CODED_INDEX = 2,
|
LE_CODED_INDEX = 2,
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
MAX_PARAM_PHYS = 3
|
MAX_PARAM_PHYS = 3
|
||||||
#else
|
#else
|
||||||
MAX_PARAM_PHYS = 1
|
MAX_PARAM_PHYS = 1
|
||||||
|
|
@ -212,7 +212,6 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable PHYs.
|
* Enable or disable PHYs.
|
||||||
*
|
*
|
||||||
|
|
@ -224,9 +223,11 @@ public:
|
||||||
*/
|
*/
|
||||||
ConnectionParameters &togglePhy(bool phy1M, bool phy2M, bool phyCoded)
|
ConnectionParameters &togglePhy(bool phy1M, bool phy2M, bool phyCoded)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
handlePhyToggle(phy_t::LE_1M, phy1M);
|
handlePhyToggle(phy_t::LE_1M, phy1M);
|
||||||
handlePhyToggle(phy_t::LE_2M, phy2M);
|
handlePhyToggle(phy_t::LE_2M, phy2M);
|
||||||
handlePhyToggle(phy_t::LE_CODED, phyCoded);
|
handlePhyToggle(phy_t::LE_CODED, phyCoded);
|
||||||
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +240,9 @@ public:
|
||||||
*/
|
*/
|
||||||
ConnectionParameters &disablePhy(phy_t phy = phy_t::LE_1M)
|
ConnectionParameters &disablePhy(phy_t phy = phy_t::LE_1M)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
handlePhyToggle(phy, false);
|
handlePhyToggle(phy, false);
|
||||||
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,11 +255,12 @@ public:
|
||||||
*/
|
*/
|
||||||
ConnectionParameters &enablePhy(phy_t phy = phy_t::LE_1M)
|
ConnectionParameters &enablePhy(phy_t phy = phy_t::LE_1M)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
handlePhyToggle(phy, true);
|
handlePhyToggle(phy, true);
|
||||||
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/* getters */
|
/* getters */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -284,7 +288,6 @@ public:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* Set if the whitelist should be used to find the peer.
|
* Set if the whitelist should be used to find the peer.
|
||||||
*
|
*
|
||||||
|
|
@ -294,11 +297,12 @@ public:
|
||||||
*/
|
*/
|
||||||
ConnectionParameters &setFilter(initiator_filter_policy_t filterPolicy)
|
ConnectionParameters &setFilter(initiator_filter_policy_t filterPolicy)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_WHITELIST
|
||||||
_filterPolicy = filterPolicy;
|
_filterPolicy = filterPolicy;
|
||||||
|
#endif // BLE_FEATURE_WHITELIST
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* Return the initiator policy.
|
* Return the initiator policy.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,6 @@ public:
|
||||||
return own_address_type;
|
return own_address_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* Set the filter to apply during scanning.
|
* Set the filter to apply during scanning.
|
||||||
* @param filter_policy The filter to apply during scanning.
|
* @param filter_policy The filter to apply during scanning.
|
||||||
|
|
@ -171,7 +170,6 @@ public:
|
||||||
scanning_filter_policy = filter_policy;
|
scanning_filter_policy = filter_policy;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filter to use during scanning
|
* Get the filter to use during scanning
|
||||||
|
|
@ -185,7 +183,6 @@ public:
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
#endif // BLE_FEATURE_WHITELIST
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable PHYs that should be used during scanning.
|
* Enable or disable PHYs that should be used during scanning.
|
||||||
* @param enable_1m True to enable the 1M phy and false to disable it.
|
* @param enable_1m True to enable the 1M phy and false to disable it.
|
||||||
|
|
@ -194,11 +191,12 @@ public:
|
||||||
*/
|
*/
|
||||||
ScanParameters &setPhys(bool enable_1m, bool enable_coded)
|
ScanParameters &setPhys(bool enable_1m, bool enable_coded)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
phys.set_1m(enable_1m);
|
phys.set_1m(enable_1m);
|
||||||
phys.set_coded(enable_coded);
|
phys.set_coded(enable_coded);
|
||||||
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PHYs to use during scanning.
|
* Get the PHYs to use during scanning.
|
||||||
|
|
@ -236,7 +234,6 @@ public:
|
||||||
return phy_1m_configuration;
|
return phy_1m_configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
/**
|
/**
|
||||||
* Set the coded PHY scan configuration.
|
* Set the coded PHY scan configuration.
|
||||||
* @param interval The scan interval to use.
|
* @param interval The scan interval to use.
|
||||||
|
|
@ -250,13 +247,14 @@ public:
|
||||||
bool active_scanning
|
bool active_scanning
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||||
phys.set_coded(true);
|
phys.set_coded(true);
|
||||||
phy_coded_configuration = phy_configuration_t(
|
phy_coded_configuration = phy_configuration_t(
|
||||||
interval, window, active_scanning
|
interval, window, active_scanning
|
||||||
);
|
);
|
||||||
|
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the coded PHY scan configuration.
|
* Get the coded PHY scan configuration.
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
|
||||||
* not used.
|
* not used.
|
||||||
*/
|
*/
|
||||||
NO_FILTER = 0x00,
|
NO_FILTER = 0x00,
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* Process connection requests from all devices but filter out scan requests
|
* Process connection requests from all devices but filter out scan requests
|
||||||
* of devices that are not in the whitelist.
|
* of devices that are not in the whitelist.
|
||||||
|
|
@ -407,7 +407,6 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
|
||||||
* whitelist.
|
* whitelist.
|
||||||
*/
|
*/
|
||||||
FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
|
FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -432,7 +431,7 @@ struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
|
||||||
* addressed to this device.
|
* addressed to this device.
|
||||||
*/
|
*/
|
||||||
NO_FILTER = 0x00,
|
NO_FILTER = 0x00,
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* Accept only advertising packets from devices in the whitelist except
|
* Accept only advertising packets from devices in the whitelist except
|
||||||
* directed advertising packets not addressed to this device.
|
* directed advertising packets not addressed to this device.
|
||||||
|
|
@ -459,7 +458,6 @@ struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
|
||||||
* resolvable private address that cannot be resolved are also accepted.
|
* resolvable private address that cannot be resolved are also accepted.
|
||||||
*/
|
*/
|
||||||
FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
|
FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -482,12 +480,11 @@ struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t>
|
||||||
* The whitelist is not used to determine which advertiser to connect to.
|
* The whitelist is not used to determine which advertiser to connect to.
|
||||||
*/
|
*/
|
||||||
NO_FILTER,
|
NO_FILTER,
|
||||||
#if BLE_FEATURE_WHITELIST
|
|
||||||
/**
|
/**
|
||||||
* The whitelist is used to determine which advertiser to connect to.
|
* The whitelist is used to determine which advertiser to connect to.
|
||||||
*/
|
*/
|
||||||
USE_WHITE_LIST
|
USE_WHITE_LIST
|
||||||
#endif // BLE_FEATURE_WHITELIST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BLERoles.h"
|
|
||||||
|
|
||||||
#if BLE_ROLE_OBSERVER
|
|
||||||
|
|
||||||
#include "ble/Gap.h"
|
#include "ble/Gap.h"
|
||||||
#include "ble/GapScanningParams.h"
|
#include "ble/GapScanningParams.h"
|
||||||
|
|
||||||
|
|
@ -77,5 +73,3 @@ GapScanningParams::setActiveScanning(bool activeScanning)
|
||||||
{
|
{
|
||||||
_activeScanning = activeScanning;
|
_activeScanning = activeScanning;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue