Stream framing used by the serial and TCP transports.
| Frames sent to the device are `0x3C | length (u16 LE) | payload`; frames |
| coming from the device are `0x3E | length (u16 LE) | payload`. The decoder is |
resilient against garbage on the line (some radios interleave console
output on the same UART): it resynchronises on the next 0x3E byte and
drops frames announcing more than 300 bytes.
Summary
Functions
Feeds a chunk of received bytes; returns the completed frame payloads (in order) and the new decoder state.
Wraps payload into an outgoing frame.
Creates an empty decoder state.
Types
@type t() :: %Meshcore.Frame{buffer: binary()}
Functions
Feeds a chunk of received bytes; returns the completed frame payloads (in order) and the new decoder state.
iex> {frames, _} = Meshcore.Frame.decode(Meshcore.Frame.new(), <<0x3E, 2, 0, 0xAA, 0xBB, 0x3E, 1>>)
iex> frames
[<<0xAA, 0xBB>>]
Wraps payload into an outgoing frame.
@spec new() :: t()
Creates an empty decoder state.