BLE operation

In Bluetooth Low Energy mode, there are five link states that are negotiated by the host and device:  

  • Advertising: Devices that transmit the advertising packets on the advertising channels.
  • Scanning: Devices that receive advertising on the advertising channels without intention to connect. Scanning can be active or passive:  
    • Active scanning: Link layer listens for advertising PDUs. Depending on the received PDU, it may request an advertiser to send additional information.
    • Passive scanning: Link layer will only receive packets, transmission disabled.
  • Initiating: Devices that need to form a connection to another device listen for connectable advertising packets and initiate by sending a connect packet.
  • Connected: There is a relationship between master and slave in the connected state. The master is the initiator and the slave is the advertiser:
    • Central: An initiator transforms the role and title to the central device.
    • Peripheral: Advertising device becomes the peripheral device.
  • Standby:  Device in the unconnected state.

The advertising state has several functions and properties. Advertisements can be general advertisements where a device broadcasts a general invitation to some other device on the network. A directed advertisement is unique and designed to invite a specific peer to connect as fast as possible. This advertisement mode contains the address of the advertising device and the invited device.

When the receiving device recognizes the packet, it will immediately send a connect request. The directed advertisement is to get fast and immediate attention and the advertisements are sent at a rate of 3.75 ms, but only for 1.28 seconds. A non-connectable advertisement is essentially a beacon (and may not even need a receiver). We will describe beacons later. Finally, the discoverable advertisement can respond to scan request, but it will not accept connections. Shown in the following state diagram are the five link states of BLE operation.

The BLE Link States.

A BLE device that has not previously bonded with a host initiates communication by broadcasting advertisements on the three advertising channels. The host can respond with SCAN_REQ to request more information from the advertising device. The peripheral device responds with a SCAN_RSP and includes the device name or possibly services. 

The  SCAN_RSP can affect power usage on a peripheral device. If the device supports scan responses it must keep its radio active in receive mode, consuming power. This occurs even if no host device issues  a SCAN_REQ. It is advisable to disable scan responses on IoT peripherals that are under power constraints.

After scanning, the host (scanner) initiates a CONNECT_REQ, at which point the scanner and advertiser will send empty PDU packets to indicate acknowledgment. The scanner is now termed the master and the advertiser is termed the slave. The master can discover slave profiles and services through the GATT. After discovery is complete, data can be exchanged from the slave to the master and vice versa. Upon termination, the master will return to a scanning mode and the slave will return to an advertiser mode. The following figure illustrates the BLE pairing process from advertising through data transmission.

Phases of BLE advertising, connecting, GATT service query and data transmission.