This post looks at Bluetooth Low Energy (BLE) link layer states. There are two forms of Bluetooth wireless technology systems. They are Basic Rate(BR) and Low Energy (LE) communication. This article summaries the connection procedure and its corresponding states . Basically BLE is a star topology network in which master device manages the connection, and can be connected to multiple slaves and slave device can only be connected to one master. Based on the different states, link layer in BLE stack is classified into below sates.
- Standby State
- Advertising State
- Scanning State
- Initiating State
- Connection State
Of the above states, only one state is possible at a time.
Standby State
The STANDBY state is the default state of the BLE device. In this state, the device may be in a low-power mode. This state does not transmit or reveive any packets in this state.
Advertising State
In advertising state, device transmits advertising packets. Advertising packets can contain a data payload, and hence broadcast data without a connection. In advertising state, a BLE device can Four types of advertisements as follow.
- Connectable undirected
- Connectable directed
- Non-connectable undirected
- Discoverable undirected
Scanning State
The device in the Scanning State will be listening for advertising channel packets from devices that are advertising. Two types of scan is possible.
- Passive Scanning In passive scanning, Scanner listens for advertising packets. Upon reception of any advertisement packet, it passes the information up to the host.
- Active Scanning The main difference in active scanning is, after receiving advertising packets, it respond with “SCAN_REQUEST” packet to get SCAN_RESPONSE” packet for more information about the advertiser.
Initiating State
After a scanner device has scanned a connectable advertisement message, it can become an “initiator” by sending a “connection request” packet to the advertiser. This state is called “initiating state”. If the advertiser accepts the connection, both devices enter the next state called “connection state”. Here initiator device becomes the “master” device and the advertiser becomes the “slave” device.
Connection State
In the CONNECTION state, the connection has been established and packets can be sent back and forth. Below are few key points in connection state.
- Connection state can be entered from either Initiating State or the Advertising State.
- Within the Connection State, two roles are defined: Master Role and Slave Role.
- When entered from the Initiating State, the Connection State shall be in the Master Role.
- When entered from the Advertising State, the Connection State shall be in the Slave Role.
- The Link Layer in the Slave Role (e.g. BLE watch,) will communicate with a single device in the Master Role ( e.g. mobile phone).
- The Link Layer in the Connection State shall not operate in the Master Role and Slave Role at the same time.
- The Link Layer in the Connection State operating in the Slave Role shall have only one connection.
- The Link Layer in the Connection State operating in the Master Role may have multiple connections.
Closing Connection Events
The MD bit of the Header of the Data Channel PDU is used to indicate that the device has more data to send.
- If neither device has set the MD bit in their packets, the packet from the slave closes the connection event.
- If either or both of the devices have set the MD bit, the master may continue the connection event by sending another packet, and the slave should listen after sending its packet .
- If a packet is not received from the slave by the master, the master will close the connection event.
- If a packet is not received from the master by the slave, the slave will close the connection event.
- If two consecutive packets received with an invalid CRC match within a connection event shall close the event.
More information
BLE uses ISM band ISM 2.4 GHz band (2400 to 2483.5 MHz). This is split into 40 channels of two types. They are,
Advertising channel : 37 (2402MHz), 38 (2426 MHz) and 39 (2480 MHz)
Data channel : 0-36 (2404-2478 MHz) excluding (2426 MHz)
To know details about BLE packets, you can refer the blow link.
http://j2abro.blogspot.in/2014/06/understanding-bluetooth-advertising.html
Reference
Bluetooth Specification Version 4.1