Skip to content

Commit 28c1d83

Browse files
sabollim-silabssatyanaag-silabsrestyled-commits
authored
Closure control cluster server code implementation (#37561)
* Closure control sluster Server Code * Restyled by whitespace * Restyled by clang-format * Changing MainState and Countdowntime Implementation * Handling OverallState and OverallTarget from Instance * Addressing PR comments * Restyled by whitespace * Restyled by clang-format * Updating missing zap changes * Adding wrapper for struct handling * Restyled by whitespace * Restyled by clang-format * Addressing PR comments * Addressing PR comments * Restyled by clang-format * addressing PR comments * changing IsEqual to operator== * Addressing PR comments * Addresssing PR comments * Removing Fallback feature attribute and commands as FB feature is removed from spec * Addressing PR comments * Updating countdonwtime quiet reporting policy * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: sabollim <satyanaag.bollimpalli@silabs.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 2ded8fb commit 28c1d83

File tree

7 files changed

+632
-31
lines changed

7 files changed

+632
-31
lines changed

src/app/chip_data_model.gni

+6
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,12 @@ template("chip_data_model") {
456456
"${_app_root}/clusters/${cluster}/ArlEncoder.cpp",
457457
"${_app_root}/clusters/${cluster}/ArlEncoder.h",
458458
]
459+
} else if (cluster == "closure-control-server") {
460+
sources += [
461+
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
462+
"${_app_root}/clusters/${cluster}/${cluster}.h",
463+
"${_app_root}/clusters/${cluster}/closure-control-cluster-objects.h",
464+
]
459465
} else {
460466
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
461467
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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-common/zap-generated/cluster-objects.h>
22+
#include <lib/support/CommonIterator.h>
23+
24+
namespace chip {
25+
namespace app {
26+
namespace Clusters {
27+
namespace ClosureControl {
28+
29+
/**
30+
* Structure represents the overall state of a closure control cluster derivation instance.
31+
*/
32+
struct GenericOverallState : public Structs::OverallStateStruct::Type
33+
{
34+
GenericOverallState(Optional<PositioningEnum> positioningValue = NullOptional,
35+
Optional<LatchingEnum> latchingValue = NullOptional,
36+
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional,
37+
Optional<uint32_t> extraInfoValue = NullOptional)
38+
{
39+
Set(positioningValue, latchingValue, speedValue, extraInfoValue);
40+
}
41+
42+
GenericOverallState(const GenericOverallState & overallState) { *this = overallState; }
43+
44+
GenericOverallState & operator=(const GenericOverallState & overallState)
45+
{
46+
Set(overallState.positioning, overallState.latching, overallState.speed, overallState.extraInfo);
47+
return *this;
48+
}
49+
50+
void Set(Optional<PositioningEnum> positioningValue = NullOptional, Optional<LatchingEnum> latchingValue = NullOptional,
51+
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional, Optional<uint32_t> extraInfoValue = NullOptional)
52+
{
53+
positioning = positioningValue;
54+
latching = latchingValue;
55+
speed = speedValue;
56+
extraInfo = extraInfoValue;
57+
}
58+
59+
bool operator==(const Structs::OverallStateStruct::Type & rhs) const
60+
{
61+
return positioning == rhs.positioning && latching == rhs.latching && speed == rhs.speed && extraInfo == rhs.extraInfo;
62+
}
63+
};
64+
65+
/**
66+
* Structure represents the overall target state of a closure control cluster derivation instance.
67+
*/
68+
struct GenericOverallTarget : public Structs::OverallTargetStruct::Type
69+
{
70+
GenericOverallTarget(Optional<TagPositionEnum> tagPositionValue = NullOptional,
71+
Optional<TagLatchEnum> tagLatchValue = NullOptional,
72+
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
73+
{
74+
Set(tagPositionValue, tagLatchValue, speedValue);
75+
}
76+
77+
GenericOverallTarget(const GenericOverallTarget & overallTarget) { *this = overallTarget; }
78+
79+
GenericOverallTarget & operator=(const GenericOverallTarget & overallTarget)
80+
{
81+
Set(overallTarget.tagPosition, overallTarget.tagLatch, overallTarget.speed);
82+
return *this;
83+
}
84+
85+
void Set(Optional<TagPositionEnum> tagPositionValue = NullOptional, Optional<TagLatchEnum> tagLatchValue = NullOptional,
86+
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
87+
{
88+
tagPosition = tagPositionValue;
89+
tagLatch = tagLatchValue;
90+
speed = speedValue;
91+
}
92+
93+
bool operator==(const Structs::OverallTargetStruct::Type & rhs) const
94+
{
95+
return tagPosition == rhs.tagPosition && tagLatch == rhs.tagLatch && speed == rhs.speed;
96+
}
97+
};
98+
99+
} // namespace ClosureControl
100+
} // namespace Clusters
101+
} // namespace app
102+
} // namespace chip

0 commit comments

Comments
 (0)