Build an activity light
Give an agent a physical indicator. When the agent starts working, the lamp lights up. A second indicator shows when a reply is waiting. This first device needs two Bluetooth characteristics and one negotiated capability.
On this page
Before you start
Use a contract-aware Transponder app and a BLE peripheral that supports authenticated LE Secure Connections. Public S3 firmware v27 uses the older handshake. The example below runs on your computer even without either device. Check release compatibility.
Run the first exchange
Download indicator.py and vectors.json into the same folder. Run the example with Python 3. It answers a HELLO, receives a SNAPSHOT across three fragments, and rejects a changed conversation under the same epoch.
python3 indicator.py
Passed identity, negotiation, indicators and malformed-envelope checks.
In the snapshot, the first payload byte is 03. Bit 0 turns on the working light. Bit 1 turns on the unread light. The third fragment completes the message. Before that fragment arrives, neither light should change.
Wire it to a peripheral
- Advertise the service. Expose a protected Control read/write characteristic and a notifying Status characteristic. Use a stable eight-byte device ID and a new nonzero nonce on each boot. Copy the UUIDs and properties.
- Pair with the owner. Open Add device in Transponder. Let the owner compare the number and confirm the bond using a trusted display and input on the peripheral, or an equivalent authenticated arrangement supported by both ends. A lamp can use a small setup display and button. A blink alone cannot confirm a six-digit comparison.
- Connect the callbacks. Return
identity()on an authenticated Control read. After the host enables Status notifications, pass each protected Control write toreceive(). Split its WELCOME withstatus_fragments(welcome, value_limit)and notify on Status as your stack allows. The limit is the maximum characteristic value in bytes (usually ATT MTU minus three). On subscription loss or disconnect, calldisconnect()and clear the lights. Keep one instance per peer. - Drive the output. After a complete valid snapshot, assign
workingandunreadto your two outputs. Ask the selected agent a question from the app. Watch for the working indication and then the unread reply. Only a text-capable device sends a READ receipt. The lamp follows subsequent snapshots. A fast reply can arrive before the app relays an intermediate working state.
What to look for on the link
- App reads deviceControl identity
16 bytes. The device sets bit0x10and offers contract version 1. - App writes ControlHELLO
The host opens an epoch and offers features for this conversation. - Device notifies StatusWELCOME
Echo the epoch and context. Return the boot nonce and the agreed presentation bit. - App writes ControlSNAPSHOT
Assemble the entire payload, check its revision, then update both lights together.
If the lamp stays dark
- No identity read. Check the service UUID, bond and access permissions.
- HELLO without WELCOME. Confirm the Status subscription, the version intersection and room for the 20-byte header plus data. At ATT MTU 23 the notification value has just 20 bytes. Check framing and fragment size.
- WELCOME without an indication. Check presentation in the agreed mask, the selected context, and whether a complete current-epoch snapshot arrived.
Choose what to build next
- A message displayDifferentiate unread replies, agent activity and relay availability. Open a message or browse history.
- A voice accessoryAdd a microphone, a speaker or both. Follow one turn from button press to delivery.
- An image displayValidate an attachment before showing it.
- A changeable faceAccept a small artwork package and preserve the last working face.
For exact packet layouts, dependencies and version rules, use the session reference. For power telemetry and signed firmware, see maintenance and upgrades.