The idea: a strap that calls out, a phone that listens
A heart-rate strap has a tiny battery. It cannot keep its radio on all the time. So Bluetooth Low Energy (BLE) works in short bursts. First the strap advertises: it calls out "I am here, I measure heart rate" a few times per second. A phone that scans hears it and asks to connect. After that the two meet at fixed times, a fraction of a millisecond each time, and sleep in between. Over this link the phone uses GATT to find the heart-rate value and ask the strap to push every new value.
The page shows two devices: the strap (the peripheral and GATT server) and the phone (the central and GATT client). The middle panel is the air: the 40 BLE channels in frequency order, the channel in use now (orange), and a log of every packet.
Advertising and scanning
BLE uses 40 channels of 2 MHz from 2402 to 2480 MHz. Three of them are advertising channels:
37 (2402 MHz), 38 (2426 MHz) and 39 (2480 MHz). They sit apart, between the busiest Wi-Fi channels.
One advertising event sends the same ADV_IND on 37, then 38, then 39.
The next event starts one advertising interval later (100 ms here) plus a random
advDelay of 0 to 10 ms, so two advertisers do not collide every time.
The ADV_IND carries the strap's address and up to 31 bytes of data. Here: Flags
0x06 (discoverable, BLE only) and the service UUID 0x180D (Heart Rate).
The phone listens on one advertising channel at a time, so it misses the other copies.
In an active scan it answers the copy it heard with SCAN_REQ, on the same
channel, 150 µs later. The strap answers SCAN_RSP with more data: the name "HRM-Strap"
(Demo 1: advertise, then an active scan).
CONNECT_IND and connection events
To connect, the phone waits for the next ADV_IND and answers it with CONNECT_IND.
The strap stops advertising at once. CONNECT_IND holds everything the link needs:
| Field | Value here | Meaning |
|---|---|---|
| AA | 0x50654C23 | access address that marks this connection's packets |
| Interval | 24 → 30 ms | time between connection events (units of 1.25 ms) |
| Latency | 0 | events the strap may skip when it has nothing to send |
| Timeout | 200 → 2000 ms | supervision timeout (units of 10 ms) |
| ChM, Hop | all 37, 7 | which data channels to use and how far to jump |
From then on the two meet at a connection event every 30 ms. The phone always sends first;
the strap answers 150 µs later on the same channel. With nothing to say they send empty PDUs:
that still proves the link is alive. Each event moves to the next data channel:
channel = (last + hop) mod 37, so 7, 14, 21, 28, 35, 5, … A noisy channel spoils only one event
(Demo 2: connect, events hop channels).
With a peripheral latency of 4, the strap could sleep through up to 4 events in a row when it has no data, and save more battery. The page uses latency 0, so the strap answers every event.
GATT: services, characteristics, descriptors
GATT data lives in an attribute table on the strap. Each attribute has a handle (its address), a type (a UUID) and a value. The phone reads and writes them with ATT requests that ride inside the connection events.
| Handle | Type | Value |
|---|---|---|
| 0x000C | Primary Service 0x2800 | 0x180D Heart Rate |
| 0x000D | Characteristic 0x2803 | Notify, value at 0x000E, UUID 0x2A37 |
| 0x000E | Heart Rate Measurement 0x2A37 | flags 0x00, bpm |
| 0x000F | CCCD 0x2902 | 0x0000 (off) or 0x0001 (notify) |
| 0x0010 | Characteristic 0x2803 | Read, value at 0x0011, UUID 0x2A38 |
| 0x0011 | Body Sensor Location 0x2A38 | 0x01 Chest |
The phone does not know these handles at first, so it discovers them (Demo 3: GATT service discovery):
ATT_READ_BY_GROUP_TYPE_REQfor type 0x2800 finds the services. Heart Rate is 0x000C–0xFFFF; it ends at 0xFFFF, so it is the last one.ATT_READ_BY_TYPE_REQfor type 0x2803 finds the two characteristics. The phone asks again from 0x0011 and getsATT_ERROR_RSP0x0A, Attribute Not Found: no more.ATT_FIND_INFORMATION_REQon the handles between 0x000E and 0x0010 finds the CCCD at 0x000F.
Notifications and the CCCD
A read is one request and one response: ATT_READ_REQ 0x0011 returns 0x01,
Chest. Asking for the heart rate that way every second would waste radio time. Instead the phone writes
0x0001 to the Client Characteristic Configuration Descriptor (CCCD, 0x2902):
ATT_WRITE_REQ 0x000F = 01 00. From then on the strap pushes each new value as
ATT_HANDLE_VALUE_NTF in its next answer. A notification gets no ATT reply. While the CCCD is
0x0000, a new value stays on the strap and it answers with empty PDUs
(Demo 4: read, enable notifications, get bpm).
An indication (CCCD 0x0002) is the same push, but the phone must confirm each one. Heart rate uses notifications: a lost value is replaced by the next one a second later.
Supervision timeout
Both sides keep a timer. Each packet heard from the other side restarts it. If it reaches the
supervision timeout (2000 ms here) the link is lost. The phone reports
reason 0x08, Connection Timeout. The strap drops the link too, forgets the CCCD (it was not bonded) and
goes back to advertising (Demo 5: strap walks out of range). The timeout must be longer than
(1 + latency) × interval × 2, here 60 ms, so a few lost packets do not end the link.
See also Wi-Fi CSMA/CA, the other radio sharing the 2.4 GHz band, and MQTT QoS, which often carries such sensor values on from the phone or a gateway.
What the page leaves out
The page answers each ATT request in the same connection event; real stacks often answer one event later. It sends one packet each way per event and hides the link-layer SN/NESN acknowledgements, the More Data bit, the transmit window and window widening. It skips the MTU exchange, pairing and bonding, encryption, connection parameter updates, the 2M and Coded PHYs, extended advertising (Bluetooth 5) and Channel Selection Algorithm #2. The GAP and GATT services and RSSI are fixed sample values.