WireFraming

Single source of truth for the Meshtastic STREAM_API wire-framing constants shared by every stream-oriented transport (TCP, USB-CDC serial, BLE).

Per protocol.md §2, the on-wire framing is:

+------+------+----------+----------+==================+
| 0x94 | 0xC3 | LEN_HI | LEN_LO | protobuf bytes |
+------+------+----------+----------+==================+

The 4-byte header is followed by up to MAX_PAYLOAD_SIZE bytes of protobuf payload, giving a total wire envelope of at most MAX_FRAME_ON_WIRE bytes.

Centralising these here lets the per-transport framers avoid redefining the same magic numbers; see WireCodec for the engine encoder/decoder that uses the same values.

Properties

Link copied to clipboard
const val HEADER_SIZE: Int = 4

Fixed framing header length: MAGIC_0 MAGIC_1 LEN_HI LEN_LO.

Link copied to clipboard
const val MAGIC_0: Byte

First sync byte (START1) of every STREAM_API frame.

Link copied to clipboard
const val MAGIC_1: Byte

Second sync byte (START2).

Link copied to clipboard

Maximum total on-wire envelope size: HEADER_SIZE + MAX_PAYLOAD_SIZE.

Link copied to clipboard
const val MAX_PAYLOAD_SIZE: Int = 512

Maximum payload size in bytes (exclusive of header). Enforced by the firmware's de-framer; frames whose announced length exceeds this trigger a resync rather than a buffer overflow.