Skip to main content

Crate irbt_proto

Crate irbt_proto 

Source
Expand description

Wire protocol between the ir-bt-bridge firmware and the irbt host tools.

Every message is a Frame, serialized with postcard, followed by a CRC-16, COBS-encoded and delimited by 0x00 bytes on both sides:

0x00 | COBS( postcard(frame) ‖ crc16_le ) | 0x00

COBS guarantees the encoded body never contains 0x00, so the delimiter is unambiguous and a receiver can resynchronize at the next 0x00 after garbage. Bytes that don’t form a valid frame (ROM bootloader text, panic dumps) are surfaced by Decoder as Decoded::Raw instead of being lost.

postcard is not self-describing: enum variant order is wire ABI. Only ever append variants/fields at the end, and bump PROTOCOL_VERSION for anything that changes existing encodings. tests::golden_* pin the bytes.

Structs§

Battery
BuildInfo
How the firmware was built. A free-form component list, so new entries need no protocol change.
Component
Decoder
Streaming frame decoder. Feed it bytes as they arrive.
DeviceInfo
KeymapPage
Log
Mapping
Request
Response
Status
UnknownKey

Enums§

Command
Decoded
One item produced by Decoder.
EncodeError
Event
Unsolicited device → host notifications.
Frame
Top-level unit on the wire. Request flows host → device; everything else flows device → host.
HidKey
Keys the bridge can send to Google TV.
HidUsage
Which HID report a key is sent in, and its usage ID there.
LogLevel
Reply

Constants§

MAX_FRAME_LEN
Largest postcard body + CRC accepted on either side. Keeps the device’s buffers bounded; senders must split anything larger (see ListKeymap).
PROTOCOL_VERSION
Bumped on any change that alters the encoding of existing messages.

Functions§

encode
Encode frame into a complete wire frame, delimiters included.

Type Aliases§

IrCode
A raw 32-bit NEC code as decoded by the firmware’s IR receiver (address, ~address, command, ~command, MSB-first).