MatterEx.IM (matter_ex v0.4.0)

Copy Markdown View Source

Matter Interaction Model codec — encode/decode IM payloads.

Decode takes an opcode atom (from ProtocolID.opcode_name) and the raw TLV binary from ProtoHeader.payload. Encode takes a message struct and returns TLV binary.

Attribute/command values use tagged tuples for encoding (e.g. {:uint, 42}) and plain Elixir values after decoding.

Summary

Functions

Chunk a ReportData into multiple messages, each with at most max_reports attribute reports. All chunks except the last have more_chunked_messages: true.

Functions

chunk_report_data(report, max_reports \\ 9)

@spec chunk_report_data(
  %MatterEx.IM.ReportData{
    attribute_reports: term(),
    event_reports: term(),
    more_chunked_messages: term(),
    subscription_id: term(),
    suppress_response: term()
  },
  pos_integer()
) :: [
  %MatterEx.IM.ReportData{
    attribute_reports: term(),
    event_reports: term(),
    more_chunked_messages: term(),
    subscription_id: term(),
    suppress_response: term()
  }
]

Chunk a ReportData into multiple messages, each with at most max_reports attribute reports. All chunks except the last have more_chunked_messages: true.

decode(opcode, binary)

@spec decode(atom(), binary()) :: {:ok, struct()} | {:error, atom()}

encode(msg)

@spec encode(struct()) :: binary()