diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-server.cpp b/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.cpp similarity index 98% rename from src/app/clusters/closure-dimension-server/closure-dimension-server.cpp rename to src/app/clusters/closure-dimension-server/ClosureDimensionCluster.cpp index 8c0001fb9df45d..ee21a41015b9c1 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-server.cpp +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.cpp @@ -16,8 +16,8 @@ * */ -#include "closure-dimension-server.h" -#include "closure-dimension-cluster-logic.h" +#include "ClosureDimensionCluster.h" +#include "ClosureDimensionClusterLogic.h" namespace chip { namespace app { diff --git a/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.h b/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.h new file mode 100644 index 00000000000000..4648b567fef93d --- /dev/null +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.h @@ -0,0 +1,71 @@ +/** + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#pragma once +#include "ClosureDimensionClusterLogic.h" + +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ClosureDimension { + +/** + * @brief Class implements the client facing APIs to read, write and process incoming commands + * App should instantiate and init one Interface per endpoint + */ +class Interface : public AttributeAccessInterface, public CommandHandlerInterface +{ +public: + Interface(EndpointId endpoint, ClusterLogic & clusterLogic) : + AttributeAccessInterface(Optional(endpoint), Id), CommandHandlerInterface(Optional(endpoint), Id), + mClusterLogic(clusterLogic) + {} + + // AttributeAccessInterface implementation + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + + // CommandHandlerInterface implementation + + void InvokeCommand(HandlerContext & handlerContext) override; + + /** + * @brief This function registers attribute access and command handler. + * @return CHIP_NO_ERROR when succesfully initialized. + * Aborts if registration fails. + */ + CHIP_ERROR Init(); + + /** + * @brief This function unregisters attribute access and command handlers. + * @return CHIP_NO_ERROR when succesfully initialized + * Aborts if attribute access unregistration fails. + */ + CHIP_ERROR Shutdown(); + +private: + // This is owned by the caller and passed to the interface for its use. + ClusterLogic & mClusterLogic; +}; + +} // namespace ClosureDimension +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/closure-dimension-server/ClosureDimensionClusterDelegate.h b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterDelegate.h new file mode 100644 index 00000000000000..f66071d55d6e54 --- /dev/null +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterDelegate.h @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ClosureDimension { + +/** @brief + * Defines methods for implementing application-specific logic for the Closure Dimension Cluster. + */ + +class DelegateBase +{ +public: + DelegateBase(){}; + virtual ~DelegateBase() = default; + + /** + * @brief This function handles SetTarget command implementaion. + * + * @param [in] position TargetState position to be set + * @param [in] latch TargetState Latch to be set + * @param [in] speed TargetState speed to be set + * + * @return Success when succesfully handled. + * Error when handle SetTarget fails. + */ + virtual Protocols::InteractionModel::Status HandleSetTarget(const Optional & position, + const Optional & latch, + const Optional & speed) = 0; + + /** + * @brief This function handles Step command implementaion. + * + * @param [in] direction step direction + * @param [in] numberOfSteps total number of steps + * @param [in] speed speed of each step + * + * @return Success when successfully handled. + * Error when handle Step fails. + */ + virtual Protocols::InteractionModel::Status HandleStep(const StepDirectionEnum & direction, const uint16_t & numberOfSteps, + const Optional & speed) = 0; +}; + +} // namespace ClosureDimension +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.cpp b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.cpp similarity index 99% rename from src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.cpp rename to src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.cpp index 9cbb139d303ee3..5db094dfbd0d05 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.cpp +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.cpp @@ -18,7 +18,7 @@ * @file Cross-platform API to handle cluster-specific logic for the closure dimension cluster on a single endpoint. */ -#include "closure-dimension-cluster-logic.h" +#include "ClosureDimensionClusterLogic.h" #include #include diff --git a/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.h b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.h new file mode 100644 index 00000000000000..66f944f4eff527 --- /dev/null +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.h @@ -0,0 +1,365 @@ +/** + * + * Copyright (c) 2025 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ClosureDimensionClusterDelegate.h" +#include "ClosureDimensionClusterMatterContext.h" +#include "GenericDimensionState.h" +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ClosureDimension { + +/** + * @brief Structure is used to configure and validate the Cluster configuration. + * Validates if the feature map, attributes and commands configuration is valid. + */ +struct ClusterConformance +{ + BitFlags & FeatureMap() { return mFeatureMap; } + const BitFlags & FeatureMap() const { return mFeatureMap; } + + inline bool HasFeature(Feature aFeature) const { return mFeatureMap.Has(aFeature); } + + /** + * @brief Function determines if Cluster conformance is valid + * + * The function executes these checks in order to validate the conformance + * 1. Check if either Positioning or MotionLatching is supported. If neither are enabled, returns false. + * 2. If Unit, Limitation or speed is enabled, Positioning must be enabled. Return false otherwise. + * 3. If Translation, Rotation or Modulation is enabled, Positioning must be enabled. Return false otherwise. + * 4. Only one of Translation, Rotation or Modulation must be enabled. Return false otherwise. + * 5. If the Overflow attribute is supported, at least one of Rotation or MotionLatching feature must be supported. + * Return false otherwise. + * 6. If Rotation feature is enabled, then the Overflow attribute must be supported. Return false otherwise. + * + * @return true, the cluster confirmance is valid + * false, otherwise + */ + bool Valid() const + { + // Positioning or Matching must be enabled + VerifyOrReturnValue(HasFeature(Feature::kPositioning) || HasFeature(Feature::kMotionLatching), false, + ChipLogError(AppServer, "Validation failed: Neither Positioning nor MotionLatching is enabled.")); + + // If Unit, Limitation or speed is enabled, Positioning must be enabled + if (HasFeature(Feature::kUnit) || HasFeature(Feature::kLimitation) || HasFeature(Feature::kSpeed)) + { + VerifyOrReturnValue( + HasFeature(Feature::kPositioning), false, + ChipLogError(AppServer, "Validation failed: Unit , Limitation, and speed requires the Positioning feature.")); + } + + // If Translation, Rotation or Modulation is enabled, Positioning must be enabled. + if (HasFeature(Feature::kTranslation) || HasFeature(Feature::kRotation) || HasFeature(Feature::kModulation)) + { + VerifyOrReturnValue( + HasFeature(Feature::kPositioning), false, + ChipLogError(NotSpecified, "Validation failed: Translation, Rotation or Modulation requires Positioning enabled.")); + } + + // Only one of Translation, Rotation or Modulation features must be enabled. Return false otherwise. + if ((HasFeature(Feature::kTranslation) && HasFeature(Feature::kRotation)) || + (HasFeature(Feature::kRotation) && HasFeature(Feature::kModulation)) || + (HasFeature(Feature::kModulation) && HasFeature(Feature::kTranslation))) + { + ChipLogError(AppServer, "Validation failed: Only one of Translation, Rotation or Modulation feature can be enabled."); + return false; + } + return true; + } + +private: + BitFlags mFeatureMap; +}; + +/** + * @brief Struct to store the cluster Initilization parameters + */ +struct ClusterInitParameters +{ + TranslationDirectionEnum translationDirection = TranslationDirectionEnum::kUnknownEnumValue; + RotationAxisEnum rotationAxis = RotationAxisEnum::kUnknownEnumValue; + ModulationTypeEnum modulationType = ModulationTypeEnum::kUnknownEnumValue; +}; + +/** + * @brief Struct to store the current cluster state + */ +struct ClusterState +{ + DataModel::Nullable currentState{ DataModel::NullNullable }; + DataModel::Nullable targetState{ DataModel::NullNullable }; + Percent100ths resolution = 1; + Percent100ths stepValue = 1; + ClosureUnitEnum unit = ClosureUnitEnum::kUnknownEnumValue; + DataModel::Nullable unitRange = DataModel::Nullable(); + Structs::RangePercent100thsStruct::Type limitRange{}; + TranslationDirectionEnum translationDirection = TranslationDirectionEnum::kUnknownEnumValue; + RotationAxisEnum rotationAxis = RotationAxisEnum::kUnknownEnumValue; + OverflowEnum overflow = OverflowEnum::kUnknownEnumValue; + ModulationTypeEnum modulationType = ModulationTypeEnum::kUnknownEnumValue; + BitFlags latchControlModes; +}; + +class ClusterLogic +{ +public: + /** + * @brief Instantiates a ClusterLogic class. The caller maintains ownership of the driver and the context, + * but provides them for use by the ClusterLogic class. + */ + ClusterLogic(DelegateBase & delegate, MatterContext & matterContext) : mDelegate(delegate), mMatterContext(matterContext) {} + + const ClusterState & GetState() { return mState; } + const ClusterConformance & GetConformance() { return mConformance; } + + /** + * @brief Validates the conformance and performs initialisation and sets up the ClusterInitParameters into Attributes. + * + * @param [in] conformance cluster conformance + * @param [in] clusterInitParameters cluster Init Parameters + * + * @return CHIP_ERROR_INCORRECT_STATE if the cluster has already been initialized, + * CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR if the conformance is incorrect. + * Set function errors if setting the attributes with the provided ClusterInitParameters fails. + * CHIP_NO_ERROR on succesful initialisation. + */ + CHIP_ERROR Init(const ClusterConformance & conformance, const ClusterInitParameters & clusterInitParameters); + + /** + * @brief Set Current State. + * + * @param[in] currentState Current State Position, Latch and Speed. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + */ + CHIP_ERROR SetCurrentState(const DataModel::Nullable & currentState); + + /** + * @brief Set TargetState. + * + * @param[in] targetState TargetState Position, Latch and Speed. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + */ + CHIP_ERROR SetTargetState(const DataModel::Nullable & targetState); + + /** + * @brief Set Resolution. + * + * @param[in] resolution Minimal acceptable change of Position fields of attributes. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetResolution(const Percent100ths resolution); + + /** + * @brief Set StepValue. + * + * @param[in] stepValue One step value for Step command + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetStepValue(const Percent100ths stepValue); + + /** + * @brief Set Unit. + * + * @param[in] unit Unit related to the Positioning. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetUnit(const ClosureUnitEnum unit); + + /** + * @brief Set UnitRange. + * + * @param[in] unitRange Minimum and Maximum values expressed by positioning following the unit. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetUnitRange(const DataModel::Nullable & unitRange); + + /** + * @brief Set LimitRange. + * + * @param[in] limitRange Range of possible values for the position field in Current attribute. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetLimitRange(const Structs::RangePercent100thsStruct::Type & limitRange); + + /** + * @brief Set Overflow. + * + * @param[in] overflow Overflow related to Rotation. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + */ + CHIP_ERROR SetOverflow(const OverflowEnum overflow); + + /** + * @brief Sets the latch control modes for the closure dimension cluster. + * + * This method updates the latch control modes using the provided bit flags. + * + * @param latchControlModes BitFlags representing the desired latch control modes. + * @return CHIP_ERROR Returns CHIP_NO_ERROR on success, or an appropriate error code on failure. + */ + CHIP_ERROR SetLatchControlModes(const BitFlags & latchControlModes); + + // All Get functions: + // Return CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. + // Return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if the attribute is not supported. + // Otherwise return CHIP_NO_ERROR and set the input parameter value to the current cluster state value + CHIP_ERROR GetCurrentState(DataModel::Nullable & currentState); + CHIP_ERROR GetTargetState(DataModel::Nullable & targetState); + CHIP_ERROR GetResolution(Percent100ths & resolution); + CHIP_ERROR GetStepValue(Percent100ths & stepValue); + CHIP_ERROR GetUnit(ClosureUnitEnum & unit); + CHIP_ERROR GetUnitRange(DataModel::Nullable & unitRange); + CHIP_ERROR GetLimitRange(Structs::RangePercent100thsStruct::Type & limitRange); + CHIP_ERROR GetTranslationDirection(TranslationDirectionEnum & translationDirection); + CHIP_ERROR GetRotationAxis(RotationAxisEnum & rotationAxis); + CHIP_ERROR GetOverflow(OverflowEnum & overflow); + CHIP_ERROR GetModulationType(ModulationTypeEnum & modulationType); + CHIP_ERROR GetLatchControlModes(BitFlags & latchControlModes); + CHIP_ERROR GetFeatureMap(BitFlags & featureMap); + CHIP_ERROR GetClusterRevision(Attributes::ClusterRevision::TypeInfo::Type & clusterRevision); + + /** + * @brief Calls delegate HandleSetTarget function after validating the parameters and conformance. + * + * @param [in] position TargetState position + * @param [in] latch TargetState latch + * @param [in] speed TargetState speed + * + * @return Exits if the cluster is not initialized. + * InvalidCommand if none of the input parameters are present. + * ConstraintError if the input values are out is out of range. + * InvalidInState if the current position of closure is not known. + * Success on succesful handling. + */ + Protocols::InteractionModel::Status HandleSetTargetCommand(Optional position, Optional latch, + Optional speed); + + /** + * @brief Calls delegate HandleStep function after validating the parameters and conformance. + * + * @param [in] direction step direction + * @param [in] numberOfSteps Number of steps + * @param [in] speed step speed + * + * @return Exits if the cluster is not initialized. + * UnsupportedCommand if Positioning feature is not supported. + * ConstraintError if the input values are out is out of range. + * InvalidInState if the current position of closure is not known. + * Success on successful handling. + */ + Protocols::InteractionModel::Status HandleStepCommand(StepDirectionEnum direction, uint16_t numberOfSteps, + Optional speed); + +private: + /** + * @brief Set TranslationDirection. + * This attribute is not supposed to change once the installation is finalized. + * SetTranslationDirection should only be called from Init() + * + * @param[in] translationDirection Direction of the translation. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported + * + */ + CHIP_ERROR SetTranslationDirection(const TranslationDirectionEnum translationDirection); + + /** + * @brief Set RotationAxis. + * This attribute is not supposed to change once the installation is finalized. + * so SetRotationAxis should only be called from Init(). + * + * @param[in] rotationAxis Axis of the rotation. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported + * + */ + CHIP_ERROR SetRotationAxis(const RotationAxisEnum rotationAxis); + + /** + * @brief Set ModulationType. + * This attribute is not supposed to change once the installation is finalized. + * so SetModulationType should only be called from Init(). + * + * @param[in] modulationType Modulation type. + * + * @return CHIP_NO_ERROR if set was successful. + * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid + * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized + * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. + * + */ + CHIP_ERROR SetModulationType(const ModulationTypeEnum modulationType); + + bool mInitialized = false; + ClusterState mState; + ClusterConformance mConformance; + DelegateBase & mDelegate; + MatterContext & mMatterContext; + + // At Present, QuieterReportingAttribute doesnt support Structs. + // So, this variable will be used for Quietreporting of current state position. + // TODO: Refactor CurrentState Atrribute to use QuieterReportingAttribute once Issue#39801 is resolved + QuieterReportingAttribute quietReportableCurrentStatePosition{ DataModel::NullNullable }; +}; + +} // namespace ClosureDimension +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.cpp b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.cpp similarity index 96% rename from src/app/clusters/closure-dimension-server/closure-dimension-matter-context.cpp rename to src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.cpp index 8ccdfe3f5d80ad..c579eb42fca793 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.cpp +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "closure-dimension-matter-context.h" +#include "ClosureDimensionClusterMatterContext.h" #include #include #include diff --git a/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.h b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.h new file mode 100644 index 00000000000000..b047cd3720c742 --- /dev/null +++ b/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ClosureDimension { + +/** @brief + * Interface to allow interaction with interaction model and ember layers. Can be faked for unit testing. + */ +class MatterContext +{ +public: + MatterContext(EndpointId endpoint) : mEndpoint(endpoint) {} + + /** + * @brief calls the attribute change callback + * @param[in] attributeId Attribute ID whose value needs to be marked dirty. + */ + virtual void MarkDirty(AttributeId attributeId); + + virtual ~MatterContext() = default; + + EndpointId GetEndpointId() const { return mEndpoint; } + +private: + EndpointId mEndpoint; +}; + +} // namespace ClosureDimension +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/closure-dimension-server/CodegenIntegration.h b/src/app/clusters/closure-dimension-server/CodegenIntegration.h new file mode 100644 index 00000000000000..a1b0c072a9d2b4 --- /dev/null +++ b/src/app/clusters/closure-dimension-server/CodegenIntegration.h @@ -0,0 +1,20 @@ +/** + * + * Copyright (c) 2026 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include diff --git a/src/app/clusters/closure-dimension-server/GenericDimensionState.h b/src/app/clusters/closure-dimension-server/GenericDimensionState.h new file mode 100644 index 00000000000000..72bb22eeb9b2cd --- /dev/null +++ b/src/app/clusters/closure-dimension-server/GenericDimensionState.h @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2025 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace ClosureDimension { + +/** + * Structure represents the current state struct of a closure dimension cluster derivation instance. + */ +struct GenericDimensionStateStruct : public Structs::DimensionStateStruct::Type +{ + GenericDimensionStateStruct(Optional> positionValue = NullOptional, + Optional> latchValue = NullOptional, + Optional speedValue = NullOptional) + { + Set(positionValue, latchValue, speedValue); + } + + GenericDimensionStateStruct(const GenericDimensionStateStruct & currentState) { *this = currentState; } + + GenericDimensionStateStruct & operator=(const GenericDimensionStateStruct & current) + { + Set(current.position, current.latch, current.speed); + return *this; + } + + void Set(Optional> positionValue = NullOptional, + Optional> latchValue = NullOptional, + Optional speedValue = NullOptional) + { + position = positionValue; + latch = latchValue; + speed = speedValue; + } + + bool operator==(const GenericDimensionStateStruct & rhs) const + { + return position == rhs.position && latch == rhs.latch && speed == rhs.speed; + } + + bool operator!=(const GenericDimensionStateStruct & rhs) const + { + return position != rhs.position || latch != rhs.latch || speed != rhs.speed; + } +}; +} // namespace ClosureDimension +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/src/app/clusters/closure-dimension-server/app_config_dependent_sources.cmake b/src/app/clusters/closure-dimension-server/app_config_dependent_sources.cmake index d4378d502bdda4..0cb5fcaa496f64 100644 --- a/src/app/clusters/closure-dimension-server/app_config_dependent_sources.cmake +++ b/src/app/clusters/closure-dimension-server/app_config_dependent_sources.cmake @@ -16,12 +16,12 @@ TARGET_SOURCES( ${APP_TARGET} PRIVATE - "${CLUSTER_DIR}/closure-dimension-cluster-logic.cpp" + "${CLUSTER_DIR}/ClosureDimensionClusterLogic.cpp" "${CLUSTER_DIR}/closure-dimension-cluster-logic.h" "${CLUSTER_DIR}/closure-dimension-cluster-objects.h" "${CLUSTER_DIR}/closure-dimension-delegate.h" - "${CLUSTER_DIR}/closure-dimension-matter-context.cpp" + "${CLUSTER_DIR}/ClosureDimensionClusterMatterContext.cpp" "${CLUSTER_DIR}/closure-dimension-matter-context.h" - "${CLUSTER_DIR}/closure-dimension-server.cpp" + "${CLUSTER_DIR}/ClosureDimensionCluster.cpp" "${CLUSTER_DIR}/closure-dimension-server.h" ) \ No newline at end of file diff --git a/src/app/clusters/closure-dimension-server/app_config_dependent_sources.gni b/src/app/clusters/closure-dimension-server/app_config_dependent_sources.gni index 4770782d2cd455..49c9b98ca7b0d7 100644 --- a/src/app/clusters/closure-dimension-server/app_config_dependent_sources.gni +++ b/src/app/clusters/closure-dimension-server/app_config_dependent_sources.gni @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. app_config_dependent_sources = [ - "closure-dimension-cluster-logic.cpp", + "ClosureDimensionCluster.cpp", + "ClosureDimensionClusterLogic.cpp", + "ClosureDimensionClusterMatterContext.cpp", "closure-dimension-cluster-logic.h", "closure-dimension-cluster-objects.h", "closure-dimension-delegate.h", - "closure-dimension-matter-context.cpp", "closure-dimension-matter-context.h", - "closure-dimension-server.cpp", "closure-dimension-server.h", ] diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h b/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h index 6e774319fff435..42939671f589c4 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h +++ b/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h @@ -1,6 +1,6 @@ /** * - * Copyright (c) 2025 Project CHIP Authors + * Copyright (c) 2026 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,355 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @file Cross-platform API to handle cluster-specific logic for the valve configuration and control cluster on a single endpoint. - */ #pragma once -#include "closure-dimension-cluster-objects.h" -#include "closure-dimension-delegate.h" -#include "closure-dimension-matter-context.h" -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace ClosureDimension { - -/** - * @brief Structure is used to configure and validate the Cluster configuration. - * Validates if the feature map, attributes and commands configuration is valid. - */ -struct ClusterConformance -{ - BitFlags & FeatureMap() { return mFeatureMap; } - const BitFlags & FeatureMap() const { return mFeatureMap; } - - inline bool HasFeature(Feature aFeature) const { return mFeatureMap.Has(aFeature); } - - /** - * @brief Function determines if Cluster conformance is valid - * - * The function executes these checks in order to validate the conformance - * 1. Check if either Positioning or MotionLatching is supported. If neither are enabled, returns false. - * 2. If Unit, Limitation or speed is enabled, Positioning must be enabled. Return false otherwise. - * 3. If Translation, Rotation or Modulation is enabled, Positioning must be enabled. Return false otherwise. - * 4. Only one of Translation, Rotation or Modulation must be enabled. Return false otherwise. - * 5. If the Overflow attribute is supported, at least one of Rotation or MotionLatching feature must be supported. - * Return false otherwise. - * 6. If Rotation feature is enabled, then the Overflow attribute must be supported. Return false otherwise. - * - * @return true, the cluster confirmance is valid - * false, otherwise - */ - bool Valid() const - { - // Positioning or Matching must be enabled - VerifyOrReturnValue(HasFeature(Feature::kPositioning) || HasFeature(Feature::kMotionLatching), false, - ChipLogError(AppServer, "Validation failed: Neither Positioning nor MotionLatching is enabled.")); - - // If Unit, Limitation or speed is enabled, Positioning must be enabled - if (HasFeature(Feature::kUnit) || HasFeature(Feature::kLimitation) || HasFeature(Feature::kSpeed)) - { - VerifyOrReturnValue( - HasFeature(Feature::kPositioning), false, - ChipLogError(AppServer, "Validation failed: Unit , Limitation, and speed requires the Positioning feature.")); - } - - // If Translation, Rotation or Modulation is enabled, Positioning must be enabled. - if (HasFeature(Feature::kTranslation) || HasFeature(Feature::kRotation) || HasFeature(Feature::kModulation)) - { - VerifyOrReturnValue( - HasFeature(Feature::kPositioning), false, - ChipLogError(NotSpecified, "Validation failed: Translation, Rotation or Modulation requires Positioning enabled.")); - } - - // Only one of Translation, Rotation or Modulation features must be enabled. Return false otherwise. - if ((HasFeature(Feature::kTranslation) && HasFeature(Feature::kRotation)) || - (HasFeature(Feature::kRotation) && HasFeature(Feature::kModulation)) || - (HasFeature(Feature::kModulation) && HasFeature(Feature::kTranslation))) - { - ChipLogError(AppServer, "Validation failed: Only one of Translation, Rotation or Modulation feature can be enabled."); - return false; - } - return true; - } - -private: - BitFlags mFeatureMap; -}; - -/** - * @brief Struct to store the cluster Initilization parameters - */ -struct ClusterInitParameters -{ - TranslationDirectionEnum translationDirection = TranslationDirectionEnum::kUnknownEnumValue; - RotationAxisEnum rotationAxis = RotationAxisEnum::kUnknownEnumValue; - ModulationTypeEnum modulationType = ModulationTypeEnum::kUnknownEnumValue; -}; - -/** - * @brief Struct to store the current cluster state - */ -struct ClusterState -{ - DataModel::Nullable currentState{ DataModel::NullNullable }; - DataModel::Nullable targetState{ DataModel::NullNullable }; - Percent100ths resolution = 1; - Percent100ths stepValue = 1; - ClosureUnitEnum unit = ClosureUnitEnum::kUnknownEnumValue; - DataModel::Nullable unitRange = DataModel::Nullable(); - Structs::RangePercent100thsStruct::Type limitRange{}; - TranslationDirectionEnum translationDirection = TranslationDirectionEnum::kUnknownEnumValue; - RotationAxisEnum rotationAxis = RotationAxisEnum::kUnknownEnumValue; - OverflowEnum overflow = OverflowEnum::kUnknownEnumValue; - ModulationTypeEnum modulationType = ModulationTypeEnum::kUnknownEnumValue; - BitFlags latchControlModes; -}; - -class ClusterLogic -{ -public: - /** - * @brief Instantiates a ClusterLogic class. The caller maintains ownership of the driver and the context, - * but provides them for use by the ClusterLogic class. - */ - ClusterLogic(DelegateBase & delegate, MatterContext & matterContext) : mDelegate(delegate), mMatterContext(matterContext) {} - - const ClusterState & GetState() { return mState; } - const ClusterConformance & GetConformance() { return mConformance; } - - /** - * @brief Validates the conformance and performs initialisation and sets up the ClusterInitParameters into Attributes. - * - * @param [in] conformance cluster conformance - * @param [in] clusterInitParameters cluster Init Parameters - * - * @return CHIP_ERROR_INCORRECT_STATE if the cluster has already been initialized, - * CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR if the conformance is incorrect. - * Set function errors if setting the attributes with the provided ClusterInitParameters fails. - * CHIP_NO_ERROR on succesful initialisation. - */ - CHIP_ERROR Init(const ClusterConformance & conformance, const ClusterInitParameters & clusterInitParameters); - - /** - * @brief Set Current State. - * - * @param[in] currentState Current State Position, Latch and Speed. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - */ - CHIP_ERROR SetCurrentState(const DataModel::Nullable & currentState); - - /** - * @brief Set TargetState. - * - * @param[in] targetState TargetState Position, Latch and Speed. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - */ - CHIP_ERROR SetTargetState(const DataModel::Nullable & targetState); - - /** - * @brief Set Resolution. - * - * @param[in] resolution Minimal acceptable change of Position fields of attributes. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetResolution(const Percent100ths resolution); - - /** - * @brief Set StepValue. - * - * @param[in] stepValue One step value for Step command - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetStepValue(const Percent100ths stepValue); - - /** - * @brief Set Unit. - * - * @param[in] unit Unit related to the Positioning. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetUnit(const ClosureUnitEnum unit); - - /** - * @brief Set UnitRange. - * - * @param[in] unitRange Minimum and Maximum values expressed by positioning following the unit. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetUnitRange(const DataModel::Nullable & unitRange); - - /** - * @brief Set LimitRange. - * - * @param[in] limitRange Range of possible values for the position field in Current attribute. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetLimitRange(const Structs::RangePercent100thsStruct::Type & limitRange); - - /** - * @brief Set Overflow. - * - * @param[in] overflow Overflow related to Rotation. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - */ - CHIP_ERROR SetOverflow(const OverflowEnum overflow); - - /** - * @brief Sets the latch control modes for the closure dimension cluster. - * - * This method updates the latch control modes using the provided bit flags. - * - * @param latchControlModes BitFlags representing the desired latch control modes. - * @return CHIP_ERROR Returns CHIP_NO_ERROR on success, or an appropriate error code on failure. - */ - CHIP_ERROR SetLatchControlModes(const BitFlags & latchControlModes); - - // All Get functions: - // Return CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized. - // Return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if the attribute is not supported. - // Otherwise return CHIP_NO_ERROR and set the input parameter value to the current cluster state value - CHIP_ERROR GetCurrentState(DataModel::Nullable & currentState); - CHIP_ERROR GetTargetState(DataModel::Nullable & targetState); - CHIP_ERROR GetResolution(Percent100ths & resolution); - CHIP_ERROR GetStepValue(Percent100ths & stepValue); - CHIP_ERROR GetUnit(ClosureUnitEnum & unit); - CHIP_ERROR GetUnitRange(DataModel::Nullable & unitRange); - CHIP_ERROR GetLimitRange(Structs::RangePercent100thsStruct::Type & limitRange); - CHIP_ERROR GetTranslationDirection(TranslationDirectionEnum & translationDirection); - CHIP_ERROR GetRotationAxis(RotationAxisEnum & rotationAxis); - CHIP_ERROR GetOverflow(OverflowEnum & overflow); - CHIP_ERROR GetModulationType(ModulationTypeEnum & modulationType); - CHIP_ERROR GetLatchControlModes(BitFlags & latchControlModes); - CHIP_ERROR GetFeatureMap(BitFlags & featureMap); - CHIP_ERROR GetClusterRevision(Attributes::ClusterRevision::TypeInfo::Type & clusterRevision); - - /** - * @brief Calls delegate HandleSetTarget function after validating the parameters and conformance. - * - * @param [in] position TargetState position - * @param [in] latch TargetState latch - * @param [in] speed TargetState speed - * - * @return Exits if the cluster is not initialized. - * InvalidCommand if none of the input parameters are present. - * ConstraintError if the input values are out is out of range. - * InvalidInState if the current position of closure is not known. - * Success on succesful handling. - */ - Protocols::InteractionModel::Status HandleSetTargetCommand(Optional position, Optional latch, - Optional speed); - - /** - * @brief Calls delegate HandleStep function after validating the parameters and conformance. - * - * @param [in] direction step direction - * @param [in] numberOfSteps Number of steps - * @param [in] speed step speed - * - * @return Exits if the cluster is not initialized. - * UnsupportedCommand if Positioning feature is not supported. - * ConstraintError if the input values are out is out of range. - * InvalidInState if the current position of closure is not known. - * Success on successful handling. - */ - Protocols::InteractionModel::Status HandleStepCommand(StepDirectionEnum direction, uint16_t numberOfSteps, - Optional speed); - -private: - /** - * @brief Set TranslationDirection. - * This attribute is not supposed to change once the installation is finalized. - * SetTranslationDirection should only be called from Init() - * - * @param[in] translationDirection Direction of the translation. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported - * - */ - CHIP_ERROR SetTranslationDirection(const TranslationDirectionEnum translationDirection); - - /** - * @brief Set RotationAxis. - * This attribute is not supposed to change once the installation is finalized. - * so SetRotationAxis should only be called from Init(). - * - * @param[in] rotationAxis Axis of the rotation. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported - * - */ - CHIP_ERROR SetRotationAxis(const RotationAxisEnum rotationAxis); - - /** - * @brief Set ModulationType. - * This attribute is not supposed to change once the installation is finalized. - * so SetModulationType should only be called from Init(). - * - * @param[in] modulationType Modulation type. - * - * @return CHIP_NO_ERROR if set was successful. - * CHIP_ERROR_INVALID_ARGUMENT if argument are not valid - * CHIP_ERROR_INCORRECT_STATE if the cluster has not been initialized - * CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if feature is not supported. - * - */ - CHIP_ERROR SetModulationType(const ModulationTypeEnum modulationType); - - bool mInitialized = false; - ClusterState mState; - ClusterConformance mConformance; - DelegateBase & mDelegate; - MatterContext & mMatterContext; - - // At Present, QuieterReportingAttribute doesnt support Structs. - // So, this variable will be used for Quietreporting of current state position. - // TODO: Refactor CurrentState Atrribute to use QuieterReportingAttribute once Issue#39801 is resolved - QuieterReportingAttribute quietReportableCurrentStatePosition{ DataModel::NullNullable }; -}; - -} // namespace ClosureDimension -} // namespace Clusters -} // namespace app -} // namespace chip +#include diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h b/src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h index 72bb22eeb9b2cd..cf30af8b911e05 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h +++ b/src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2025 Project CHIP Authors + * Copyright (c) 2026 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,53 +18,4 @@ #pragma once -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace ClosureDimension { - -/** - * Structure represents the current state struct of a closure dimension cluster derivation instance. - */ -struct GenericDimensionStateStruct : public Structs::DimensionStateStruct::Type -{ - GenericDimensionStateStruct(Optional> positionValue = NullOptional, - Optional> latchValue = NullOptional, - Optional speedValue = NullOptional) - { - Set(positionValue, latchValue, speedValue); - } - - GenericDimensionStateStruct(const GenericDimensionStateStruct & currentState) { *this = currentState; } - - GenericDimensionStateStruct & operator=(const GenericDimensionStateStruct & current) - { - Set(current.position, current.latch, current.speed); - return *this; - } - - void Set(Optional> positionValue = NullOptional, - Optional> latchValue = NullOptional, - Optional speedValue = NullOptional) - { - position = positionValue; - latch = latchValue; - speed = speedValue; - } - - bool operator==(const GenericDimensionStateStruct & rhs) const - { - return position == rhs.position && latch == rhs.latch && speed == rhs.speed; - } - - bool operator!=(const GenericDimensionStateStruct & rhs) const - { - return position != rhs.position || latch != rhs.latch || speed != rhs.speed; - } -}; -} // namespace ClosureDimension -} // namespace Clusters -} // namespace app -} // namespace chip +#include diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-delegate.h b/src/app/clusters/closure-dimension-server/closure-dimension-delegate.h index 487452a4e2dbf1..fe424f545cddc8 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-delegate.h +++ b/src/app/clusters/closure-dimension-server/closure-dimension-delegate.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2025 Project CHIP Authors + * Copyright (c) 2026 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,54 +18,4 @@ #pragma once -#include -#include -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace ClosureDimension { - -/** @brief - * Defines methods for implementing application-specific logic for the Closure Dimension Cluster. - */ - -class DelegateBase -{ -public: - DelegateBase(){}; - virtual ~DelegateBase() = default; - - /** - * @brief This function handles SetTarget command implementaion. - * - * @param [in] position TargetState position to be set - * @param [in] latch TargetState Latch to be set - * @param [in] speed TargetState speed to be set - * - * @return Success when succesfully handled. - * Error when handle SetTarget fails. - */ - virtual Protocols::InteractionModel::Status HandleSetTarget(const Optional & position, - const Optional & latch, - const Optional & speed) = 0; - - /** - * @brief This function handles Step command implementaion. - * - * @param [in] direction step direction - * @param [in] numberOfSteps total number of steps - * @param [in] speed speed of each step - * - * @return Success when successfully handled. - * Error when handle Step fails. - */ - virtual Protocols::InteractionModel::Status HandleStep(const StepDirectionEnum & direction, const uint16_t & numberOfSteps, - const Optional & speed) = 0; -}; - -} // namespace ClosureDimension -} // namespace Clusters -} // namespace app -} // namespace chip +#include diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.h b/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.h index b047cd3720c742..a0c0c662b5234d 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.h +++ b/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2024 Project CHIP Authors + * Copyright (c) 2026 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,37 +18,4 @@ #pragma once -#include -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace ClosureDimension { - -/** @brief - * Interface to allow interaction with interaction model and ember layers. Can be faked for unit testing. - */ -class MatterContext -{ -public: - MatterContext(EndpointId endpoint) : mEndpoint(endpoint) {} - - /** - * @brief calls the attribute change callback - * @param[in] attributeId Attribute ID whose value needs to be marked dirty. - */ - virtual void MarkDirty(AttributeId attributeId); - - virtual ~MatterContext() = default; - - EndpointId GetEndpointId() const { return mEndpoint; } - -private: - EndpointId mEndpoint; -}; - -} // namespace ClosureDimension -} // namespace Clusters -} // namespace app -} // namespace chip +#include diff --git a/src/app/clusters/closure-dimension-server/closure-dimension-server.h b/src/app/clusters/closure-dimension-server/closure-dimension-server.h index 2d32ca1cdc1542..ce2c02846ba84b 100644 --- a/src/app/clusters/closure-dimension-server/closure-dimension-server.h +++ b/src/app/clusters/closure-dimension-server/closure-dimension-server.h @@ -1,6 +1,6 @@ /** * - * Copyright (c) 2025 Project CHIP Authors + * Copyright (c) 2026 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,56 +16,5 @@ * */ #pragma once -#include "closure-dimension-cluster-logic.h" -#include -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace ClosureDimension { - -/** - * @brief Class implements the client facing APIs to read, write and process incoming commands - * App should instantiate and init one Interface per endpoint - */ -class Interface : public AttributeAccessInterface, public CommandHandlerInterface -{ -public: - Interface(EndpointId endpoint, ClusterLogic & clusterLogic) : - AttributeAccessInterface(Optional(endpoint), Id), CommandHandlerInterface(Optional(endpoint), Id), - mClusterLogic(clusterLogic) - {} - - // AttributeAccessInterface implementation - - CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; - - // CommandHandlerInterface implementation - - void InvokeCommand(HandlerContext & handlerContext) override; - - /** - * @brief This function registers attribute access and command handler. - * @return CHIP_NO_ERROR when succesfully initialized. - * Aborts if registration fails. - */ - CHIP_ERROR Init(); - - /** - * @brief This function unregisters attribute access and command handlers. - * @return CHIP_NO_ERROR when succesfully initialized - * Aborts if attribute access unregistration fails. - */ - CHIP_ERROR Shutdown(); - -private: - // This is owned by the caller and passed to the interface for its use. - ClusterLogic & mClusterLogic; -}; - -} // namespace ClosureDimension -} // namespace Clusters -} // namespace app -} // namespace chip +#include diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 36d9400f33031d..f5e2700d718b63 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -175,13 +175,13 @@ source_set("ecosystem-information-test-srcs") { source_set("closure-dimension-test-srcs") { sources = [ - "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.cpp", + "${chip_root}/src/app/clusters/closure-dimension-server/ClosureDimensionCluster.cpp", + "${chip_root}/src/app/clusters/closure-dimension-server/ClosureDimensionClusterLogic.cpp", + "${chip_root}/src/app/clusters/closure-dimension-server/ClosureDimensionClusterMatterContext.cpp", "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h", "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h", "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-delegate.h", - "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.cpp", "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-matter-context.h", - "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-server.cpp", "${chip_root}/src/app/clusters/closure-dimension-server/closure-dimension-server.h", ] public_deps = [