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_STATUS_RESPONSE = 1_u8
MSG_SUBSCRIBE_REQUEST = 3_u8
MSG_SUBSCRIBE_RESPONSE = 4_u8
MSG_TIMED_REQUEST = 10_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
Sourceencode_invoke_response(invoke_responses : Array(InteractionModel::InvokeResponseIB), suppress_response : Bool = false) : Bytes
Encode InvokeResponse using TLV::Serializable
Encode InvokeResponse from array of InvokeResponseIB
Sourceencode_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
Sourceencode_subscribe_response(subscription_id : UInt32, max_interval : UInt16) : Bytes
Sourceencode_write_response(write_responses : Array(InteractionModel::AttributeStatusIB)) : Bytes
Encode WriteResponse from array of AttributeStatusIB
Sourceinvoke_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
Sourceparse_invoke_request(payload : Bytes) : InteractionModel::InvokeRequestMessage | Nil
Parse InvokeRequest from decrypted TLV payload
Sourceparse_read_request(payload : Bytes) : InteractionModel::ReadRequestMessage | Nil
Parse ReadRequest from decrypted TLV payload
Sourceparse_subscribe_request(payload : Bytes) : InteractionModel::SubscribeRequestMessage | Nil
Parse SubscribeRequest from decrypted TLV payload
Sourceparse_write_request(payload : Bytes) : InteractionModel::WriteRequestMessage | Nil
Parse WriteRequest from decrypted TLV payload
Sourceread_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
Sourcewrite_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