Turns the generic terms produced by Sml.Parser into Sml.Message structs.
Message bodies are recognized by their tag. Bodies with an unknown tag or an
unexpected shape are returned as {:unknown, tag, terms} instead of failing
the whole telegram.
Summary
Functions
Decodes a parsed message body ([tag, body]) into its struct.
Decodes a single message from the beginning of data.
Decodes all messages in payload (the unwrapped content of a telegram).
Types
@type error() :: {:parse_error, reason :: term(), offset :: non_neg_integer()} | :invalid_crc
Functions
@spec decode_body(Sml.Parser.term_t()) :: Sml.Message.body()
Decodes a parsed message body ([tag, body]) into its struct.
@spec decode_message(binary(), keyword()) :: {:ok, Sml.Message.t(), binary()} | {:error, term(), binary()}
Decodes a single message from the beginning of data.
@spec decode_messages(binary(), keyword()) :: {:ok, [Sml.Message.t()]} | {:error, error()}
Decodes all messages in payload (the unwrapped content of a telegram).
Options
:crc- checksum algorithm to verify::auto(default, X-25 or Kermit),:x25,:kermit, orfalseto skip the check