Technical considerations for Bluetooth low energy application developers.
ISM band is split into 40 channels of two types:
- Advertising Channels
- Data channels
Advertising Channels are used for discovering devices, initiating connection and broadcasting data. There are three fixed Advertisement Channels operating on frequencies 2402 MHz (channel 37), 2426 MHz (channel 38) and 2480 MHz (channel 39).
Data Channels are used for communicating data after the devices get connected. There are 37 data channels that use frequencies 2404-2424 MHz (Channels 0-10), 2428-2478 MHz (Channels 11-36).
The operation of the Link Layer can be described in terms of a state machine with the following five states:
- Standby State
- Advertising State
- Scanning State
- Initiating State
- Connection State
The Link Layer state machine allows only one state to be active at a time. The Link Layer shall have at least one Link Layer state machine that supports one of Advertising State or Scanning State. The Link Layer may have multiple instances of the Link Layer state machine. Certain combinations of states and roles within multiple state machines in the Link Layer are prohibited.
Standby State—the Link Layer in the Standby State does not transmit or receive any packets. The Standby State can be entered from any other state.
Advertising State—the Link Layer in the Advertising State will be transmitting advertising channel packets and possibly listening to and responding to responses triggered by these advertising channel packets. A device in the Advertising State is known as an advertiser. The Advertising State can be entered from the Standby State.
Scanning State—the Link Layer in the Scanning State will be listening for advertising channel packets from devices that are advertising. A device in the Scanning State is known as a scanner. The Scanning State can be entered from the Standby State.
Initiating State—the Link Layer in the Initiating State will be listening for advertising channel packets from a specific device(s) and responding to these packets to initiate a connection with another device. A device in the Initiating State is known as an initiator. The Initiating State can be entered from the Standby State.
Connection State—the Connection State can be entered either from the Initiating State or the Advertising State. A device in the Connection State is known as being in a connection. Within the Connection State, two roles are defined:
- Master Role—when entered from the Initiating State, the Connection State shall be in the Master Role
- Slave Role—when entered from the Advertising State, the Connection State shall be in the Slave Role The Link Layer in the Master Role will communicate with a device in the Slave Role and defines the timings of transmissions. The Link Layer in the Slave Role will communicate with a single device in the Master Role.
The Link Layer in the Connection State shall only transmit Data Channel PDUs in connection events. The master and slave shall determine the data channel index for each connection event. The same data channel index shall be used for all packets in the connection event. Each connection event contains at least one packet sent by the master. During a connection event, the master and slave alternate sending and receiving packets. The connection event is considered open while both devices continue to send packets. The slave shall always send a packet if it receives a packet from the master.
Important Connection Parameters
The Link Layer enters the Connection State when an initiator sends a CONNECT_REQ PDU to an advertiser or an advertiser receives a CONNECT_REQ PDU from an initiator.
A connection request contains a few connection parameters:
Connection Interval—the connection interval is the amount of time between two connection events. The connInterval shall be a multiple of 1.25 ms in the range of 7.5 ms to 4.0 s. Different applications may require different connection intervals. The advantage of having a very long connection interval is that significant power is saved, since the device can sleep most of the time between connection events. The disadvantage is that if a device has data that it needs to send, it must wait until the next connection event. The advantage of having a very short connection interval is that there is more opportunity for data to be sent or received, as the two devices will connect more frequently. The disadvantage is that more power will be consumed, since the device is frequently waking up for connection events.
Slave Latency—slave latency allows a slave to use a reduced number of connection events. The connSlaveLatency parameter defines the number of consecutive connection events that the slave device is not required to listen for the master. As a result, slave device can skip a number of connection events if it does not have additional data resulting in power savings. This is a parameter that the application can set during connection establishment. ConnSlaveLatency shall be an integer in the range of 0 to ((connSupervisionTimeout/ connInterval) - 1). connSlaveLatency shall also be less than 500. When connSlaveLatency is set to zero the slave device shall listen at every anchor point. If the slave does not receive a packet from the master after applying slave latency, it should listen at each anchor point and not apply slave latency until it receives a packet from the master.
Supervision Timeout—connection supervision timeout (connSupervisionTimeout) is a parameter that defines the maximum time between two received Data Packet PDUs before the connection is considered lost. The connSupervisionTimeout shall be a multiple of 10 ms in the range of 100 ms to 32.0 s and it shall be larger than (1 + connSlaveLatency) * connInterval. A connection can break down due to various reasons such as a device moving out of range, encountering severe interference or a power failure condition. Since this may happen without any prior warning, it is important for both the master and the slave to monitor the status of the connection. Upon reception of a valid packet, the timer shall be reset.
Take the following example:
- Connection Interval: 80 (100ms)
- Slave Latency: 4
- Effective Connection Interval: (100ms) * ( 1 + 4 ) = 500ms
This tells us that in a situation in which no data is being sent from the slave to the master, the slave will only transmit during a connection event once every 500ms. In many applications, the slave will skip the maximum number of connection events. Therefore it is useful to consider the effective connection interval when selecting your connection parameters. Selecting the correct group of connection parameters plays an important role in power optimization of your Bluetooth low energy device.
The following list gives a general summary of the trade-offs in connection parameter settings:
Reducing the connection interval will:
- Increase the power consumption for both devices
- Increase the throughput in both directions
- Reduce the amount of time that it takes for data to be sent in either direction
Increasing the connection interval will:
- Reduce the power consumption for both devices
- Reduce the throughput in both directions Increase the amount of time that it takes for data to be sent in either direction
Reducing the slave latency (or setting it to zero) will:
- Increase the power consumption for the peripheral device
- Reduce the amount of time that it takes for data sent from the central device to be received by the peripheral device
Increasing the slave latency will:
- Reduce power consumption for the peripheral during periods when the peripheral has no data to send to the central device
- Increase the amount of time that it takes for data sent from the central device to be received by the peripheral device
In some cases, the central device will request a connection with a peripheral device containing connection parameters that are unfavorable to the peripheral device. In other cases, a peripheral device might have the desire to change parameters in the middle of a connection, based on the peripheral application. The peripheral device can request the central device to change the connection settings by sending a "Connection Parameter Update Request".
This request contains four parameters: minimum connection interval, maximum connection interval, slave latency, and timeout. These values represent the parameters that the peripheral device desires for the connection (the connection interval is given as a range). When the central device receives this request, it has the option of accepting or rejecting the new parameters. A connection can be voluntarily terminated by either the master or the slave for any reason. One side initiates termination, and the other side must respond accordingly before both devices exit the connected state
The set of devices that the Link Layer uses for device filtering is called the White List. It is a powerful configuration that the application developers can use to save power. The White List is configured by the Host and is used by the Link Layer to filter advertisers, scanners or initiators. This allows the Host to configure the Link Layer to act on a request without awakening the Host. All the device filter policies shall use the same White List.
- Advertising Filter Policy—the advertising filter policy determines how the advertiser's Link Layer processes scan and/or connection requests
- Scanner Filter Policy—the scanner filter policy determines how the scanner's Link Layer processes advertising packets.
- Initiator Filter Policy—the initiator filter policy determines how an initiator's Link Layer processes advertising packets.