TransponderDevice contractv1

Give your device a voice

A button and microphone can send a turn to an agent. A speaker can play its reply. Implement either direction on its own, or both for a two-way conversation. The app owns account access and the call. Your device handles capture, playout and the feedback the user sees or hears.

On this page

Choose a direction

What you’re buildingOffer in WELCOMEBLE endpoint beyond Control and Status
A microphone or talk button with audio inputVoice input, bit 3 (0x08)1003, microphone notifications
A speaker accessoryVoice output, bit 4 (0x10)1004, media writes without response
A two-way intercomBoth, mask 0x181003 and 1004

Start after a successful HELLO/WELCOME with a nonzero conversation context. A connected BLE link means the app can exchange device messages. VOICE_READY tells you which directions the current agent call can use. Losing the upstream chat-history connection does not by itself end the call.

Bring up the call without recording

On a user request, send ACTION (8) on Status with payload 0e 01, ID equal to the selected context and a fresh nonzero sequence. The sequence identifies this connection attempt. Repeat that ID for retransmission. Choose a new ID for a new attempt after an error. The app can respond with VOICE_PROGRESS, VOICE_READY or ERROR on Control. A device with a microphone can also initiate a call by announcing an actual capture.

Match connection progress and failures to the context and intent. Show “Connecting” while there is an outstanding attempt. Enter the ready state when READY reports usable media. Speaker traffic may never arrive during a successful connection. Use a finite deadline if the phone cannot respond. The voice control reference defines the exact flags and stages.

Send one microphone turn

This abbreviated trace uses context 42, boot 7 and utterance 9. Headers below show ID and sequence in decimal. The connection epoch remains the negotiated epoch throughout. Two synthetic frames make the offsets easy to verify. Normal recordings can span many frames, and the first announcement can be sent while the button is still down.

StepMessage and directionExpected behavior
1. AnnounceDevice → app CAPTURE, ID 9, seq 1, flags 0x51. Payload 2a 00 00 00 07 00 00 00 40 01 00 00 00 01.320 samples recorded, manual button, automatic send allowed. The flags request a rolling phone-owned journal and bounded live input. Keep the frame locally until ownership is acknowledged.
2. Admit inputApp → device VOICE_READY, ID 42, seq 9, header flag 1. Example payload 12 37 00 00 00. App → device MIC_ACK, ID 9, seq 0, flags 3, grant 2.READY byte 0x12 permits mic input to the journal while the call connects. Session ID is 55. Grant 2 permits frames 0 and 1. Readiness alone grants no frames.
3. SendDevice → app MIC on 1003, ID 9, seq 0, valid count 320. When the button is released, send the last MIC at seq 1 with valid count 80. Reannounce ended CAPTURE with ID 9, seq 2, total samples 400, and flag 2 set.Each MIC carries 166 bytes. Continue announcing final counts until the turn resolves. Keep the original context/boot and set handoff-uncertain if frames have left the device.
4. Transfer ownershipApp → device MIC_ACK, ID 9, seq 2, flags 3, example grant 2.The phone owns frames 0 and 1. Their local buffer slots can be reused. The release announcement still awaits delivery.
5. Complete handoffApp → device DELIVERY, ID 9, seq 2, flags 2, empty payload.The app counted all 400 valid samples through the upstream media callback. Release pending recording state. Recognition and the agent reply may follow later.

An exclusive grant of G permits frame sequences strictly below G. Reject a cumulative ACK beyond sent data. While waiting, preserve unsent frames and prevent new capture from overwriting them. When durable ownership and the bounded window are negotiated, the maximum input lead is 250 frames (five seconds). The host can feed the call sooner. If an ACK is lost, retransmit the same frame under the same utterance ID. Preserve exact final valid counts so padding at the end of the codec block never becomes extra speech.

Verify the codec

At 16 kHz mono, each full frame contains 320 signed PCM16 samples. Each wire frame contains a little-endian valid count followed by an independent 164-byte IMA ADPCM block. Decode from that block’s own predictor and step index. The low nibble of each encoded byte comes first.

05 00  e8 03  00 00  07 19  [158 zero bytes]
count  predictor index/reserved  codes

The valid count is 5, the predictor is +1000, and the step index starts at 0. The four codes are 7, 0, 9, 1. The five valid decoded samples are [1000, 1011, 1013, 1009, 1013]. The wire frame remains 166 bytes. This tests sign, nibble order, index updates and truncation to valid count. Start your transport test with the silent frame in the packet fixtures.

Play a reply

For an output-only device, request a call without starting a capture, or accept an app-originated voice intent. Wait for media-ready and output-enabled bits. Use the session ID inside READY for speaker flow control. It differs from the conversation context and utterance ID. Reset frame sequencing when the voice session changes.

READY    app → device    context 42, payload 05 37 00 00 00
CREDIT   device → app    ID 55, seq 0, payload 02 00 00 00
SPEAKER  app → device    ID 55, seq 0, 166 bytes on 1004
SPEAKER  app → device    ID 55, seq 1, 166 bytes on 1004
CREDIT   device → app    ID 55, seq 2, payload 02 00 00 00
CREDIT   device → app    ID 55, seq 2, payload 04 00 00 00

The first CREDIT reserves two frame slots. After accepting both, seq 2 acknowledges them. Grant 2 holds the sender while the queue is full. Grant 4 opens two slots as playback drains. Bound the outstanding grant to 64 frames or less and size it to your actual queue. Discard stale sessions. On a gap or duplicate, report your current next expected sequence and space. Keep BLE callbacks short and feed the speaker from a bounded queue.

Follow the reply-busy bit (mask 0x08) of the READY payload to show a pending or playing reply. Its transition back to clear completes the reply lifecycle even if the agent produced text only. Agent thinking and unread-message indicators come from a separate presentation snapshot.

Recover a turn

ObservationDevice action
Connected but no agent bound, or call setup failsKeep any unsent turn private to its original context. Display the reported reason, or say the app did not respond before your deadline. Offer Retry and Discard.
BLE drops after one or more frames might have been heardEnd the old session. Mark the handoff uncertain. Reconnect with a fresh epoch and wait for an explicit user decision before replaying any audio.
User retries retained audioAnnounce a fresh utterance. If some frames were released to the phone journal, set CAPTURE flags 16 and 32 and append the original recording ID to the payload. Use the new grant/resume position. The reference app starts recovery from the CAPTURE announcement. Sending ACTION 7 alone to the phone does not replay the recording.
User discardsRelease local turn state and signal ACTION [8,0] for the current context to release phone-side recording state. The next press starts an independent turn.
The upstream turn fails after deliveryA matching ERROR with flag 2 reports a turn failure while the call remains usable. A matching connection ERROR with flag 1 ends the connection attempt.

For exact payload layouts, use the voice frames and ownership registry.

Voice control reference

Packet fields and receiver rules

Voice input and output have independent capabilities. The app owns provider authentication, call setup and the upstream connection. The device owns local recording and playout decisions. Keep connection readiness, current turn, microphone transfer and speaker playout as separate state.

KindDirectionID / seqPayload and flags
8 ACTIONEither, by actioncontext / intent for connect, otherwise 0u8 action, u8 value. 4 stop voice, 5 input mode (0 push to talk, 1 hands-free), 6 volume, 7 retry, 8 discard, 13 app defers legacy capture, 14 connect voice (value 1).
24 VOICE_PROGRESSApp → devicecontext / current intentu8 stage, then ≤80 ASCII bytes. Stages 0 off, 1 requested, 2 authorizing, 3 negotiating, 4 connecting, 5 reconnecting, 6 ready, 7 failed. Flag 2 starts an app-originated intent at stage 1.
14 VOICE_READYApp → devicecontext / intent when header flag 1, otherwise 0u8 readiness bits, u32 voice session. Bit values 1 media, 2 mic admission, 4 output, 8 reply pending/playing, 16 phone can retain recording.
16 ERRORApp → devicecontext / intent or utterance≤80 bytes ASCII without length prefix. Flag 1 connection failure for this intent. Flag 2 error for a delivered turn without ending the call. Legacy flag 0 uses seq 0.

Initiate a call with ACTION [14,1], a nonzero bound context and a fresh nonzero intent ID. Reuse the intent ID when repeating that request. Respond to current progress/readiness/failure only. A retry after an error is a new user intent. A device can also start by announcing a real utterance. Contacting an app, connecting a call and delivering audio are different outcomes. A disconnected device can advertise to invite reconnection. OS background scheduling can delay or prevent a response. Give a finite timeout with a truthful error and a way to retry or discard. Never infer call success from speaker traffic. Reply-busy clearing can complete a successful silent or text-only turn.

Voice frames and ownership reference

Packet fields and receiver rules

Audio uses signed mono PCM at 16,000 Hz before compression. Each 20 ms frame contains 320 samples. Encode independent IMA ADPCM blocks: s16 initial predictor (sample 0), u8 initial step index (0–88), zero reserved byte, then 160 bytes coding samples 1–319, lower nibble first. The final high nibble is unused. Saturate predictor to signed 16 bits and clamp the index to 0–88 after each nibble. Prepend u16 valid sample count (1–320). The transmitted MIC/SPEAKER payload is always 166 bytes, including for a partial final frame.

KindDirectionID / seqPayload and flags
9 CAPTUREDevice → appnonzero utterance / number of frames recorded so faru32 original context, u32 boot nonce, u32 total valid samples, u8 from VAD, u8 automatic retry allowed. When flag 32 set append u32 prior recording ID. Flag bits: 1 pending, 2 ended, 4 manual retry required, 8 handoff uncertain, 16 phone retention, 32 retry from phone, 64 bounded live window.
10 MICDevice → app on 1003utterance / zero-based frameValid sample count and ADPCM block.
11 MIC_ACKApp → deviceutterance / next expected frameu32 exclusive grant. Flag 1 acknowledges durable phone retention. Flag 2 additionally bounds live input.
12 SPEAKERApp → device on 1004voice session / zero-based frameValid sample count and ADPCM block.
13 CREDITDevice → appvoice session / next expected speaker frameu32 exclusive grant, from next expected through next expected + 64. Refresh credits as the local playback queue drains.
15 DELIVERYApp → deviceutterance / final frame countEmpty. Flag 2 confirms all valid samples reached the upstream media callback. Flag 1 indicates uncertain handoff.

For microphone input, announce CAPTURE with a stable (device, boot, context, utterance) identity. Reannounce until resolved. Wait for the appropriate mic/media or retention readiness and a grant before sending. For grant G, send only frames with seq < G. Resends must preserve the exact frame and ID. Reject ACKs beyond sent data, backward ACKs and excessive windows. Release a rolling-buffer slot only after cumulative ownership ACK covers it. With the bounded live window the cap is 250 frames (five seconds). The host can start forwarding as soon as media becomes writable. The window limits how far capture may run ahead of the upstream call.

On release, send the ended CAPTURE with final frames and exact total valid samples. A write acknowledgment, mic ACK and DELIVERY are three distinct events. Only matching DELIVERY for the ended utterance releases pending turn state. It certifies handoff to the media callback. Observe reply state separately. Keep ambiguous captures for an explicit decision. If retrying from a retained phone recording, allocate a new ID and include the original recording ID (flags 16 and 32). Never replay an uncertain utterance on reconnection or send it to a newly selected agent.

For output, start sequence 0 for a new voice session, accept only your next frame and publish cumulative CREDIT as room permits. Repeated, late and future frames must not play twice. The host prioritizes active audio at complete media-message boundaries. Keep enough capacity to finish reassembling one message. Do not interleave two fragmented messages on a single characteristic.