Two ways to talk
- Advertising (connectionless). A device broadcasts small packets on the three primary advertising channels. Good for beacons, sensor broadcasts and discovery. Nobody has to connect.
- Connections. A central connects to a peripheral; both then wake up at agreed connection events. Needed for bidirectional data, reliable delivery and security (pairing/bonding).
Roles (GAP)
| Role | Typical device |
|---|---|
| Peripheral | the sensor, lock or wearable; advertises and accepts connections |
| Central | phone, gateway or PC; scans and initiates connections |
| Broadcaster / Observer | advertising-only sender / scan-only receiver |
Data model (GATT)
- A service groups related data (e.g. Battery Service).
- A characteristic is one value with properties: read, write, write without response, notify, indicate.
- Descriptors describe a characteristic; the most important is the CCCD, which the client writes to enable notifications or indications.
- UUIDs: 16-bit for Bluetooth SIG-assigned types, 128-bit for your own.
The GATT server role is independent of central/peripheral: usually the peripheral is the GATT server, but a phone can host a GATT server too.
Notifications vs indications vs reads
- Notify: server pushes a value, no acknowledgement at the ATT layer. Use for sensor streams.
- Indicate: pushed and acknowledged; only one outstanding indication at a time, so it is slower. Use for events that must not be lost at the application level.
- Polling reads waste energy on both sides; prefer notifications.
First limits you will hit
- Default ATT MTU is 23 bytes, so a notification carries at most 20 bytes until the MTU is negotiated upward. See the separate item on MTU and Data Length Extension.
- Legacy advertising data is limited to 31 bytes.
- Connection interval, peripheral latency and supervision timeout decide battery life and responsiveness. See the item on connection parameters.
- Phones decide much of this for you (connection intervals, MTU, scan behavior), and iOS and Android differ. Test on both.