Skip to content

Commit ff5490a

Browse files
[Closures] Update Closure dimension cluster as per latest specification (project-chip#38424)
* Update Closure dimension cluster as per latest specification * Adding missing zap files * Updating server implementation as per new spec changes * Removing constrain check for boolean * Restyled by clang-format * Restyled by prettier-json * Add missing Git SHA in XML * Removing old struct files --------- Co-authored-by: sabollim <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent 4a26ee2 commit ff5490a

File tree

50 files changed

+318
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+318
-437
lines changed

src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ CHIP_ERROR ClusterLogic::SetCurrentState(const GenericCurrentStateStruct & curre
5757
VerifyOrReturnError(currentState.position.Value() <= PERCENT100THS_MAX_VALUE, CHIP_ERROR_INVALID_ARGUMENT);
5858
}
5959

60-
if (currentState.latching.HasValue())
60+
if (currentState.latch.HasValue())
6161
{
6262
VerifyOrReturnError(mConformance.HasFeature(Feature::kMotionLatching), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
63-
VerifyOrReturnError(EnsureKnownEnumValue(currentState.latching.Value()) != LatchingEnum::kUnknownEnumValue,
64-
CHIP_ERROR_INVALID_ARGUMENT);
6563
}
6664

6765
if (currentState.speed.HasValue())
@@ -76,7 +74,7 @@ CHIP_ERROR ClusterLogic::SetCurrentState(const GenericCurrentStateStruct & curre
7674
if (currentState != mState.currentState)
7775
{
7876
mState.currentState = currentState;
79-
mMatterContext.MarkDirty(Attributes::Current::Id);
77+
mMatterContext.MarkDirty(Attributes::CurrentState::Id);
8078
}
8179

8280
return CHIP_NO_ERROR;
@@ -95,8 +93,6 @@ CHIP_ERROR ClusterLogic::SetTarget(const GenericTargetStruct & target)
9593
if (target.latch.HasValue())
9694
{
9795
VerifyOrReturnError(mConformance.HasFeature(Feature::kMotionLatching), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
98-
VerifyOrReturnError(EnsureKnownEnumValue(target.latch.Value()) != TargetLatchEnum::kUnknownEnumValue,
99-
CHIP_ERROR_INVALID_ARGUMENT);
10096
}
10197

10298
if (target.speed.HasValue())
@@ -404,7 +400,7 @@ CHIP_ERROR ClusterLogic::GetClusterRevision(Attributes::ClusterRevision::TypeInf
404400
return CHIP_NO_ERROR;
405401
}
406402

407-
Status ClusterLogic::HandleSetTargetCommand(Optional<Percent100ths> position, Optional<TargetLatchEnum> latch,
403+
Status ClusterLogic::HandleSetTargetCommand(Optional<Percent100ths> position, Optional<bool> latch,
408404
Optional<Globals::ThreeLevelAutoEnum> speed)
409405
{
410406
VerifyOrDieWithMsg(mInitialized, NotSpecified, "Unexpected command received when device is yet to be initialized");
@@ -429,7 +425,6 @@ Status ClusterLogic::HandleSetTargetCommand(Optional<Percent100ths> position, Op
429425

430426
if (latch.HasValue())
431427
{
432-
VerifyOrReturnError(latch.Value() != TargetLatchEnum::kUnknownEnumValue, Status::ConstraintError);
433428
VerifyOrReturnError(mConformance.HasFeature(Feature::kMotionLatching), Status::Success);
434429
// TODO: If the device supports the Latching(LT) feature, the device dimension SHALL either fulfill the latch order and
435430
// update Target.Latch or, if manual intervention is required to latch, respond with INVALID_ACTION and remain in its
@@ -528,7 +523,7 @@ Status ClusterLogic::HandleStepCommand(StepDirectionEnum direction, uint16_t num
528523
// Position value SHALL be clamped to 0.00% if the LM feature is not supported or LimitRange.Max if the LM feature is
529524
// supported.
530525
newPosition = limitSupported ? std::min(newPosition, static_cast<uint32_t>(limitRange.max))
531-
: std::min(newPosition, static_cast<uint32_t>(10000));
526+
: std::min(newPosition, static_cast<uint32_t>(PERCENT100THS_MAX_VALUE));
532527
break;
533528

534529
default:
@@ -538,7 +533,7 @@ Status ClusterLogic::HandleStepCommand(StepDirectionEnum direction, uint16_t num
538533
}
539534

540535
// set the target position
541-
stepTarget.position.SetValue(newPosition);
536+
stepTarget.position.SetValue(static_cast<Percent100ths>(newPosition));
542537

543538
if (speed.HasValue())
544539
{

src/app/clusters/closure-dimension-server/closure-dimension-cluster-logic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class ClusterLogic
238238
* Returns Success if arguments don't match the feature conformance.
239239
* Returns Success on succesful handling.
240240
*/
241-
Protocols::InteractionModel::Status HandleSetTargetCommand(Optional<Percent100ths> position, Optional<TargetLatchEnum> latch,
241+
Protocols::InteractionModel::Status HandleSetTargetCommand(Optional<Percent100ths> position, Optional<bool> latch,
242242
Optional<Globals::ThreeLevelAutoEnum> speed);
243243

244244
/**

src/app/clusters/closure-dimension-server/closure-dimension-cluster-objects.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,38 @@ namespace ClosureDimension {
2828
/**
2929
* Structure represents the current state struct of a closure dimension cluster derivation instance.
3030
*/
31-
struct GenericCurrentStateStruct : public Structs::CurrentStruct::Type
31+
struct GenericCurrentStateStruct : public Structs::CurrentStateStruct::Type
3232
{
33-
GenericCurrentStateStruct(Optional<Percent100ths> positionValue = NullOptional,
34-
Optional<LatchingEnum> latchingValue = NullOptional,
33+
GenericCurrentStateStruct(Optional<Percent100ths> positionValue = NullOptional, Optional<bool> latchValue = NullOptional,
3534
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
3635
{
37-
Set(positionValue, latchingValue, speedValue);
36+
Set(positionValue, latchValue, speedValue);
3837
}
3938

4039
GenericCurrentStateStruct(const GenericCurrentStateStruct & currentState) { *this = currentState; }
4140

4241
GenericCurrentStateStruct & operator=(const GenericCurrentStateStruct & current)
4342
{
44-
Set(current.position, current.latching, current.speed);
43+
Set(current.position, current.latch, current.speed);
4544
return *this;
4645
}
4746

48-
void Set(Optional<Percent100ths> positioningValue = NullOptional, Optional<LatchingEnum> latchingValue = NullOptional,
47+
void Set(Optional<Percent100ths> positioningValue = NullOptional, Optional<bool> latchValue = NullOptional,
4948
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
5049
{
5150
position = positioningValue;
52-
latching = latchingValue;
51+
latch = latchValue;
5352
speed = speedValue;
5453
}
5554

5655
bool operator==(const GenericCurrentStateStruct & rhs) const
5756
{
58-
return position == rhs.position && latching == rhs.latching && speed == rhs.speed;
57+
return position == rhs.position && latch == rhs.latch && speed == rhs.speed;
5958
}
6059

6160
bool operator!=(const GenericCurrentStateStruct & rhs) const
6261
{
63-
return position != rhs.position || latching != rhs.latching || speed != rhs.speed;
62+
return position != rhs.position || latch != rhs.latch || speed != rhs.speed;
6463
}
6564
};
6665

@@ -69,7 +68,7 @@ struct GenericCurrentStateStruct : public Structs::CurrentStruct::Type
6968
*/
7069
struct GenericTargetStruct : public Structs::TargetStruct::Type
7170
{
72-
GenericTargetStruct(Optional<Percent100ths> positionValue = NullOptional, Optional<TargetLatchEnum> latchValue = NullOptional,
71+
GenericTargetStruct(Optional<Percent100ths> positionValue = NullOptional, Optional<bool> latchValue = NullOptional,
7372
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
7473
{
7574
Set(positionValue, latchValue, speedValue);
@@ -83,7 +82,7 @@ struct GenericTargetStruct : public Structs::TargetStruct::Type
8382
return *this;
8483
}
8584

86-
void Set(Optional<Percent100ths> positionValue = NullOptional, Optional<TargetLatchEnum> latchValue = NullOptional,
85+
void Set(Optional<Percent100ths> positionValue = NullOptional, Optional<bool> latchValue = NullOptional,
8786
Optional<Globals::ThreeLevelAutoEnum> speedValue = NullOptional)
8887
{
8988
position = positionValue;

src/app/clusters/closure-dimension-server/closure-dimension-delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class DelegateBase
4848
* Error when handle SetTarget fails.
4949
*/
5050
virtual Protocols::InteractionModel::Status HandleSetTarget(const Optional<Percent100ths> & position,
51-
const Optional<TargetLatchEnum> & latch,
51+
const Optional<bool> & latch,
5252
const Optional<Globals::ThreeLevelAutoEnum> & speed) = 0;
5353

5454
/**

src/app/clusters/closure-dimension-server/closure-dimension-server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CHIP_ERROR Interface::Read(const ConcreteReadAttributePath & aPath, AttributeVal
4343
{
4444
switch (aPath.mAttributeId)
4545
{
46-
case Attributes::Current::Id: {
46+
case Attributes::CurrentState::Id: {
4747
typedef GenericCurrentStateStruct T;
4848
return EncodeRead<T>(aEncoder, [&logic = mClusterLogic](T & ret) -> CHIP_ERROR { return logic.GetCurrentState(ret); });
4949
}

src/app/zap-templates/zcl/data-model/chip/closure-dimension-cluster.xml

Lines changed: 28 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
XML generated by Alchemy; DO NOT EDIT.
1919
Source: src/app_clusters/ClosureDimension.adoc
2020
Parameters: in-progress
21-
Git: 0.7-summer-2025-513-g8ca88d0f5
21+
Git: 0.7-summer-2025-ncr-68-gebfcd02e9
2222
-->
2323
<configurator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../zcl.xsd">
2424
<domain name="Closures"/>
@@ -28,13 +28,6 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
2828
<item name="Degree" value="0x01"/>
2929
</enum>
3030

31-
<enum name="LatchingEnum" type="enum8">
32-
<cluster code="0x0105"/>
33-
<item name="LatchedAndSecured" value="0x00"/>
34-
<item name="LatchedButNotSecured" value="0x01"/>
35-
<item name="NotLatched" value="0x02"/>
36-
</enum>
37-
3831
<enum name="ModulationTypeEnum" type="enum8">
3932
<cluster code="0x0105"/>
4033
<item name="SlatsOrientation" value="0x00"/>
@@ -80,12 +73,6 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
8073
<item name="Increase" value="0x01"/>
8174
</enum>
8275

83-
<enum name="TargetLatchEnum" type="enum8">
84-
<cluster code="0x0105"/>
85-
<item name="Latch" value="0x00"/>
86-
<item name="Unlatch" value="0x01"/>
87-
</enum>
88-
8976
<enum name="TranslationDirectionEnum" type="enum8">
9077
<cluster code="0x0105"/>
9178
<item name="Downward" value="0x00"/>
@@ -106,10 +93,10 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
10693
<item name="CeilingCenteredSymmetry" value="0x0F"/>
10794
</enum>
10895

109-
<struct name="CurrentStruct" apiMaturity="provisional">
96+
<struct name="CurrentStateStruct" apiMaturity="provisional">
11097
<cluster code="0x0105"/>
11198
<item fieldId="0" name="Position" type="percent100ths" optional="true"/>
112-
<item fieldId="1" name="Latching" type="LatchingEnum" optional="true" default="0x02" min="0x00" max="0x02"/>
99+
<item fieldId="1" name="Latch" type="boolean" optional="true" default="0"/>
113100
<item fieldId="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" default="0x00" min="0x00" max="0x03"/>
114101
</struct>
115102

@@ -122,14 +109,14 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
122109
<struct name="TargetStruct" apiMaturity="provisional">
123110
<cluster code="0x0105"/>
124111
<item fieldId="0" name="Position" type="percent100ths" optional="true"/>
125-
<item fieldId="1" name="Latch" type="TargetLatchEnum" optional="true" default="0x01" min="0x00" max="0x01"/>
112+
<item fieldId="1" name="Latch" type="boolean" optional="true" default="0"/>
126113
<item fieldId="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" default="0x00" min="0x00" max="0x03"/>
127114
</struct>
128115

129116
<struct name="UnitRangeStruct" apiMaturity="provisional">
130117
<cluster code="0x0105"/>
131118
<item fieldId="0" name="Min" type="int16s"/>
132-
<item fieldId="1" name="Max" type="int16s" max="32767"/>
119+
<item fieldId="1" name="Max" type="int16s"/>
133120
</struct>
134121

135122
<cluster apiMaturity="provisional">
@@ -141,52 +128,44 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
141128
<client init="false" tick="false">true</client>
142129
<server init="false" tick="false">true</server>
143130
<globalAttribute code="0xFFFD" side="either" value="1"/>
144-
<attribute code="0x0000" side="server" define="CURRENT" type="CurrentStruct" isNullable="true">Current</attribute>
145-
<attribute code="0x0001" side="server" define="TARGET" type="TargetStruct" isNullable="true">Target</attribute>
146-
<attribute code="0x0002" side="server" define="RESOLUTION" type="percent100ths" min="0" optional="true">
147-
<description>Resolution</description>
131+
<attribute code="0x0000" side="server" name="CurrentState" define="CURRENT" type="CurrentStateStruct" isNullable="true"/>
132+
<attribute code="0x0001" side="server" name="Target" define="TARGET" type="TargetStruct" isNullable="true"/>
133+
<attribute code="0x0002" side="server" name="Resolution" define="RESOLUTION" type="percent100ths" optional="true" max="10000">
148134
<mandatoryConform>
149135
<feature name="PS"/>
150136
</mandatoryConform>
151137
</attribute>
152-
<attribute code="0x0003" side="server" define="STEP_VALUE" type="percent100ths" optional="true">
153-
<description>StepValue</description>
138+
<attribute code="0x0003" side="server" name="StepValue" define="STEP_VALUE" type="percent100ths" optional="true">
154139
<mandatoryConform>
155140
<feature name="PS"/>
156141
</mandatoryConform>
157142
</attribute>
158-
<attribute code="0x0004" side="server" define="UNIT" type="ClosureUnitEnum" min="0x00" max="0x01" optional="true">
159-
<description>Unit</description>
143+
<attribute code="0x0004" side="server" name="Unit" define="UNIT" type="ClosureUnitEnum" min="0x00" max="0x01" optional="true">
160144
<mandatoryConform>
161145
<feature name="UT"/>
162146
</mandatoryConform>
163147
</attribute>
164-
<attribute code="0x0005" side="server" define="UNIT_RANGE" type="UnitRangeStruct" isNullable="true" optional="true">
165-
<description>UnitRange</description>
148+
<attribute code="0x0005" side="server" name="UnitRange" define="UNIT_RANGE" type="UnitRangeStruct" isNullable="true" optional="true">
166149
<mandatoryConform>
167150
<feature name="UT"/>
168151
</mandatoryConform>
169152
</attribute>
170-
<attribute code="0x0006" side="server" define="LIMIT_RANGE" type="RangePercent100thsStruct" optional="true">
171-
<description>LimitRange</description>
153+
<attribute code="0x0006" side="server" name="LimitRange" define="LIMIT_RANGE" type="RangePercent100thsStruct" optional="true">
172154
<mandatoryConform>
173155
<feature name="LM"/>
174156
</mandatoryConform>
175157
</attribute>
176-
<attribute code="0x0007" side="server" define="TRANSLATION_DIRECTION" type="TranslationDirectionEnum" min="0x00" max="0x0F" optional="true">
177-
<description>TranslationDirection</description>
158+
<attribute code="0x0007" side="server" name="TranslationDirection" define="TRANSLATION_DIRECTION" type="TranslationDirectionEnum" min="0x00" max="0x0F" optional="true">
178159
<mandatoryConform>
179160
<feature name="TR"/>
180161
</mandatoryConform>
181162
</attribute>
182-
<attribute code="0x0008" side="server" define="ROTATION_AXIS" type="RotationAxisEnum" min="0x00" max="0x0A" optional="true">
183-
<description>RotationAxis</description>
163+
<attribute code="0x0008" side="server" name="RotationAxis" define="ROTATION_AXIS" type="RotationAxisEnum" min="0x00" max="0x0A" optional="true">
184164
<mandatoryConform>
185165
<feature name="RO"/>
186166
</mandatoryConform>
187167
</attribute>
188-
<attribute code="0x0009" side="server" define="OVERFLOW" type="OverflowEnum" min="0x00" max="0x0A" optional="true">
189-
<description>Overflow</description>
168+
<attribute code="0x0009" side="server" name="Overflow" define="OVERFLOW" type="OverflowEnum" min="0x00" max="0x0A" optional="true">
190169
<otherwiseConform>
191170
<mandatoryConform>
192171
<feature name="RO"/>
@@ -196,24 +175,23 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
196175
</optionalConform>
197176
</otherwiseConform>
198177
</attribute>
199-
<attribute code="0x000A" side="server" define="MODULATION_TYPE" type="ModulationTypeEnum" min="0x00" max="0x04" optional="true">
200-
<description>ModulationType</description>
178+
<attribute code="0x000A" side="server" name="ModulationType" define="MODULATION_TYPE" type="ModulationTypeEnum" min="0x00" max="0x04" optional="true">
201179
<mandatoryConform>
202180
<feature name="MD"/>
203181
</mandatoryConform>
204182
</attribute>
205-
<command code="0x00" source="client" name="SetTarget" optional="false">
206-
<description>Upon receipt, this SHALL move the product&apos;s dimension in the most fitting state following the data as follows: </description>
183+
<command code="0x00" source="client" name="SetTarget">
184+
<description>This command is used to move a dimension of the device to a target position.</description>
207185
<arg id="0" name="Position" type="percent100ths" optional="true"/>
208-
<arg id="1" name="Latch" type="TargetLatchEnum" optional="true" min="0x00" max="0x01"/>
209-
<arg id="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" min="0x00" max="0x03"/>
186+
<arg id="1" name="Latch" type="boolean" optional="true" default="0"/>
187+
<arg id="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" min="0x00" max="0x03" default="0x00"/>
210188
</command>
211189

212190
<command code="0x01" source="client" name="Step" optional="true">
213-
<description>Upon receipt, this SHALL update the Target.Position attribute value e.g. by sending multiple commands with short step by step or a single command with multiple steps.</description>
191+
<description>This command is used to move a dimension of the device to a target position by a number of steps.</description>
214192
<arg id="0" name="Direction" type="StepDirectionEnum" min="0x00" max="0x01"/>
215193
<arg id="1" name="NumberOfSteps" type="int16u" min="1"/>
216-
<arg id="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" min="0x00" max="0x03"/>
194+
<arg id="2" name="Speed" type="ThreeLevelAutoEnum" optional="true" min="0x00" max="0x03" default="0x00"/>
217195
<mandatoryConform>
218196
<feature name="PS"/>
219197
</mandatoryConform>
@@ -223,15 +201,15 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
223201
<feature bit="0" code="PS" name="Positioning" summary="Supports positioning in the range from 0.00% to 100.00%">
224202
<optionalConform choice="a" more="true" min="1"/>
225203
</feature>
226-
<feature bit="1" code="LT" name="MotionLatching" summary="Supports a latch (securing a position, a state ...)">
204+
<feature bit="1" code="LT" name="MotionLatching" summary="Supports a latch to secure the closure to a position or state">
227205
<optionalConform choice="a" more="true" min="1"/>
228206
</feature>
229-
<feature bit="2" code="UT" name="Unit" summary="Supports additional data (in mm, degrees ...) to enhance control">
207+
<feature bit="2" code="UT" name="Unit" summary="Specifies the relevant unit and range for this dimension (mm, degrees etc.)">
230208
<optionalConform>
231209
<feature name="PS"/>
232210
</optionalConform>
233211
</feature>
234-
<feature bit="3" code="LM" name="Limitation" summary="Supports the limitation of the operating range">
212+
<feature bit="3" code="LM" name="Limitation" summary="Supports limitation of the operating range">
235213
<optionalConform>
236214
<feature name="PS"/>
237215
</optionalConform>
@@ -241,21 +219,9 @@ Git: 0.7-summer-2025-513-g8ca88d0f5
241219
<feature name="PS"/>
242220
</optionalConform>
243221
</feature>
244-
<feature bit="5" code="TR" name="Translation" summary="Drives a translation motion">
245-
<optionalConform choice="b">
246-
<feature name="PS"/>
247-
</optionalConform>
248-
</feature>
249-
<feature bit="6" code="RO" name="Rotation" summary="Drives a rotation motion">
250-
<optionalConform choice="b">
251-
<feature name="PS"/>
252-
</optionalConform>
253-
</feature>
254-
<feature bit="7" code="MD" name="Modulation" summary="Modulates a particular flow level (light, air, privacy ...)">
255-
<optionalConform choice="b">
256-
<feature name="PS"/>
257-
</optionalConform>
258-
</feature>
222+
<feature bit="5" code="TR" name="Translation" summary="Drives a translation motion"/>
223+
<feature bit="6" code="RO" name="Rotation" summary="Drives a rotation motion"/>
224+
<feature bit="7" code="MD" name="Modulation" summary="Modulates a particular flow level (light, air, privacy ...)"/>
259225
</features>
260226
</cluster>
261227
</configurator>

src/app/zap-templates/zcl/zcl-with-test-extensions.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@
209209
"Bridged Device Basic Information": ["ProductAppearance"],
210210
"Chime": ["SelectedChime", "Enabled"],
211211
"Closure Control": ["CountdownTime", "OverallState", "OverallTarget"],
212-
"Closure Dimension": ["Current", "Target", "UnitRange", "LimitRange"],
212+
"Closure Dimension": [
213+
"CurrentState",
214+
"Target",
215+
"UnitRange",
216+
"LimitRange"
217+
],
213218
"Commodity Price": ["Currency", "CurrentPrice"],
214219
"Commodity Tariff": [
215220
"TariffInfo",

0 commit comments

Comments
 (0)