mirror of https://github.com/ARMmbed/mbed-os.git
BLE: remove not required prefixes in ble::ConnectionParameters.
parent
c1cd5ede84
commit
7123364674
|
@ -34,7 +34,7 @@ class ConnectionParameters {
|
|||
public:
|
||||
ConnectionParameters() :
|
||||
_filterPolicy(initiator_filter_policy_t::NO_FILTER),
|
||||
_ownAddressType(ble::own_address_type_t::PUBLIC)
|
||||
_ownAddressType(own_address_type_t::PUBLIC)
|
||||
{
|
||||
for (uint8_t i = 0; i < MAX_PARAM_PHYS; ++i) {
|
||||
_scanInterval[i] = 4;
|
||||
|
@ -52,9 +52,9 @@ public:
|
|||
/* setters */
|
||||
|
||||
ConnectionParameters &setScanParameters(
|
||||
ble::scan_interval_t scanInterval,
|
||||
ble::scan_window_t scanWindow,
|
||||
ble::phy_t phy = ble::phy_t::LE_1M
|
||||
scan_interval_t scanInterval,
|
||||
scan_window_t scanWindow,
|
||||
phy_t phy = phy_t::LE_1M
|
||||
)
|
||||
{
|
||||
uint8_t phy_index = handlePhyToggle(phy, true);
|
||||
|
@ -66,15 +66,13 @@ public:
|
|||
}
|
||||
|
||||
ConnectionParameters &setConnectionParameters(
|
||||
ble::conn_interval_t minConnectionInterval,
|
||||
ble::conn_interval_t maxConnectionInterval,
|
||||
ble::slave_latency_t slaveLatency,
|
||||
ble::supervision_timeout_t connectionSupervisionTimeout,
|
||||
ble::phy_t phy = ble::phy_t::LE_1M,
|
||||
ble::conn_event_length_t minEventLength = ble::conn_event_length_t(0),
|
||||
ble::conn_event_length_t maxEventLength = ble::conn_event_length_t(
|
||||
0xFFFF
|
||||
)
|
||||
conn_interval_t minConnectionInterval,
|
||||
conn_interval_t maxConnectionInterval,
|
||||
slave_latency_t slaveLatency,
|
||||
supervision_timeout_t connectionSupervisionTimeout,
|
||||
phy_t phy = phy_t::LE_1M,
|
||||
conn_event_length_t minEventLength = conn_event_length_t(0),
|
||||
conn_event_length_t maxEventLength = conn_event_length_t(0xFFFF)
|
||||
)
|
||||
{
|
||||
uint8_t phy_index = handlePhyToggle(phy, true);
|
||||
|
@ -95,9 +93,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
ConnectionParameters &setOwnAddressType(
|
||||
ble::own_address_type_t ownAddress
|
||||
)
|
||||
ConnectionParameters &setOwnAddressType(own_address_type_t ownAddress)
|
||||
{
|
||||
_ownAddressType = ownAddress;
|
||||
|
||||
|
@ -111,31 +107,23 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
ConnectionParameters &togglePhy(
|
||||
bool phy1M,
|
||||
bool phy2M,
|
||||
bool phyCoded
|
||||
)
|
||||
ConnectionParameters &togglePhy(bool phy1M, bool phy2M, bool phyCoded)
|
||||
{
|
||||
handlePhyToggle(ble::phy_t::LE_1M, phy1M);
|
||||
handlePhyToggle(ble::phy_t::LE_2M, phy2M);
|
||||
handlePhyToggle(ble::phy_t::LE_CODED, phyCoded);
|
||||
handlePhyToggle(phy_t::LE_1M, phy1M);
|
||||
handlePhyToggle(phy_t::LE_2M, phy2M);
|
||||
handlePhyToggle(phy_t::LE_CODED, phyCoded);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConnectionParameters &disablePhy(
|
||||
ble::phy_t phy = ble::phy_t::LE_1M
|
||||
)
|
||||
ConnectionParameters &disablePhy(phy_t phy = phy_t::LE_1M)
|
||||
{
|
||||
handlePhyToggle(phy, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConnectionParameters &enablePhy(
|
||||
ble::phy_t phy = ble::phy_t::LE_1M
|
||||
)
|
||||
ConnectionParameters &enablePhy(phy_t phy = phy_t::LE_1M)
|
||||
{
|
||||
handlePhyToggle(phy, true);
|
||||
|
||||
|
@ -144,7 +132,7 @@ public:
|
|||
|
||||
/* getters */
|
||||
|
||||
ble::own_address_type_t getOwnAddressType() const
|
||||
own_address_type_t getOwnAddressType() const
|
||||
{
|
||||
return _ownAddressType;
|
||||
}
|
||||
|
@ -157,18 +145,18 @@ public:
|
|||
uint8_t getNumberOfEnabledPhys() const
|
||||
{
|
||||
return (
|
||||
_enabledPhy[ble::phy_t::LE_1M] * 1 +
|
||||
_enabledPhy[ble::phy_t::LE_2M] * 1 +
|
||||
_enabledPhy[ble::phy_t::LE_CODED] * 1
|
||||
_enabledPhy[phy_t::LE_1M] * 1 +
|
||||
_enabledPhy[phy_t::LE_2M] * 1 +
|
||||
_enabledPhy[phy_t::LE_CODED] * 1
|
||||
);
|
||||
}
|
||||
|
||||
uint8_t getPhySet() const
|
||||
{
|
||||
ble::phy_set_t set(
|
||||
_enabledPhy[ble::phy_t::LE_1M],
|
||||
_enabledPhy[ble::phy_t::LE_2M],
|
||||
_enabledPhy[ble::phy_t::LE_CODED]
|
||||
phy_set_t set(
|
||||
_enabledPhy[phy_t::LE_1M],
|
||||
_enabledPhy[phy_t::LE_2M],
|
||||
_enabledPhy[phy_t::LE_CODED]
|
||||
);
|
||||
return set.value();
|
||||
}
|
||||
|
@ -218,17 +206,16 @@ public:
|
|||
private:
|
||||
uint8_t getFirstEnabledIndex() const
|
||||
{
|
||||
if (_enabledPhy[ble::phy_t::LE_1M]) {
|
||||
if (_enabledPhy[phy_t::LE_1M]) {
|
||||
return 0;
|
||||
} else if (_enabledPhy[ble::phy_t::LE_2M]) {
|
||||
} else if (_enabledPhy[phy_t::LE_2M]) {
|
||||
return 1;
|
||||
} else if (_enabledPhy[ble::phy_t::LE_CODED]) {
|
||||
} else if (_enabledPhy[phy_t::LE_CODED]) {
|
||||
return 2;
|
||||
}
|
||||
/* this should never happen, it means you were trying to start a connection with a blank set
|
||||
* of paramters - you need to enabled at least one phy */
|
||||
MBED_ASSERT(
|
||||
"Trying to use connection parameters without any PHY defined.");
|
||||
MBED_ASSERT("Trying to use connection parameters without any PHY defined.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -238,7 +225,7 @@ private:
|
|||
* @param enable On or Off.
|
||||
* @return The index to the array of settings.
|
||||
*/
|
||||
uint8_t handlePhyToggle(ble::phy_t phy, bool enable)
|
||||
uint8_t handlePhyToggle(phy_t phy, bool enable)
|
||||
{
|
||||
uint8_t index = phy.value();
|
||||
|
||||
|
@ -259,7 +246,7 @@ private:
|
|||
swapCodedAnd2M();
|
||||
}
|
||||
|
||||
if (is_swapped && phy == ble::phy_t::LE_CODED) {
|
||||
if (is_swapped && phy == phy_t::LE_CODED) {
|
||||
index -= 1;
|
||||
}
|
||||
|
||||
|
@ -269,46 +256,46 @@ private:
|
|||
bool isSwapped() const
|
||||
{
|
||||
return (
|
||||
_enabledPhy[ble::phy_t::LE_1M] &&
|
||||
!_enabledPhy[ble::phy_t::LE_2M] &&
|
||||
_enabledPhy[ble::phy_t::LE_CODED]
|
||||
_enabledPhy[phy_t::LE_1M] &&
|
||||
!_enabledPhy[phy_t::LE_2M] &&
|
||||
_enabledPhy[phy_t::LE_CODED]
|
||||
);
|
||||
}
|
||||
|
||||
/** Handle the swapping of 2M and CODED so that the array is ready for the pal call. */
|
||||
void swapCodedAnd2M()
|
||||
{
|
||||
uint16_t scanInterval = _scanInterval[ble::phy_t::LE_2M];
|
||||
uint16_t scanWindow = _scanWindow[ble::phy_t::LE_2M];
|
||||
uint16_t minConnectionInterval = _minConnectionInterval[ble::phy_t::LE_2M];
|
||||
uint16_t maxConnectionInterval = _maxConnectionInterval[ble::phy_t::LE_2M];
|
||||
uint16_t slaveLatency = _maxConnectionInterval[ble::phy_t::LE_2M];
|
||||
uint16_t connectionSupervisionTimeout = _connectionSupervisionTimeout[ble::phy_t::LE_2M];
|
||||
uint16_t minEventLength = _minEventLength[ble::phy_t::LE_2M];
|
||||
uint16_t maxEventLength = _maxEventLength[ble::phy_t::LE_2M];
|
||||
uint16_t scanInterval = _scanInterval[phy_t::LE_2M];
|
||||
uint16_t scanWindow = _scanWindow[phy_t::LE_2M];
|
||||
uint16_t minConnectionInterval = _minConnectionInterval[phy_t::LE_2M];
|
||||
uint16_t maxConnectionInterval = _maxConnectionInterval[phy_t::LE_2M];
|
||||
uint16_t slaveLatency = _maxConnectionInterval[phy_t::LE_2M];
|
||||
uint16_t connectionSupervisionTimeout = _connectionSupervisionTimeout[phy_t::LE_2M];
|
||||
uint16_t minEventLength = _minEventLength[phy_t::LE_2M];
|
||||
uint16_t maxEventLength = _maxEventLength[phy_t::LE_2M];
|
||||
|
||||
_scanInterval[ble::phy_t::LE_2M] = _scanInterval[ble::phy_t::LE_CODED];
|
||||
_scanWindow[ble::phy_t::LE_2M] = _scanWindow[ble::phy_t::LE_CODED];
|
||||
_minConnectionInterval[ble::phy_t::LE_2M] = _minConnectionInterval[ble::phy_t::LE_CODED];
|
||||
_maxConnectionInterval[ble::phy_t::LE_2M] = _maxConnectionInterval[ble::phy_t::LE_CODED];
|
||||
_slaveLatency[ble::phy_t::LE_2M] = _slaveLatency[ble::phy_t::LE_CODED];
|
||||
_connectionSupervisionTimeout[ble::phy_t::LE_2M] = _connectionSupervisionTimeout[ble::phy_t::LE_CODED];
|
||||
_minEventLength[ble::phy_t::LE_2M] = _minEventLength[ble::phy_t::LE_CODED];
|
||||
_maxEventLength[ble::phy_t::LE_2M] = _maxEventLength[ble::phy_t::LE_CODED];
|
||||
_scanInterval[phy_t::LE_2M] = _scanInterval[phy_t::LE_CODED];
|
||||
_scanWindow[phy_t::LE_2M] = _scanWindow[phy_t::LE_CODED];
|
||||
_minConnectionInterval[phy_t::LE_2M] = _minConnectionInterval[phy_t::LE_CODED];
|
||||
_maxConnectionInterval[phy_t::LE_2M] = _maxConnectionInterval[phy_t::LE_CODED];
|
||||
_slaveLatency[phy_t::LE_2M] = _slaveLatency[phy_t::LE_CODED];
|
||||
_connectionSupervisionTimeout[phy_t::LE_2M] = _connectionSupervisionTimeout[phy_t::LE_CODED];
|
||||
_minEventLength[phy_t::LE_2M] = _minEventLength[phy_t::LE_CODED];
|
||||
_maxEventLength[phy_t::LE_2M] = _maxEventLength[phy_t::LE_CODED];
|
||||
|
||||
_scanInterval[ble::phy_t::LE_CODED] = scanInterval;
|
||||
_scanWindow[ble::phy_t::LE_CODED] = scanWindow;
|
||||
_minConnectionInterval[ble::phy_t::LE_CODED] = minConnectionInterval;
|
||||
_maxConnectionInterval[ble::phy_t::LE_CODED] = maxConnectionInterval;
|
||||
_slaveLatency[ble::phy_t::LE_CODED] = slaveLatency;
|
||||
_connectionSupervisionTimeout[ble::phy_t::LE_CODED] = connectionSupervisionTimeout;
|
||||
_minEventLength[ble::phy_t::LE_CODED] = minEventLength;
|
||||
_maxEventLength[ble::phy_t::LE_CODED] = maxEventLength;
|
||||
_scanInterval[phy_t::LE_CODED] = scanInterval;
|
||||
_scanWindow[phy_t::LE_CODED] = scanWindow;
|
||||
_minConnectionInterval[phy_t::LE_CODED] = minConnectionInterval;
|
||||
_maxConnectionInterval[phy_t::LE_CODED] = maxConnectionInterval;
|
||||
_slaveLatency[phy_t::LE_CODED] = slaveLatency;
|
||||
_connectionSupervisionTimeout[phy_t::LE_CODED] = connectionSupervisionTimeout;
|
||||
_minEventLength[phy_t::LE_CODED] = minEventLength;
|
||||
_maxEventLength[phy_t::LE_CODED] = maxEventLength;
|
||||
}
|
||||
|
||||
private:
|
||||
initiator_filter_policy_t _filterPolicy;
|
||||
ble::own_address_type_t _ownAddressType;
|
||||
own_address_type_t _ownAddressType;
|
||||
|
||||
uint16_t _scanInterval[MAX_PARAM_PHYS]; /* 0.625 ms */
|
||||
uint16_t _scanWindow[MAX_PARAM_PHYS]; /* 0.625 ms */
|
||||
|
|
Loading…
Reference in New Issue