What is Bluetooth Low Energy, and how do GAP and GATT work?
Short answer: Bluetooth Low Energy (BLE) is a 2.4 GHz wireless protocol designed for very low power, short-range communication (sensors, wearables, phone accessories). GAP (Generic Access Profile) defines how devices discover and connect: advertisers/peripherals broadcast advertising packets, scanners/centrals listen and initiate connections. GATT (Generic Attribute Profile) defines how data is exchanged once connected: a server exposes services, each containing characteristics (values with properties: read, write, notify, indicate), identified by UUIDs, and a client reads, writes or subscribes to them.
Typical sensor example
GATT server (sensor)
└── Service: Environmental Sensing (0x181A)
├── Characteristic: Temperature (0x2A6E) properties: read, notify
│ └── CCCD descriptor (client enables notifications here)
└── Characteristic: Humidity (0x2A6F) properties: read, notify
The phone (central/GATT client) connects, discovers services, writes to the CCCD to enable notifications, and receives a notification each time the temperature changes.
Key concepts
- Advertising: packets every 20 ms–10 s on 3 advertising channels; can carry data without connecting (beacons, broadcast sensors).
- Connection interval (7.5 ms–4 s), peripheral latency and supervision timeout trade latency for power.
- MTU and data length extension decide how many bytes fit per packet (default 20 bytes of payload; up to ~244 with DLE and a larger MTU).
- Security: pairing (Just Works, Passkey, Numeric Comparison, Out of Band), bonding (storing keys), LE Secure Connections (ECDH). Just Works has no man-in-the-middle protection.
- PHYs: 1M, 2M (faster) and Coded (long range, 125/500 kbps).
- Newer features: LE Audio (LC3 codec, Auracast broadcast), direction finding, periodic advertising.
Power: a BLE sensor sleeping between connection events can average a few µA and run for years on a coin cell.
Embedded stacks: Zephyr Bluetooth (used by nRF Connect SDK), NimBLE (Apache Mynewt, ESP-IDF), vendor stacks (TI, ST, Silicon Labs), BlueZ on Linux.