Bluetooth Low Energy, from the radio up · Puzzle 3 · 4 of 5
The filing cabinet
In puzzle 2, the phone and the strap met on a timetable. Now they need to agree on what the data is: which value is the heart rate, and which is the battery level.
The problem
In puzzle 2, the phone and the strap met on a timetable to exchange packets. But a packet is just bytes. The strap has a heart rate, a battery level, a name, maybe a setting for its light. How does the phone ask for "the heart rate" and know the bytes it gets back are one?
See it
The strap keeps its data in a filing cabinet: GATT. The strap is the GATT server, the side that holds the data.
Step 1 of 4Each drawer is a service, a group of related values: Heart Rate, Battery.
Step 2 of 4In a drawer, each folder is a characteristic: one value, like the latest heart rate, 72. Its name is a UUID: for a standard value like this, the same number on every brand of strap. Predict: how does the phone ask for it?
Step 3 of 4By that name. The phone is the GATT client: "read 2A37", and the strap answers with the folder's value.
Step 4 of 4
The building block
GATT (Generic Attribute Profile) is the way a BLE device organizes its data, so any phone can find its way around it. The side that holds the data is the GATT server, usually the small device. The side that reads and writes it is the GATT client, usually the phone.
The data comes in two levels. A service is a group of related values: Heart Rate, or Battery. Inside each service, a characteristic holds one value: the latest heart rate, or the battery level in percent. A client can read a characteristic, write it, or, as the next puzzle shows, be told when it changes. Every read travels at the connection events: the request at one meeting, and the answer at that meeting or a later one. Each service and each characteristic is named by a UUID (universally unique identifier), a long number. For standard features, the Bluetooth group fixed the UUIDs in advance, so they're the same on every device: unlike the random ones UUID.randomUUID() gives you, these are agreed. They're written in hexadecimal (digits 0–9 and A–F) and, for standard features, shortened to four digits, so the heart-rate measurement is 2A37. That lets an app look for "the Heart Rate service" on any brand of strap.
Right after connecting, the phone asks the strap for its list of services and characteristics: service discovery. Only then does it know which drawers this cabinet has.
GATT's roles are separate from the roles in puzzle 2. Central and peripheral are about who sets the timing; server and client are about who holds the data. A phone can be a GATT server too, for example when a watch reads the phone's messages.
The analogy
The strap carries a filing cabinet. Each drawer is a service, with a label. Inside, each folder is a characteristic holding one sheet with one value. The phone doesn't rummage: it asks for "drawer Heart Rate, folder Measurement" by its label, and gets that sheet.
Check yourself
Sources
- Bluetooth Core Specification 5.4, Vol 3, Part G: Generic Attribute Profile (GATT) (services, characteristics, descriptors; client and server roles)
- Bluetooth SIG assigned numbers: characteristic UUIDs (
0x2A37: Heart Rate Measurement) - Android Developers: Connect to a GATT server
What you now know
GATT organizes a device's data like a filing cabinet: services are drawers, characteristics are folders holding one value, each named by a UUID. The GATT server holds them; the GATT client reads and writes them.
Answer every question above correctly to unlock the next puzzle.
Something wrong or unclear on this page? Tell me: a puzzle that didn't click is a bug in the puzzle.