Skip to content

Commit 6143979

Browse files
Add checks for stepSize and bump Color control cluster revision in its xml
1 parent 722f727 commit 6143979

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
@@ -1387,7 +1387,8 @@ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const
13871387

13881388
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);
13891389

1390-
// check moveMode before any operation is done on the transition states
1390+
// check moveMode and rate before any operation is done on the transition states
1391+
// rate value is ignored if the MoveMode is stop
13911392
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop))
13921393
{
13931394
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -1669,8 +1670,8 @@ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const
16691670
ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint);
16701671
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);
16711672

1672-
// Confirm validity of the step mode received
1673-
if (stepMode == HueStepMode::kUnknownEnumValue)
1673+
// Confirm validity of the step mode and step size received
1674+
if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0)
16741675
{
16751676
commandObj->AddStatus(commandPath, Status::InvalidCommand);
16761677
return true;
@@ -1756,7 +1757,8 @@ bool ColorControlServer::moveSaturationCommand(app::CommandHandler * commandObj,
17561757
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint);
17571758
VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint);
17581759

1759-
// check moveMode before any operation is done on the transition states
1760+
// check moveMode and rate before any operation is done on the transition states
1761+
// rate value is ignored if the MoveMode is stop
17601762
if (moveMode == SaturationMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != SaturationMoveMode::kStop))
17611763
{
17621764
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -1867,8 +1869,8 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
18671869
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint);
18681870
VerifyOrExit(colorSaturationTransitionState != nullptr, status = Status::UnsupportedEndpoint);
18691871

1870-
// Confirm validity of the step mode received
1871-
if (stepMode == SaturationStepMode::kUnknownEnumValue)
1872+
// Confirm validity of the step mode and step size received
1873+
if (stepMode == SaturationStepMode::kUnknownEnumValue || stepSize == 0)
18721874
{
18731875
commandObj->AddStatus(commandPath, Status::InvalidCommand);
18741876
return true;
@@ -2263,6 +2265,12 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
22632265
VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint);
22642266
VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint);
22652267

2268+
if (rateX == 0 && rateY == 0)
2269+
{
2270+
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2271+
return true;
2272+
}
2273+
22662274
if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride))
22672275
{
22682276
commandObj->AddStatus(commandPath, Status::Success);
@@ -2275,12 +2283,6 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
22752283
// New command. Need to stop any active transitions.
22762284
stopAllColorTransitions(endpoint);
22772285

2278-
if (rateX == 0 && rateY == 0)
2279-
{
2280-
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2281-
return true;
2282-
}
2283-
22842286
// Handle color mode transition, if necessary.
22852287
handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY);
22862288

@@ -2364,6 +2366,12 @@ bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, cons
23642366
VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint);
23652367
VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint);
23662368

2369+
if (stepX == 0 && stepY == 0)
2370+
{
2371+
commandObj->AddStatus(commandPath, Status::InvalidCommand);
2372+
return true;
2373+
}
2374+
23672375
if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride))
23682376
{
23692377
commandObj->AddStatus(commandPath, Status::Success);
@@ -2693,7 +2701,8 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj,
26932701
Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint);
26942702
VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint);
26952703

2696-
// check moveMode before any operation is done on the transition states
2704+
// check moveMode and rate before any operation is done on the transition states
2705+
// rate value is ignored if the MoveMode is stop
26972706
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop))
26982707
{
26992708
commandObj->AddStatus(commandPath, Status::InvalidCommand);
@@ -2815,8 +2824,8 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj,
28152824
Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint);
28162825
VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint);
28172826

2818-
// Confirm validity of the step mode received
2819-
if (stepMode == HueStepMode::kUnknownEnumValue)
2827+
// Confirm validity of the step mode and step size received
2828+
if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0)
28202829
{
28212830
commandObj->AddStatus(commandPath, Status::InvalidCommand);
28222831
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)