Skip to content

Commit b2c44f5

Browse files
[Code Driven]: #2 – Move Cluster Headers to Code driven style (project-chip#43203)
* closure-control: move code to new cluster headers while keeping backward * Added shim files for backward compatibility * updated copyright year for shim files
1 parent cde596c commit b2c44f5

12 files changed

Lines changed: 808 additions & 703 deletions

src/app/clusters/closure-control-server/ClosureControlCluster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <app/CommandHandlerInterfaceRegistry.h>
2020
#include <app/ConcreteAttributePath.h>
2121
#include <app/InteractionModelEngine.h>
22-
#include <app/clusters/closure-control-server/closure-control-server.h>
22+
#include <app/clusters/closure-control-server/ClosureControlCluster.h>
2323
#include <app/util/attribute-storage.h>
2424
#include <lib/support/logging/CHIPLogging.h>
2525

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app/AttributeAccessInterface.h>
22+
#include <app/CommandHandlerInterface.h>
23+
#include <app/ConcreteAttributePath.h>
24+
#include <app/clusters/closure-control-server/ClosureControlClusterLogic.h>
25+
#include <lib/core/CHIPError.h>
26+
27+
namespace chip {
28+
namespace app {
29+
namespace Clusters {
30+
namespace ClosureControl {
31+
32+
/**
33+
* @brief Closure Control cluster interface implementation
34+
* Applications should instantiate and init one Interface per endpoint
35+
*
36+
*/
37+
class Interface : public AttributeAccessInterface, public CommandHandlerInterface
38+
{
39+
public:
40+
Interface(EndpointId endpoint, ClusterLogic & clusterLogic) :
41+
AttributeAccessInterface(Optional<EndpointId>(endpoint), Id), CommandHandlerInterface(Optional<EndpointId>(endpoint), Id),
42+
mClusterLogic(clusterLogic)
43+
{}
44+
45+
virtual ~Interface() = default;
46+
47+
// AttributeAccessInterface
48+
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
49+
50+
// CommandHandlerInterface
51+
void InvokeCommand(HandlerContext & handlerContext) override;
52+
53+
/**
54+
* @brief This function registers attribute access and command handler.
55+
*
56+
* @return CHIP_NO_ERROR when succesfully initialized.
57+
* Aborts if registration fails.
58+
*/
59+
CHIP_ERROR Init();
60+
61+
/**
62+
* @brief This function registers attribute access and command handler.
63+
*
64+
* @return CHIP_NO_ERROR when succesfully initialized.
65+
* Aborts if registration fails.
66+
*/
67+
CHIP_ERROR Shutdown();
68+
69+
private:
70+
ClusterLogic & mClusterLogic;
71+
};
72+
73+
} // namespace ClosureControl
74+
} // namespace Clusters
75+
} // namespace app
76+
} // namespace chip
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include <app-common/zap-generated/cluster-enums.h>
21+
#include <protocols/interaction_model/StatusCode.h>
22+
23+
namespace chip {
24+
namespace app {
25+
namespace Clusters {
26+
namespace ClosureControl {
27+
28+
/** @brief Defines methods for implementing application-specific logic for the Closure Control Cluster.
29+
*/
30+
class DelegateBase
31+
{
32+
public:
33+
DelegateBase() = default;
34+
virtual ~DelegateBase() = default;
35+
36+
/**
37+
* @brief This function handles Stop command implementaion.
38+
*
39+
* @return Success when closure succesfully handles stop.
40+
* Error when stop fails.
41+
*/
42+
virtual Protocols::InteractionModel::Status HandleStopCommand() = 0;
43+
44+
/**
45+
* @brief This function handles MoveTo command implementaion.
46+
*
47+
* @param [in] position Target position to be set
48+
* @param [in] latch Target Latch to be set
49+
* @param [in] speed Target speed to be set
50+
*
51+
* @return Success when closure succesfully handles motion.
52+
* Error when motion fails.
53+
*/
54+
virtual Protocols::InteractionModel::Status HandleMoveToCommand(const Optional<TargetPositionEnum> & position,
55+
const Optional<bool> & latch,
56+
const Optional<Globals::ThreeLevelAutoEnum> & speed) = 0;
57+
58+
/**
59+
* @brief This function handles Calibrate command implementaion.
60+
*
61+
* @return Success when closure succesfully handles calibration.
62+
* Error when calibration fails.
63+
*/
64+
virtual Protocols::InteractionModel::Status HandleCalibrateCommand() = 0;
65+
66+
/**
67+
* @brief Checks whether the closure can move (as opposed to still needing pre-motion stages to complete).
68+
*
69+
* @return true if closure is ready to move
70+
* false if closure is not ready to move
71+
*/
72+
virtual bool IsReadyToMove() = 0;
73+
74+
/**
75+
* @brief Get the countdown time required by the closure for calibration.
76+
*
77+
* @return Time required for calibration action.
78+
*/
79+
virtual ElapsedS GetCalibrationCountdownTime() = 0;
80+
81+
/**
82+
* @brief Get the countdown time required by the closure for Motion.
83+
*
84+
* @return Time required for Motion action.
85+
*/
86+
virtual ElapsedS GetMovingCountdownTime() = 0;
87+
88+
/**
89+
* @brief Get the countdown time required by the closure for pre-stage before start of motion.
90+
*
91+
* @return Time required for Motion action.
92+
*/
93+
virtual ElapsedS GetWaitingForMotionCountdownTime() = 0;
94+
};
95+
96+
} // namespace ClosureControl
97+
} // namespace Clusters
98+
} // namespace app
99+
} // namespace chip

src/app/clusters/closure-control-server/ClosureControlClusterLogic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <app/clusters/closure-control-server/closure-control-cluster-logic.h>
18+
#include <app/clusters/closure-control-server/ClosureControlClusterLogic.h>
1919
#include <clusters/ClosureControl/Metadata.h>
2020
#include <platform/CHIPDeviceLayer.h>
2121
#include <platform/LockTracker.h>

0 commit comments

Comments
 (0)