Parameters defining the connection initiation process. More...
#include <ConnectionParameters.h>
Public Member Functions | |
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. More... | |
ConnectionParameters & | setScanParameters (phy_t phy, scan_interval_t scanInterval, scan_window_t scanWindow) |
Set the scan parameters for a given PHY. More... | |
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. More... | |
ConnectionParameters & | setOwnAddressType (own_address_type_t ownAddress) |
Address type used by the local device to connect the peer. More... | |
ConnectionParameters & | setFilter (initiator_filter_policy_t filterPolicy) |
Set if the whitelist should be used to find the peer. More... | |
ConnectionParameters & | togglePhy (bool phy1M, bool phy2M, bool phyCoded) |
Enable or disable PHYs. More... | |
ConnectionParameters & | disablePhy (phy_t phy=phy_t::LE_1M) |
Disable an individual PHY. More... | |
ConnectionParameters & | enablePhy (phy_t phy=phy_t::LE_1M) |
Enable an individual PHY. More... | |
own_address_type_t | getOwnAddressType () const |
Return the local address type used. More... | |
initiator_filter_policy_t | getFilter () const |
Return the initiator policy. More... | |
uint8_t | getNumberOfEnabledPhys () const |
Return the number of PHY enabled. More... | |
Parameters defining the connection initiation process.
The connection initiation process is divided in two different phases. First, the initiating device scans for the peer to which it should connect. Once it finds the peer, it sends a connection request that contains the connection parameters.
The scan parameters are defined by two durations: the scan interval and the scan window. The scan interval is the duration between two scan cycles, and the scan window defines how long the device searches during a scan cycle.
You can set the scan window and the scan interval at construction time or by calling setScanParameters().
A Bluetooth connection is defined by three parameters:
You can set these parameters at construction time or by calling the function setConnectionParameters().
Bluetooth 5 has introduced the support of different physical layer to either increase the range or the throughput. You can configure multiple PHY independently for scanning and connecting.
Legacy connection happens on the 1M PHY (phy_t::LE_1M). It is the only PHY that you can configure on legacy systems.
The constructor, setScanParameters() and setConnectionParameters() accept a phy_t parameter that defines to which PHY the parameters set applies.
It is possible to define what type of address is used to establish the connection and whether the whitelist should be used to find the peer to connect to.
Thanks to the fluent API, you can compose the connection parameters at instantiation point:
Definition at line 124 of file ConnectionParameters.h.
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.
phy | The PHY being configured. |
scanInterval | Interval between two scans. |
scanWindow | Scan duration during a scan interval. |
minConnectionInterval | Minimum value of the connection interval. |
maxConnectionInterval | Maximum value of the connection interval. |
slaveLatency | Maximum number of packets the slave can drop. |
connectionSupervisionTimeout | Time after which the connection is considered lost if no data has been exchanged. |
minEventLength | Minimum duration of a connection event. |
maxEventLength | Maximum duration of a connection event. |
ConnectionParameters& disablePhy | ( | phy_t | phy = phy_t::LE_1M | ) |
Disable an individual PHY.
phy | The PHY to disable. |
Definition at line 259 of file ConnectionParameters.h.
ConnectionParameters& enablePhy | ( | phy_t | phy = phy_t::LE_1M | ) |
Enable an individual PHY.
phy | The PHY to enable. |
Definition at line 274 of file ConnectionParameters.h.
initiator_filter_policy_t getFilter | ( | ) | const |
Return the initiator policy.
Definition at line 299 of file ConnectionParameters.h.
uint8_t getNumberOfEnabledPhys | ( | ) | const |
Return the number of PHY enabled.
Definition at line 312 of file ConnectionParameters.h.
own_address_type_t getOwnAddressType | ( | ) | const |
Return the local address type used.
Definition at line 289 of file ConnectionParameters.h.
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.
phy | The PHY being configured. |
minConnectionInterval | Minimum connection interval. |
maxConnectionInterval | Maximum connection interval. |
slaveLatency | Maximum number of packets the slave can drop. |
connectionSupervisionTimeout | Time after which the connection is considered lost if no data has been exchanged. |
minEventLength | Minimum duration of a connection event. |
maxEventLength | Maximum duration of a connection event. |
ConnectionParameters& setFilter | ( | initiator_filter_policy_t | filterPolicy | ) |
Set if the whitelist should be used to find the peer.
filterPolicy | The initiator filter to apply. |
Definition at line 225 of file ConnectionParameters.h.
ConnectionParameters& setOwnAddressType | ( | own_address_type_t | ownAddress | ) |
Address type used by the local device to connect the peer.
ownAddress | Type of address used to initiate the connection. |
Definition at line 212 of file ConnectionParameters.h.
ConnectionParameters& setScanParameters | ( | phy_t | phy, |
scan_interval_t | scanInterval, | ||
scan_window_t | scanWindow | ||
) |
Set the scan parameters for a given PHY.
phy | PHY being configured. |
scanInterval | Interval between two scans. |
scanWindow | Scan duration within a scan interval. |
ConnectionParameters& togglePhy | ( | bool | phy1M, |
bool | phy2M, | ||
bool | phyCoded | ||
) |
Enable or disable PHYs.
phy1M | true to enable the 1M PHY and false to disable it. |
phy2M | true to enable the 2M PHY and false to disable it. |
phyCoded | true to enable the CODED PHY and false to disable it. |
Definition at line 242 of file ConnectionParameters.h.