Skip to content

Commit 371dab1

Browse files
Add checks for stepSize and bump Color control cluster revision in its xml
1 parent 5c2ba36 commit 371dab1

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/app/clusters/color-control-server/color-control-server.cpp

+24-15
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,8 @@ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const
13621362

13631363
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);
13641364

1365-
// check moveMode before any operation is done on the transition states
1365+
// check moveMode and rate before any operation is done on the transition states
1366+
// rate value is ignored if the MoveMode is stop
13661367
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop))
13671368
{
13681369
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -1644,8 +1645,8 @@ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const
16441645
ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint);
16451646
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);
16461647

1647-
// Confirm validity of the step mode received
1648-
if (stepMode == HueStepMode::kUnknownEnumValue)
1648+
// Confirm validity of the step mode and step size received
1649+
if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0)
16491650
{
16501651
commandObj->AddStatus(commandPath, Status::InvalidCommand);
16511652
return true;
@@ -1731,7 +1732,8 @@ bool ColorControlServer::moveSaturationCommand(app::CommandHandler * commandObj,
17311732
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint);
17321733
VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint);
17331734

1734-
// check moveMode before any operation is done on the transition states
1735+
// check moveMode and rate before any operation is done on the transition states
1736+
// rate value is ignored if the MoveMode is stop
17351737
if (moveMode == SaturationMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != SaturationMoveMode::kStop))
17361738
{
17371739
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -1842,8 +1844,8 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
18421844
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint);
18431845
VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint);
18441846

1845-
// Confirm validity of the step mode received
1846-
if (stepMode == SaturationStepMode::kUnknownEnumValue)
1847+
// Confirm validity of the step mode and step size received
1848+
if (stepMode == SaturationStepMode::kUnknownEnumValue || stepSize == 0)
18471849
{
18481850
commandObj->AddStatus(commandPath, Status::InvalidCommand);
18491851
return true;
@@ -2238,6 +2240,12 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
22382240
VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint);
22392241
VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint);
22402242

2243+
if (rateX == 0 && rateY == 0)
2244+
{
2245+
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2246+
return true;
2247+
}
2248+
22412249
if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride))
22422250
{
22432251
commandObj->AddStatus(commandPath, Status::Success);
@@ -2250,12 +2258,6 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
22502258
// New command. Need to stop any active transitions.
22512259
stopAllColorTransitions(endpoint);
22522260

2253-
if (rateX == 0 && rateY == 0)
2254-
{
2255-
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2256-
return true;
2257-
}
2258-
22592261
// Handle color mode transition, if necessary.
22602262
handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY);
22612263

@@ -2339,6 +2341,12 @@ bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, cons
23392341
VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint);
23402342
VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint);
23412343

2344+
if (stepX == 0 && stepY == 0)
2345+
{
2346+
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2347+
return true;
2348+
}
2349+
23422350
if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride))
23432351
{
23442352
commandObj->AddStatus(commandPath, Status::Success);
@@ -2668,7 +2676,8 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj,
26682676
Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint);
26692677
VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint);
26702678

2671-
// check moveMode before any operation is done on the transition states
2679+
// check moveMode and rate before any operation is done on the transition states
2680+
// rate value is ignored if the MoveMode is stop
26722681
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop))
26732682
{
26742683
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -2785,8 +2794,8 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj,
27852794
Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint);
27862795
VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint);
27872796

2788-
// Confirm validity of the step mode received
2789-
if (stepMode == HueStepMode::kUnknownEnumValue)
2797+
// Confirm validity of the step mode and step size received
2798+
if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0)
27902799
{
27912800
commandObj->AddStatus(commandPath, Status::InvalidCommand);
27922801
return true;

src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ limitations under the License.
9898
<client tick="false" init="false">true</client>
9999
<server tick="false" init="false">true</server>
100100

101-
<globalAttribute side="either" code="0xFFFD" value="6"/>
101+
<globalAttribute side="either" code="0xFFFD" value="7"/>
102102

103103
<features>
104104
<feature bit="0" code="HS" name="Hue And Saturation" summary="Supports color specification via hue/saturation.">

0 commit comments

Comments
 (0)