17 #ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__ 18 #define MBED_EXTENDED_CONNECT_PARAMETERS_H__ 20 #include "ble/BLETypes.h" 21 #include "mbed_assert.h" 126 #if BLE_FEATURE_PHY_MANAGEMENT 130 #endif // BLE_FEATURE_PHY_MANAGEMENT 211 _ownAddressType = ownAddress;
224 #if BLE_FEATURE_WHITELIST 225 _filterPolicy = filterPolicy;
226 #endif // BLE_FEATURE_WHITELIST 241 #if BLE_FEATURE_PHY_MANAGEMENT 245 #endif // BLE_FEATURE_PHY_MANAGEMENT 258 #if BLE_FEATURE_PHY_MANAGEMENT 259 handlePhyToggle(phy,
false);
260 #endif // BLE_FEATURE_PHY_MANAGEMENT 273 #if BLE_FEATURE_PHY_MANAGEMENT 274 handlePhyToggle(phy,
true);
275 #endif // BLE_FEATURE_PHY_MANAGEMENT 288 return _ownAddressType;
298 #if BLE_FEATURE_WHITELIST 299 return _filterPolicy;
302 #endif // BLE_FEATURE_WHITELIST 312 _enabledPhy[LE_1M_INDEX] * 1
313 #
if BLE_FEATURE_PHY_MANAGEMENT
314 + _enabledPhy[LE_2M_INDEX] * 1
315 + _enabledPhy[LE_CODED_INDEX] * 1
320 #if !defined(DOXYGEN_ONLY) 324 #if BLE_FEATURE_PHY_MANAGEMENT 326 _enabledPhy[LE_1M_INDEX],
327 _enabledPhy[LE_2M_INDEX],
328 _enabledPhy[LE_CODED_INDEX]
332 return phy_set_t::PHY_SET_1M;
333 #endif // BLE_FEATURE_PHY_MANAGEMENT 339 const uint16_t *getScanIntervalArray()
const 341 return &_scanInterval[getFirstEnabledIndex()];
344 const uint16_t *getScanWindowArray()
const 346 return &_scanWindow[getFirstEnabledIndex()];
349 const uint16_t *getMinConnectionIntervalArray()
const 351 return &_minConnectionInterval[getFirstEnabledIndex()];
354 const uint16_t *getMaxConnectionIntervalArray()
const 356 return &_maxConnectionInterval[getFirstEnabledIndex()];
359 const uint16_t *getSlaveLatencyArray()
const 361 return &_slaveLatency[getFirstEnabledIndex()];
364 const uint16_t *getConnectionSupervisionTimeoutArray()
const 366 return &_connectionSupervisionTimeout[getFirstEnabledIndex()];
369 const uint16_t *getMinEventLengthArray()
const 371 return &_minEventLength[getFirstEnabledIndex()];
374 const uint16_t *getMaxEventLengthArray()
const 376 return &_maxEventLength[getFirstEnabledIndex()];
382 uint8_t getFirstEnabledIndex()
const 384 #if BLE_FEATURE_PHY_MANAGEMENT 385 if (_enabledPhy[LE_1M_INDEX]) {
387 }
else if (_enabledPhy[LE_2M_INDEX]) {
389 }
else if (_enabledPhy[LE_CODED_INDEX]) {
390 return LE_CODED_INDEX;
394 MBED_ASSERT(
"Trying to use connection parameters without any PHY defined.");
395 #endif // BLE_FEATURE_PHY_MANAGEMENT 405 uint8_t handlePhyToggle(
phy_t phy,
bool enable)
407 uint8_t index = phyToIndex(phy);
409 #if BLE_FEATURE_PHY_MANAGEMENT 410 bool was_swapped = isSwapped();
412 _enabledPhy[index] = enable;
414 bool is_swapped = isSwapped();
416 if (was_swapped != is_swapped) {
420 if (is_swapped && index == LE_CODED_INDEX) {
424 #endif // BLE_FEATURE_PHY_MANAGEMENT 429 uint8_t phyToIndex(
phy_t phy)
const 432 switch (phy.
value()) {
436 #if BLE_FEATURE_PHY_MANAGEMENT 441 index = LE_CODED_INDEX;
443 #endif // BLE_FEATURE_PHY_MANAGEMENT 452 #if BLE_FEATURE_PHY_MANAGEMENT 453 bool isSwapped()
const 456 _enabledPhy[LE_1M_INDEX] &&
457 !_enabledPhy[LE_2M_INDEX] &&
458 _enabledPhy[LE_CODED_INDEX]
463 void swapCodedAnd2M();
464 #endif // BLE_FEATURE_PHY_MANAGEMENT 470 uint16_t _scanInterval[MAX_PARAM_PHYS];
471 uint16_t _scanWindow[MAX_PARAM_PHYS];
472 uint16_t _minConnectionInterval[MAX_PARAM_PHYS];
473 uint16_t _maxConnectionInterval[MAX_PARAM_PHYS];
474 uint16_t _slaveLatency[MAX_PARAM_PHYS];
475 uint16_t _connectionSupervisionTimeout[MAX_PARAM_PHYS];
476 uint16_t _minEventLength[MAX_PARAM_PHYS];
477 uint16_t _maxEventLength[MAX_PARAM_PHYS];
479 bool _enabledPhy[MAX_PARAM_PHYS];
Duration< uint16_t, 10000, Range< 0x0A, 0x0C80 > > supervision_timeout_t
Time after which a connection is loss of devices have not exchanged data.
Duration< uint16_t, 1250, Range< 0x06, 0x0C80 > > conn_interval_t
Time interval between two connection events.
ConnectionParameters & setFilter(initiator_filter_policy_t filterPolicy)
Set if the whitelist should be used to find the peer.
static Duration max()
Return the maximum duration.
LayoutType value() const
Explicit access to the inner value of the SafeEnum instance.
ConnectionParameters & setConnectionParameters(phy_t phy, conn_interval_t minConnectionInterval, conn_interval_t maxConnectionInterval, slave_latency_t slaveLatency, supervision_timeout_t connectionSupervisionTimeout, conn_event_length_t minEventLength=conn_event_length_t::min(), conn_event_length_t maxEventLength=conn_event_length_t::max())
Set the conenction parameters of a given PHY.
ConnectionParameters & enablePhy(phy_t phy=phy_t::LE_1M)
Enable an individual PHY.
Type that describes a bluetooth PHY(sical) transport.
Parameters defining the connection initiation process.
ConnectionParameters(phy_t phy=phy_t::LE_1M, scan_interval_t scanInterval=scan_interval_t::min(), scan_window_t scanWindow=scan_window_t::min(), conn_interval_t minConnectionInterval=conn_interval_t(50), conn_interval_t maxConnectionInterval=conn_interval_t(100), slave_latency_t slaveLatency=slave_latency_t::min(), supervision_timeout_t connectionSupervisionTimeout=supervision_timeout_t(100), conn_event_length_t minEventLength=conn_event_length_t::min(), conn_event_length_t maxEventLength=conn_event_length_t::max())
Create a ConnectionParameters object.
ConnectionParameters & togglePhy(bool phy1M, bool phy2M, bool phyCoded)
Enable or disable PHYs.
static uint16_t min()
The left-bound value.
The whitelist is not used to determine which advertiser to connect to.
Type that describe a set of PHY(sical) transports.
ConnectionParameters & setOwnAddressType(own_address_type_t ownAddress)
Address type used by the local device to connect the peer.
own_address_type_t getOwnAddressType() const
Return the local address type used.
ConnectionParameters & disablePhy(phy_t phy=phy_t::LE_1M)
Disable an individual PHY.
uint8_t getNumberOfEnabledPhys() const
Return the number of PHY enabled.
static Duration min()
Return the minimum duration.
ConnectionParameters & setScanParameters(phy_t phy, scan_interval_t scanInterval, scan_window_t scanWindow)
Set the scan parameters for a given PHY.
initiator_filter_policy_t getFilter() const
Return the initiator policy.
Type used to model the own address used during the following GAP operations: advertising, scanning and initiating.
Entry namespace for all BLE API definitions.
Filter policy that you can use during connection initiation.