Skip to content

Structure

  • Protocol Version: The version of the protocol (always 3).
  • Message Length: The length of the message, including the version, header, data, and checksum.
  • Message Type: The type of message. This is used to determine how to interpret the message.
  • Data: Both data field (header and payload) are made up of the same format:
    • Field Count: The number of fields in the data.
    • Fields: List of field types in the data
    • Data: The data itself, making used of bBytes to represent length and values.
  • Checksum: A 16-bit CRC checksum of the message (XMODEM).

Data

Within each Data element (the header data, or payload data), the structure is as follows:

Byte positionDescriptionTypeExample
1 -> 2Number of fields (n)uint162 0
3 -> 3+nField types[]uint81 2
3+n+1 -> endData[]bBytes[1 8] [3 9 9 9]

The Data should be in the order of the field types.

The example data includes 2 data fields, the first of type 1, with value byte array [8], the second of type 2, with value byte array [9 9 9].

bBytes

bBytes are a byte array that represents a length and then the data itself. The size of the length prefix depends on the field's data type ID:

  • Data type IDs 0–127: the length prefix is a uint8 (1 byte), allowing up to 255 bytes of data.
  • Data type IDs 128–255: the length prefix is a uint16 little-endian value (2 bytes), allowing up to 65535 bytes of data, though on device messages are generally limited to 2000 bytes.

All data type IDs currently assigned are below 128, so existing messages are unaffected by this change. IDs 128 and above are reserved for fields that need to carry more than 255 bytes of data.

For example, for a field with data type ID 1 (< 128), [1 8] would represent a byte array of length 1, with the value 8.

Or for a field with data type ID 3 (< 128), [3 9 9 9] would represent a byte array of length 3, with the values 9, 9, 9.

For a field with data type ID 200 (>= 128), the length prefix is 2 bytes little-endian, so [3 0 9 9 9] would represent a byte array of length 3, with the values 9, 9, 9.