This cluster provides an interface for controlling a single degree of freedom (also referred to as a “dimension” or an “axis” below) of a composed closure.
This directory contains a code-driven C++ implementation of the Matter Closure Dimension cluster server. This implementation (ClosureDimensionCluster.h) is designed for flexibility, avoiding the tight coupling present in older codegen-based implementations.
It uses a delegate pattern (chip::app::Clusters::ClosureDimension::ClosureDimensionClusterDelegate) to interact with the application's closure dimension logic and state management.
To integrate the ClosureDimensionCluster into your application, follow these steps:
Create a class that inherits from chip::app::Clusters::ClosureDimension::ClosureDimensionClusterDelegate and implement its virtual methods to handle commands and provide dimension state information.
#include "app/clusters/closure-dimension-server/ClosureDimensionClusterDelegate.h" class MyClosureDimensionDelegate : public chip::app::Clusters::ClosureDimension::ClosureDimensionClusterDelegate { };
Configure the cluster's feature map and optional attributes based on your device capabilities. The conformance must be valid before cluster creation (see “Conformance Validation” below).
#include "app/clusters/closure-dimension-server/ClosureDimensionCluster.h" chip::app::Clusters::ClosureDimension::ClusterConformance conformance; conformance.FeatureMap().Set(chip::app::Clusters::ClosureDimension::Feature::kPositioning); conformance.FeatureMap().Set(chip::app::Clusters::ClosureDimension::Feature::kMotionLatching); // Add other features as needed // Optional: Configure init parameters (translation / rotation / modulation when those features are enabled) chip::app::Clusters::ClosureDimension::ClusterInitParameters initParams; initParams.translationDirection = chip::app::Clusters::ClosureDimension::TranslationDirectionEnum::kDownward; // initParams.rotationAxis / initParams.modulationType when required
Instantiate your delegate and the ClosureDimensionCluster itself for each endpoint that requires it. Using RegisteredServerCluster simplifies registration.
#include "app/server-cluster/ServerClusterInterfaceRegistry.h" // In a .cpp file MyClosureDimensionDelegate gMyDelegate; chip::app::Clusters::ClosureDimension::ClosureDimensionCluster::Context clusterContext{ .delegate = gMyDelegate, .conformance = conformance, .initParams = initParams }; chip::app::RegisteredServerCluster<chip::app::Clusters::ClosureDimension::ClosureDimensionCluster> gClosureDimensionCluster( chip::EndpointId{ 2 }, clusterContext);
In your application's initialization sequence, register the cluster instance with the CodegenDataModelProvider. This hooks the cluster into the Matter data model and message processing framework.
#include "data-model-providers/codegen/CodegenDataModelProvider.h" void ApplicationInit() { // ... other initializations // Register cluster BEFORE server starts CHIP_ERROR err = chip::app::CodegenDataModelProvider::Instance().Registry().Register( gClosureDimensionCluster.Registration()); VerifyOrDie(err == CHIP_NO_ERROR); // ... server startup happens later }
For new applications using the code-driven cluster pattern:
Before Server Startup:
ClusterConformance with valid feature mapClusterInitParameters with initial stateCodegenDataModelProviderAfter Startup:
Legacy API Usage
The legacy classes ClusterLogic and MatterContext have been removed and are no longer required in the newer implementation.
Other APIs are retained for backward compatibility and remain accessible through the legacy Interface class through CodegenIntegration.h
The cluster performs strict conformance validation during construction. Any validation failure is fatal and will terminate the application with “Invalid Conformance” message
We recommend migrating to the new, direct instantiation method to improve performance and reduce your application's footprint.
The new approach is to instantiate the cluster directly and register it with the CodegenDataModelProvider, as detailed in the “Usage” section above.