module
Matter::Protocol::IMHandler
Overview
Helper module for Interaction Model message handling
Defined in:
matter/protocol/im_handler.crConstant Summary
-
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 Method Summary
-
.encode_chunked_report_data(response : InteractionModel::ReadResponse, 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
-
.encode_invoke_response(response : InteractionModel::InvokeResponse) : Bytes
Encode InvokeResponse using TLV::Serializable
-
.encode_read_response(response : InteractionModel::ReadResponse) : Bytes
Encode ReadResponse using TLV::Serializable structs
-
.encode_report_data(response : InteractionModel::ReadResponse, subscription_id : UInt32 | Nil = nil) : Bytes
Encode ReportData (used for both ReadResponse and initial subscription data)
-
.encode_subscribe_response(subscription_id : UInt32, max_interval : UInt16) : Bytes
Encode SubscribeResponse
-
.encode_write_response(response : InteractionModel::WriteResponse) : Bytes
Encode WriteResponse using TLV::Serializable
-
.invoke_commands(invoke_requests : Array(InteractionModel::CommandDataIB), clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base), session_id : UInt64 | Nil = nil, is_case_session : Bool = false, fabric_index : UInt8 | Nil = nil) : InteractionModel::InvokeResponse
Execute commands from invoke requests
-
.parse_invoke_request(payload : Bytes) : InteractionModel::InvokeRequest | Nil
Parse InvokeRequest from decrypted TLV payload
-
.parse_read_request(payload : Bytes) : InteractionModel::ReadRequest | Nil
Parse ReadRequest from decrypted TLV payload
-
.parse_subscribe_request(payload : Bytes) : InteractionModel::SubscribeRequest | Nil
Parse SubscribeRequest from decrypted TLV payload
-
.parse_write_request(payload : Bytes) : InteractionModel::WriteRequest | Nil
Parse WriteRequest from decrypted TLV payload
-
.read_attributes(attribute_requests : Array(InteractionModel::AttributePath), clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base), fabric_index : UInt8 | Nil = nil) : InteractionModel::ReadResponse
Read attributes from clusters The fabric_index parameter is used for fabric-scoped attributes like CurrentFabricIndex
-
.write_attributes(write_requests : Array(InteractionModel::AttributeWriteRequest), clusters : Hash(Tuple(UInt16, UInt32), Cluster::Base)) : InteractionModel::WriteResponse
Write attributes to clusters
Class Method Detail
Chunk attributes into multiple ReportData messages that fit within MTU Returns an array of (encoded_bytes, is_last_chunk) tuples
Encode InvokeResponse using TLV::Serializable
Encode ReadResponse using TLV::Serializable structs
Encode ReportData (used for both ReadResponse and initial subscription data)
Encode SubscribeResponse
Encode WriteResponse using TLV::Serializable
Execute commands from invoke requests
Parse InvokeRequest from decrypted TLV payload
Parse ReadRequest from decrypted TLV payload
Parse SubscribeRequest from decrypted TLV payload
Parse WriteRequest from decrypted TLV payload
Read attributes from clusters The fabric_index parameter is used for fabric-scoped attributes like CurrentFabricIndex
Write attributes to clusters