Skip to main content

Module packet

Module packet 

Source
Expand description

The transmit-side packet builder — allocation-free.

Builds the full wire packet: command + checksum, encoded as UTF-8 bytes, written into a caller-provided buffer. The checksum is a bytewise sum mod 256, formatted as 2 uppercase hex chars — exactly the app’s SkydroidControl.getCrc.

Functions§

build
Build the full wire packet from raw command bytes: command + checksum, written into out. Returns the total bytes written, or None if out is too small (cmd.len() + 2 needed).
build_command
Build a wire packet from any Command implementor, writing into out.
checksum_byte
Compute the checksum byte for a command: (sum of all bytes) mod 256.
checksum_hex
Compute the 2-character uppercase-hex checksum string as ASCII bytes.
verify
Given a full packet (cmd + 2-char checksum), verify the checksum matches.