TransponderDevice contractv1

Show images from a conversation

A screen can receive thumbnails of images the agent places in a conversation. Start with a single image encoded as RGB565 rows. Add gallery navigation and JPEG only if the device has the storage and decoder for them. A general image display works independently of downloadable faces.

On this page

Choose a profile

Your receiverImage feature bitsRequired behavior
Single imageBit 5, mask 0x20Support row-based RLE, cumulative acknowledgments and explicit presentation.
Browsable galleryBits 5–6, mask 0x60Also understand message token, image index and count. Request or pin an index.
Browsable gallery with JPEGBits 5–7, mask 0xE0Also receive baseline JPEG chunks, verify compressed bytes and decode within bounds. Accept RLE fallback.

Expose the writable Media characteristic 1004 for the image bytes. IMAGE_BEGIN, END and PRESENT arrive on Control. Send every ACK and gallery request on Status. Working from complete logical messages keeps transfers independent of the negotiated ATT packet size. Frame a message.

Receive two red pixels

This synthetic single-image exchange fits a 2 × 1 thumbnail into one row. Assume the current nonzero context is 42 and the message token is 23. Without gallery support, the same token identifies the transfer and presentation. All fields use little-endian encoding. The ID and sequence below are decimal header fields.

MessageID / sequencePayload (hex)Expected effect
App → device IMAGE_BEGIN (17), flags 042 / 2302 00 01 00 5a 87 f5 29Reserve staging for width 2, height 1, expected CRC32 0x29F5875A. Keep the current image displayed.
Device → app IMAGE_ACK (20), flags 023 / 0EmptyReady for row zero. BEGIN acknowledges setup only.
App → device IMAGE_ROW (18), flags 023 / 081 00 f8Expand to two copies of RGB565 red (0xF800). Feed the uncompressed bytes 00 f8 00 f8 to CRC32.
Device → app IMAGE_ACK (20), flags 023 / 1EmptyAll rows received. The image remains staged.
App → device IMAGE_END (19), flags 042 / 23EmptyVerify the row count, dimensions and checksum. Commit only valid pixels.
Device → app IMAGE_ACK (20), flags 123 / 1EmptyCommit receipt. The user can now view this image. A duplicate END for the same completed transfer can repeat this ACK.
App → device IMAGE_PRESENT (21), flags 042 / 23a0 0fRequest that the committed image appear for 4,000 ms. Match the current message and respect a user interaction already in progress.

Rows are independent. Each command’s low seven bits encode the pixel count minus one. A set high bit repeats the following u16 color. Otherwise copy the given number of literal u16 colors. Check input length before reading, cap expansion to the declared width and require exactly that many pixels when the row ends. RGB565 uses red bits 15–11, green bits 10–5 and blue bits 4–0.

Reproduce the integrity check locally with python3 -c "import zlib; print(hex(zlib.crc32(bytes.fromhex('00 f8 00 f8'))))". The expected result is 0x29f5875a. Change the RLE color to 01 f8 but retain the original BEGIN. On END the receiver should issue IMAGE_ACK with flags 2 and preserve the previously committed image. The packet fixtures include the intact IMAGE_ROW with its wire header.

Receive a JPEG

Check width 1–192, height 1–152 and encoded length 1–16,384 bytes before reserving memory. A JPEG BEGIN has flag 1, with a 20-byte payload containing width, height, CRC32, gallery message token, index, count and compressed byte length. CRC covers the exact JPEG file bytes. Bound both memory use and decoded dimensions, and require successful baseline JPEG decoding before issuing a committed ACK.

For example, take gallery 31, index 0 of 2, a fresh transfer token 70 and 900 JPEG bytes. Once BEGIN is accepted, ACK ID 70 at offset 0. If media capacity allows 300-byte chunks, expect ROW seq 0, 300 and 600 with flag 1. ACK the contiguous byte offset 300, 600, then 900. END has ID 42 and seq 70. After validation, the successful ACK has ID 70, seq 900 and flag 1. To show it, PRESENT uses ID 42 and seq 31, the gallery message token. The transfer token is scoped to this attempt.

The sender can have up to four RLE rows or twelve JPEG chunks in flight. A JPEG chunk is ≤512 bytes and sized for the media characteristic. An ACK represents the next contiguous offset or row. If a chunk arrives twice, report the same progress and keep the original bytes. If it arrives ahead of a gap, report your current contiguous position. Allow speaker traffic between complete image messages. The reference sender retries after two seconds without progress, with at most three retries before reporting failure.

Only advertise gallery support with the base image profile. A gallery BEGIN adds an opaque message token, a zero-based index and a positive count. Reject an out-of-range index. Keep the conversation and gallery token with all stored images.

User or host eventProtocol action
User opens index 1 of gallery 31Send IMAGE_REQUEST (23), ID 42, seq 31, flags 0, payload 01 00. Accept the selected image under a new transfer token.
User selects an image already decoded locallyUse the local pixels and send the same request with flags 2 to pin the selection. Avoid another download.
A newer reply arrives while viewing an older galleryKeep the user’s pinned gallery and index. Receiving bytes or an unread indicator does not itself request a popup.
Host prefetches a sibling JPEGBEGIN has flags 5 (JPEG + cache-only). Accept a sibling of the selected gallery when capacity permits. Verify and ACK it without changing the displayed selection.
User dismisses the gallerySend IMAGE_REQUEST, ID 42, seq 31, flags 1 and an empty payload to release the selection.
An attachment cannot be obtainedThe app can send IMAGE_BEGIN with flags 2, ID 42, seq 31 and an empty payload. Offer a fresh request if the user retries.

On disconnect, clear partial staging and ACK state. Across a conversation change, invalidate gallery tokens and pending presentation requests. Bound any compressed cache and use the host for evicted entries. A cache fill, a committed image, and an explicit request to bring it onscreen have separate meanings. Image and gallery wire reference.

Images and galleries reference

Packet fields and receiver rules
KindDirectionID / seqPayload and flags
17 IMAGE_BEGINApp → devicecontext / transfer tokenu16 width, u16 height, u32 CRC. Gallery adds u32 message token, u16 index, u16 count. JPEG adds u32 compressed byte length. Flag 1 JPEG, flag 4 cache-only JPEG. Flag 2 alone carries an empty payload with gallery token as seq to report unavailability.
18 IMAGE_ROWApp → device on 1004transfer token / row or byte offsetRLE row with flags 0, or compressed file bytes with flag 1.
19 IMAGE_ENDApp → devicecontext / transfer tokenEmpty. Flag 0 RLE or 1 JPEG. Verify the complete object before committing.
20 IMAGE_ACKDevice → apptransfer token / next expected row or byte offsetEmpty. Flags 0 cumulative progress, 1 verified commit, 2 failed.
21 IMAGE_PRESENTApp → devicecontext / message tokenu16 duration in milliseconds, 1,000–15,000. Explicit request to show the matching committed image.
23 IMAGE_REQUESTDevice → appcontext / gallery message tokenFlags 0 request index (u16), 2 pin an already rendered index (u16), 1 release (empty).

Fit within 192 × 152, validate nonzero dimensions and gallery count, and require index < count. Each RLE command covers (low seven bits + 1) RGB565 pixels. If bit 7 is set, repeat the following little-endian color, otherwise copy that many little-endian colors. A row must expand exactly to width. CRC-32/IEEE covers all uncompressed row-major RGB565 bytes. For JPEG validate a baseline file of ≤16 KiB, integrity over the compressed file bytes, and agreement with declared dimensions. The absence of gallery capability uses the 8-byte BEGIN form and the transfer token as message token.

ACK 0 offset at BEGIN. The sender allows four RLE rows or twelve JPEG chunks in flight (JPEG chunks ≤512 bytes). Accept duplicates idempotently, ACK only contiguous complete data, and only commit after decoding and CRC validation. The reference sender retries after two seconds without progress up to three times. Keep the last displayed image on corruption or interruption. A cache-only BEGIN must never replace the user’s displayed image. The host can preload history on reconnect. Only explicit IMAGE_PRESENT requests a popup. Gallery navigation is scoped to its conversation and reply. A face asset and a chat attachment use different contracts.