Skip to content

Commit 2ab14b6

Browse files
Add checks for stepSize and bump Color control cluster revision in its xml
1 parent 48b6f45 commit 2ab14b6

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

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

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

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

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

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

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

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

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

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

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

2787-
// Confirm validity of the step mode received
2788-
if (stepMode == HueStepMode::kUnknownEnumValue)
2796+
// Confirm validity of the step mode and step size received
2797+
if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0)
27892798
{
27902799
commandObj->AddStatus(commandPath, Status::InvalidCommand);
27912800
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)