module

Matter::Protocol::IMHandler

Helper module for Interaction Model message handling

Constants

Log = ::Log.for("matter.im")
MAX_REPORT_PAYLOAD_SIZE = 1100

Maximum TLV payload size per message (conservative value to stay under IPv6 MTU of 1280) Overhead: UDP header (8) + IPv6 header (40) + Matter packet header (~12) + Matter payload header (~13) + MAC tag (16) = ~89 bytes overhead 1280 - 89 = ~1191 bytes available for TLV payload, use 1100 for safety margin

MSG_INVOKE_REQUEST = 8_u8
MSG_INVOKE_RESPONSE = 9_u8
MSG_READ_REQUEST = 2_u8
MSG_REPORT_DATA = 5_u8
MSG_STATUS_RESPONSE = 1_u8

IM message types

MSG_SUBSCRIBE_REQUEST = 3_u8
MSG_SUBSCRIBE_RESPONSE = 4_u8
MSG_TIMED_REQUEST = 10_u8
MSG_WRITE_REQUEST = 6_u8
MSG_WRITE_RESPONSE = 7_u8

Class methods

encode_chunked_report_data(attribute_reports : Array(InteractionModel::AttributeReportIB), subscription_id : UInt32 | Nil = nil) : Array(Tuple(Bytes, Bool))

Chunk attributes into multiple ReportData messages that fit within MTU Returns an array of (encoded_bytes, is_last_chunk) tuples

Source
encode_invoke_response(invoke_responses : Array(InteractionModel::InvokeResponseIB), suppress_response : Bool = false) : Bytes

Encode InvokeResponse using TLV::Serializable Encode InvokeResponse from array of InvokeResponseIB

Source
encode_report_data(attribute_reports : Array(InteractionModel::AttributeReportIB), subscription_id : UInt32 | Nil = nil, more_chunked_messages : Bool = false, suppress_response : Bool = false) : Bytes

Encode ReportData from array of AttributeReportIB Used for both ReadResponse and initial subscription data

Source
encode_subscribe_response(subscription_id : UInt32, max_interval : UInt16) : Bytes

Encode SubscribeResponse

Source
encode_write_response(write_responses : Array(InteractionModel::AttributeStatusIB)) : Bytes

Encode WriteResponse from array of AttributeStatusIB

Source
invoke_commands(invoke_requests : Array(InteractionModel::CommandDataIBTlv), clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base), session_id : UInt64 | Nil = nil, is_case_session : Bool = false, fabric_index : UInt8 | Nil = nil, peer_subject_ids : Array(UInt64) | Nil = nil) : Array(InteractionModel::InvokeResponseIB)

Execute commands from invoke requests Returns array of InvokeResponseIB for each command

Source
parse_invoke_request(payload : Bytes) : InteractionModel::InvokeRequestMessage | Nil

Parse InvokeRequest from decrypted TLV payload

Source
parse_read_request(payload : Bytes) : InteractionModel::ReadRequestMessage | Nil

Parse ReadRequest from decrypted TLV payload

Source
parse_subscribe_request(payload : Bytes) : InteractionModel::SubscribeRequestMessage | Nil

Parse SubscribeRequest from decrypted TLV payload

Source
parse_write_request(payload : Bytes) : InteractionModel::WriteRequestMessage | Nil

Parse WriteRequest from decrypted TLV payload

Source
read_attributes(attribute_requests : Array(InteractionModel::AttributePath) | Nil, clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base), fabric_index : UInt8 | Nil = nil, is_case_session : Bool = false, peer_subject_ids : Array(UInt64) | Nil = nil) : Array(InteractionModel::AttributeReportIB)

Read attributes from clusters The fabric_index parameter is used for fabric-scoped attributes like CurrentFabricIndex Returns an array of AttributeReportIB, each containing either data or status

Source
write_attributes(write_requests : Array(InteractionModel::AttributeDataIB) | Nil, clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base), session_id : UInt16 | Nil = nil, is_case_session : Bool = false, fabric_index : UInt8 | Nil = nil, peer_subject_ids : Array(UInt64) | Nil = nil) : Array(InteractionModel::AttributeStatusIB)

Write attributes to clusters Returns array of AttributeStatusIB for each write operation

Source