BLE Protocol Stack — Controller

Olivia's Pc
4 min readSep 15, 2019

--

While we usually only interface with the upper layers of BLE, it is good to have a basic overview of the BLE protocol Stack.

BLE protocol Stack is divided into three parts:

Application

  • it is responsible for the application logic, user interface, and data handling. It’s architecture is highly dependent on each particular implementation.

Host — the host is composed of several layers:

  • Generic Access Profile (GAP),
  • Generic Attribute Profile (GATT),
  • Logical Link Control and Adaptation Protocol (L2CAP),
  • Attribute Protocol (ATT),
  • Security Manager (SM), and
  • Host Controller Interface (HCI) — Host side

Controller — The controller includes the following layers:

  • Host Controller Interface (HCI) — Controller side,
  • Link Layer (LL),
  • Physical Layer (PHY)

Each of these basic building blocks is split into several layers that provide the necessary functionality for operation. This article focuses on the physical layer (PHY) and the link layer (LL).

Controller — Physical Layer (PHY)

The physical (PHY) layer handles the operation involves analog communications. Specifically, it defines the modulation and demodulation of analog signals and applies source coding to transform the signals into digital symbols.

The BLE radio uses the 2.4 GHz ISM band — it is a licensed free band. There are 40 channels — 3 for advertising channels and 37 for data channels. Each channel is 2 MHz width. The frequency allocation for each channel is shown below:

Frequency hopping spread spectrum (FHSS) is employ to allow the BLE radio hops between channels on each connection event using the following formula

The value h denotes the hop, which is disclosed to the connected device upon connection establishment. Hence, h is different for every new established connection. Since BLE uses the same ISM band as WiFi, BLE devices might experience heavy interference when there are WiFi devices with strong transmission power in its vicinity. The use of FHSS can minimize the effect of any such interference across any single channel.

Gaussian Frequency Shift Keying (GFSK) is used as the modulation technique to encode the bitstream over the air. The modulation rate is fixed at 1 Mbps.

Controller — Link Layer (LL)

Link layer (LL) directly interfaces with the physical layer (PHY), and is usually implemented as a combination of custom hardware and software.

The hardware part of LL defines a certain automated functionalities to avoid overloading the central processing unit that runs all of the software layers in the stack. These functionalities includes

  • Preamble, Access Address, and air protocol framing
  • CRC generation and verification
  • Data whitening
  • Random number generation
  • AES encryption

The software part of LL manages the link state of the radio, which defines the connection between devices. It is responsible for the processes related to connection establishment, involving the central (become master upon connection establishment) and the peripheral (become slave) devices. BLE has an inherent asymmetry in its lower layers between master and slave, in which the master is required to have more resources to act as a master. This type of architectural asymmetry allows low-cost peripherals running on cheap micro-controllers and radios, while the majority of the low-level protocol complexity occurs on devices with more resources, such as smartphones and tablets.

LL defines the following roles:

  • advertiser — a device that broadcasts advertising packets
  • scanner — a device that performs scanning to listen to incoming advertising packets
  • master — a device that initiates the connection and manages the timing upon connection establishment
  • slave — a device that accepts a connection request and follows the timing set by the master.

These roles can be logically grouped into two pairs:

  • advertiser and scanner (when the devices are not in an active connection)
  • master and slave (when the devices are in a secure connection link)

LL and PHY are kept isolated from the higher layers by means of a standard interface — Host-controller Interface (HCI). Hence, the higher layers do not have to worry about the complexity of those modulation techniques and timing setting that define the operation of BLE radio.

** more about the link layer **

Bluetooth Device Address

Bluetooth device is identified by the Bluetooth device address. This address is 48-bit (i.e., 6 bytes) long. There are two types of device addresses:

  • Public device address — this is a fixed, factory-programmed device address. It must be registered with the IEEE Registration Authority and will never get change during its entire lifetime.
  • Random device address — this address can be pre-programmed or dynamically generated during the runtime. It has many practical uses in BLE. We will discuss more about this type of address in the topic focuses on GAP.

Link Layer also responsible for defining the advertising and scanning operation. We will dedicate another article to talk more about these operations in more details.

** this topic is part of the BLE series for beginner **

--

--