abstract class Matter::Cluster::Base

Overview

Base class for all cluster implementations

Direct Known Subclasses

Defined in:

matter/cluster/cluster.cr

Constant Summary

GLOBAL_ACCEPTED_COMMAND_LIST = 65529_u32
GLOBAL_ATTRIBUTE_LIST = 65531_u32

Global attribute IDs (mandatory on all clusters)

GLOBAL_CLUSTER_REVISION = 65533_u32
GLOBAL_FEATURE_MAP = 65532_u32
GLOBAL_GENERATED_COMMAND_LIST = 65528_u32

Constructors

Instance Method Summary

Constructor Detail

def self.new(endpoint_id : DataType::EndpointNumber, cluster_id : DataType::ClusterId) #

[View source]

Instance Method Detail

def apply_scene_extension_field_set(field_set : ScenesManagementCluster::ExtensionFieldSet) : Bool #

[View source]
abstract def attributes : Array(AttributeMetadata) #

Get all attribute metadata


[View source]
def cluster_id : DataType::ClusterId #

[View source]
def cluster_id=(cluster_id : DataType::ClusterId) #

[View source]
def commands : Array(CommandMetadata) #

Get all command metadata


[View source]
def data_version : UInt32 #

[View source]
def data_version=(data_version : UInt32) #

[View source]
def endpoint_id : DataType::EndpointNumber #

[View source]
def endpoint_id=(endpoint_id : DataType::EndpointNumber) #

[View source]
def events : Array(EventMetadata) #

Get all event metadata


[View source]
def get_attribute_metadata(attribute_id : UInt32) : AttributeMetadata | Nil #

Get attribute metadata by ID


[View source]
def get_command_metadata(command_id : UInt32) : CommandMetadata | Nil #

Get command metadata by ID


[View source]
def invoke_command(command_id : UInt32, fields : Bytes = Bytes.new(0), session_id : UInt64 | Nil = nil, is_case_session : Bool = false, fabric_index : UInt8 | Nil = nil) : InteractionModel::Status | CommandResponse #

Invoke a command


[View source]
abstract def name : String #

Get cluster name


[View source]
def on_attribute_changed : Proc(UInt16, UInt32, UInt32, Nil) | Nil #

Callback for attribute change notifications (used by subscription system) Parameters: endpoint_id, cluster_id, attribute_id


[View source]
def on_attribute_changed=(on_attribute_changed : Proc(UInt16, UInt32, UInt32, Nil) | Nil) #

Callback for attribute change notifications (used by subscription system) Parameters: endpoint_id, cluster_id, attribute_id


[View source]
def persistence_key : String #

Returns a unique key for this cluster instance for persistence Format: "endpoint_cluster"


[View source]
def read_attribute(attribute_id : UInt32, fabric_index : UInt8 | Nil = nil) : InteractionModel::Status | Bytes #

Read an attribute value The fabric_index parameter is optional and used for fabric-scoped attributes like CurrentFabricIndex in OperationalCredentialsCluster


[View source]
def request_fabric_index : UInt8 | Nil #

[View source]
def request_fabric_index=(request_fabric_index : UInt8 | Nil) #

[View source]
def request_is_case_session=(request_is_case_session : Bool) #

[View source]
def request_is_case_session? : Bool #

[View source]
def request_peer_node_id : UInt64 | Nil #

[View source]
def request_peer_node_id=(request_peer_node_id : UInt64 | Nil) #

[View source]
def request_session_id : UInt64 | Nil #

Request context (populated by the protocol layer for the current operation). These are intentionally prefixed to avoid colliding with cluster-specific state.


[View source]
def request_session_id=(request_session_id : UInt64 | Nil) #

Request context (populated by the protocol layer for the current operation). These are intentionally prefixed to avoid colliding with cluster-specific state.


[View source]
def restore_state(json : String) : Nil #

Restore cluster state from JSON. Override in subclasses that need to restore state. The json parameter is the string returned by save_state.


[View source]
def save_state : String | Nil #

Save cluster state to JSON for persistence. Override in subclasses that need to persist state (e.g., scenes, groups). Returns nil if no state needs to be persisted.


[View source]
def store_scene_extension_field_set : ScenesManagementCluster::ExtensionFieldSet | Nil #

Scenes Management hooks

ScenesManagementCluster (0x0062) stores "extension field sets" that capture cluster-specific state for scene recall. Clusters can override these hooks to participate; default implementations are no-ops.

The Device base class wires ScenesManagementCluster callbacks by calling these methods on clusters present on the same endpoint.


[View source]
def write_attribute(attribute_id : UInt32, value : Bytes) : InteractionModel::Status #

Write an attribute value


[View source]