19#ifndef MBED_EXTENDED_CONNECT_PARAMETERS_H__
20#define MBED_EXTENDED_CONNECT_PARAMETERS_H__
22#include "platform/mbed_assert.h"
24#include "ble/common/BLETypes.h"
129#if BLE_FEATURE_PHY_MANAGEMENT
153 scan_interval_t scanInterval = scan_interval_t::min(),
154 scan_window_t scanWindow = scan_window_t::min(),
155 conn_interval_t minConnectionInterval = conn_interval_t(50),
156 conn_interval_t maxConnectionInterval = conn_interval_t(100),
157 slave_latency_t slaveLatency = slave_latency_t::min(),
158 supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t(100),
159 conn_event_length_t minEventLength = conn_event_length_t::min(),
160 conn_event_length_t maxEventLength = conn_event_length_t::max()
179 scan_interval_t scanInterval,
180 scan_window_t scanWindow
199 conn_interval_t minConnectionInterval,
200 conn_interval_t maxConnectionInterval,
201 slave_latency_t slaveLatency,
202 supervision_timeout_t connectionSupervisionTimeout,
203 conn_event_length_t minEventLength = conn_event_length_t::min(),
204 conn_event_length_t maxEventLength = conn_event_length_t::max()
214 _ownAddressType = ownAddress;
227#if BLE_FEATURE_WHITELIST
228 _filterPolicy = filterPolicy;
244#if BLE_FEATURE_PHY_MANAGEMENT
261#if BLE_FEATURE_PHY_MANAGEMENT
262 handlePhyToggle(phy,
false);
276#if BLE_FEATURE_PHY_MANAGEMENT
277 handlePhyToggle(phy,
true);
291 return _ownAddressType;
301#if BLE_FEATURE_WHITELIST
302 return _filterPolicy;
304 return initiator_filter_policy_t::NO_FILTER;
315 _enabledPhy[LE_1M_INDEX] * 1
316#
if BLE_FEATURE_PHY_MANAGEMENT
317 + _enabledPhy[LE_2M_INDEX] * 1
318 + _enabledPhy[LE_CODED_INDEX] * 1
323#if !defined(DOXYGEN_ONLY)
327#if BLE_FEATURE_PHY_MANAGEMENT
329 _enabledPhy[LE_1M_INDEX],
330 _enabledPhy[LE_2M_INDEX],
331 _enabledPhy[LE_CODED_INDEX]
335 return phy_set_t::PHY_SET_1M;
342 const uint16_t *getScanIntervalArray()
const
344 return &_scanInterval[getFirstEnabledIndex()];
347 const uint16_t *getScanWindowArray()
const
349 return &_scanWindow[getFirstEnabledIndex()];
352 const uint16_t *getMinConnectionIntervalArray()
const
354 return &_minConnectionInterval[getFirstEnabledIndex()];
357 const uint16_t *getMaxConnectionIntervalArray()
const
359 return &_maxConnectionInterval[getFirstEnabledIndex()];
362 const uint16_t *getSlaveLatencyArray()
const
364 return &_slaveLatency[getFirstEnabledIndex()];
367 const uint16_t *getConnectionSupervisionTimeoutArray()
const
369 return &_connectionSupervisionTimeout[getFirstEnabledIndex()];
372 const uint16_t *getMinEventLengthArray()
const
374 return &_minEventLength[getFirstEnabledIndex()];
377 const uint16_t *getMaxEventLengthArray()
const
379 return &_maxEventLength[getFirstEnabledIndex()];
385 uint8_t getFirstEnabledIndex()
const
387#if BLE_FEATURE_PHY_MANAGEMENT
388 if (_enabledPhy[LE_1M_INDEX]) {
390 }
else if (_enabledPhy[LE_2M_INDEX]) {
392 }
else if (_enabledPhy[LE_CODED_INDEX]) {
393 return LE_CODED_INDEX;
397 MBED_ASSERT(
"Trying to use connection parameters without any PHY defined.");
408 uint8_t handlePhyToggle(phy_t phy,
bool enable)
410 uint8_t index = phyToIndex(phy);
412#if BLE_FEATURE_PHY_MANAGEMENT
413 bool was_swapped = isSwapped();
415 _enabledPhy[index] = enable;
417 bool is_swapped = isSwapped();
419 if (was_swapped != is_swapped) {
423 if (is_swapped && index == LE_CODED_INDEX) {
432 static uint8_t phyToIndex(phy_t phy)
435 switch (phy.value()) {
439#if BLE_FEATURE_PHY_MANAGEMENT
444 index = LE_CODED_INDEX;
455#if BLE_FEATURE_PHY_MANAGEMENT
456 bool isSwapped()
const
459 _enabledPhy[LE_1M_INDEX] &&
460 !_enabledPhy[LE_2M_INDEX] &&
461 _enabledPhy[LE_CODED_INDEX]
466 void swapCodedAnd2M();
470 initiator_filter_policy_t _filterPolicy;
471 own_address_type_t _ownAddressType;
473 uint16_t _scanInterval[MAX_PARAM_PHYS];
474 uint16_t _scanWindow[MAX_PARAM_PHYS];
475 uint16_t _minConnectionInterval[MAX_PARAM_PHYS];
476 uint16_t _maxConnectionInterval[MAX_PARAM_PHYS];
477 uint16_t _slaveLatency[MAX_PARAM_PHYS];
478 uint16_t _connectionSupervisionTimeout[MAX_PARAM_PHYS];
479 uint16_t _minEventLength[MAX_PARAM_PHYS];
480 uint16_t _maxEventLength[MAX_PARAM_PHYS];
482 bool _enabledPhy[MAX_PARAM_PHYS];
Parameters defining the connection initiation process.
ConnectionParameters & togglePhy(bool phy1M, bool phy2M, bool phyCoded)
Enable or disable PHYs.
ConnectionParameters & setScanParameters(phy_t phy, scan_interval_t scanInterval, scan_window_t scanWindow)
Set the scan parameters for a given PHY.
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 & 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.
own_address_type_t getOwnAddressType() const
Return the local address type used.
ConnectionParameters & setFilter(initiator_filter_policy_t filterPolicy)
Set if the whitelist should be used to find the peer.
initiator_filter_policy_t getFilter() const
Return the initiator policy.
ConnectionParameters & disablePhy(phy_t phy=phy_t::LE_1M)
Disable an individual PHY.
ConnectionParameters & setOwnAddressType(own_address_type_t ownAddress)
Address type used by the local device to connect the peer.
uint8_t getNumberOfEnabledPhys() const
Return the number of PHY enabled.
ConnectionParameters & enablePhy(phy_t phy=phy_t::LE_1M)
Enable an individual PHY.
Type that describe a set of PHY(sical) transports.
Entry namespace for all BLE API definitions.
Type that describes a bluetooth PHY(sical) transport.