The Bluetooth protocol architecture adopts a layered structure, covering multiple protocol components from the physical communication at the bottom layer to the application data transmission at the top layer. The Bluetooth protocol stack is suitable for Classic Bluetooth (BR/EDR) and Bluetooth Low Energy (BLE), which have similar basic architectures, but BLE is optimized for low power consumption, making it suitable for IoT devices, smart homes, wearables, and more. |
1. Bluetooth Protocol Architecture (Bluetooth Protocol Stack)
The Bluetooth protocol is divided into the following five layers (from bottom to top):
1. Physical Layer (PHY – Physical Layer)
•Responsible for radio wave transmission, using the 2.4 GHz ISM band (Industrial, Scientific, and Medical use).
•Modulation methods:
○Classic Bluetooth (BR/EDR): GFSK (1 Mbps) + π/4 DQPSK, 8DPSK (up to 3 Mbps).
○Bluetooth Low Energy (BLE): GFSK (1 Mbps / 2 Mbps, BLE 5.0 supports long-range mode Coded PHY).
•Channel division:
○BR/EDR: 79 channels (1 MHz spacing).
○BLE: 40 channels (2 MHz spacing, of which 3 are for advertising).
2. Link Layer (LL – Link Layer)
•Responsible for device discovery, connection establishment, and maintenance, controlling the transmission of data packets.
•Main communication modes of BLE:
○Advertising: The peripheral device sends advertising packets, and the central device can listen and connect.
○Scanning: The central device listens to advertising packets to determine whether to connect.
○Connection: The central device establishes a connection with the peripheral device to start data exchange.
○Data transmission: Uses master-slave mode, with data transmitted according to the connection interval.
•BLE low power features:
○Devices can enter sleep mode to reduce power consumption.
○BLE 5.0 and above support extended advertising and periodic advertising, improving throughput and stability.
3. Logical Link Control and Adaptation Protocol (L2CAP – Logical Link Control and Adaptation Protocol)
•Responsible for data multiplexing, fragmentation, and reassembly, transmitting data from high-level protocols to the lower link layer.
•Functions:
○Protocol multiplexing (allows multiple protocols to share the Bluetooth link).
○Data fragmentation (if the data packet is larger than MTU, it will split the data).
○Channel management (controls data flow between hosts).
•Optimizations in BLE:
○Only supports LE channels (fixed channel IDs).
○Credit-based flow control mode, improving throughput.
4. Higher Layer Protocols
Higher layer protocols include GAP, GATT, ATT, SM, RFCOMM, SDP, among which BLE mainly uses GAP, GATT, ATT, SM.
4.1 Generic Access Profile (GAP – Generic Access Profile)
•Defines device roles, connection modes, and discovery methods.
•BLE device roles:
○Central device: Responsible for scanning and connecting BLE peripheral devices (e.g., smart locks, sensors).
○Peripheral device: Sends advertising packets and waits for connections (e.g., BLE sensors).
○Broadcaster: Only sends advertising data and does not accept connections (e.g., BLE beacons).
○Observer: Only scans advertising data and does not actively connect (e.g., BLE monitoring devices).
•Main functions of GAP:
○Device discovery (Scanning & Advertising).
○Connection establishment and termination.
○Device pairing and encryption (Security).
4.2 Generic Attribute Profile (GATT – Generic Attribute Profile)
•The core data interaction protocol of BLE, based on ATT (Attribute Protocol) for data transmission.
•Uses a client-server architecture:
○Server: Stores data, such as the status information of a smart lock.
○Client: Reads or writes data, such as a mobile app reading the status of a smart lock.
•GATT structure:
○Service: Contains multiple characteristics (e.g., “Battery Service”).
○Characteristic: Specific data items (e.g., “Battery Level”).
○Attribute: Stores UUID, permissions, and other information.
○Main operations:
▪Read: Client requests to read server data.
▪Write: Client sends data to the server.
▪Notify: Server actively pushes data without client confirmation.
▪Indicate: Similar to Notify, but requires client confirmation.
4.3 Attribute Protocol (ATT – Attribute Protocol)
•Defines the GATT data structure, specifying how data is stored and accessed.
•Each BLE device’s GATT server consists of multiple ATTs:
○Each ATT is identified by a UUID (Unique Identifier)..
○Allows data to be read, written, notified, and indicated..
4.4 Security Manager (SM – Security Manager)
•Responsible for device pairing, encryption, and key exchange, ensuring data security.
•Main security mechanisms:
○Device pairing:
▪Just Works (no authentication, vulnerable).
▪Passkey (enter a 6-digit PIN code).
▪Out of Band (OOB, using NFC to exchange keys).
▪LE Secure Connections (Bluetooth 4.2+, using AES-CCM encryption).
○Data encryption:
▪Uses AES-CCM to encrypt transmitted data, preventing eavesdropping.
▪Stores keys after pairing (Bonding), allowing automatic reconnection next time.
5. Application Layer (Application Layer)
•Specific application implementations:
○BLE Smart Lock: GATT services used for locking/unlocking.
○BLE Sensor: Periodically sends temperature and humidity data.
○BLE Mesh Network: Used for smart homes, enabling communication between multiple devices.
2. Comparison of Bluetooth Protocol Architecture (BLE vs. Classic Bluetooth BR/EDR)
Conclusion
•The Bluetooth protocol architecture is clearly layered, with Bluetooth Low Energy (BLE) being more suitable for the Internet of Things (IoT) and smart devices.
•The basic architecture of BLE devices includes hardware layer, protocol stack layer, and application layer.
•The protocol stack layer mainly includes PHY, LL, L2CAP, GAP, GATT, SM, etc.
•GATT and ATT are responsible for data transmission of BLE devices, using UUIDs to identify services and characteristics.
•BLE device communication is based on master-slave mode, with the Central device controlling the Peripheral devices.
•BLE device communication is mainly based on GATT interactions, supporting read, write, notify, and indicate operations.