@@ -1362,7 +1362,8 @@ bool ColorControlServer::moveHueCommand(app::CommandHandler * commandObj, const
1362
1362
1363
1363
VerifyOrExit (colorHueTransitionState != nullptr , status = Status::UnsupportedEndpoint);
1364
1364
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
1366
1367
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop ))
1367
1368
{
1368
1369
commandObj->AddStatus (commandPath, Status::InvalidCommand);
@@ -1644,8 +1645,8 @@ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const
1644
1645
ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState (endpoint);
1645
1646
VerifyOrExit (colorHueTransitionState != nullptr , status = Status::UnsupportedEndpoint);
1646
1647
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 )
1649
1650
{
1650
1651
commandObj->AddStatus (commandPath, Status::InvalidCommand);
1651
1652
return true ;
@@ -1731,7 +1732,8 @@ bool ColorControlServer::moveSaturationCommand(app::CommandHandler * commandObj,
1731
1732
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState (endpoint);
1732
1733
VerifyOrExit (colorSaturationTransitionState != nullptr , status = Status::UnsupportedEndpoint);
1733
1734
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
1735
1737
if (moveMode == SaturationMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != SaturationMoveMode::kStop ))
1736
1738
{
1737
1739
commandObj->AddStatus (commandPath, Status::InvalidCommand);
@@ -1842,8 +1844,8 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
1842
1844
Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState (endpoint);
1843
1845
VerifyOrExit (colorSaturationTransitionState != nullptr , status = Status::UnsupportedEndpoint);
1844
1846
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 )
1847
1849
{
1848
1850
commandObj->AddStatus (commandPath, Status::InvalidCommand);
1849
1851
return true ;
@@ -2238,6 +2240,12 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
2238
2240
VerifyOrExit (colorXTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2239
2241
VerifyOrExit (colorYTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2240
2242
2243
+ if (rateX == 0 && rateY == 0 )
2244
+ {
2245
+ commandObj->AddStatus (commandPath, Status::InvalidCommand);
2246
+ return true ;
2247
+ }
2248
+
2241
2249
if (!shouldExecuteIfOff (endpoint, optionsMask, optionsOverride))
2242
2250
{
2243
2251
commandObj->AddStatus (commandPath, Status::Success);
@@ -2250,12 +2258,6 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons
2250
2258
// New command. Need to stop any active transitions.
2251
2259
stopAllColorTransitions (endpoint);
2252
2260
2253
- if (rateX == 0 && rateY == 0 )
2254
- {
2255
- commandObj->AddStatus (commandPath, Status::InvalidCommand);
2256
- return true ;
2257
- }
2258
-
2259
2261
// Handle color mode transition, if necessary.
2260
2262
handleModeSwitch (endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY );
2261
2263
@@ -2339,6 +2341,12 @@ bool ColorControlServer::stepColorCommand(app::CommandHandler * commandObj, cons
2339
2341
VerifyOrExit (colorXTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2340
2342
VerifyOrExit (colorYTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2341
2343
2344
+ if (stepX == 0 && stepY == 0 )
2345
+ {
2346
+ commandObj->AddStatus (commandPath, Status::InvalidCommand);
2347
+ return true ;
2348
+ }
2349
+
2342
2350
if (!shouldExecuteIfOff (endpoint, optionsMask, optionsOverride))
2343
2351
{
2344
2352
commandObj->AddStatus (commandPath, Status::Success);
@@ -2668,7 +2676,8 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj,
2668
2676
Color16uTransitionState * colorTempTransitionState = getTempTransitionState (endpoint);
2669
2677
VerifyOrExit (colorTempTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2670
2678
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
2672
2681
if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop ))
2673
2682
{
2674
2683
commandObj->AddStatus (commandPath, Status::InvalidCommand);
@@ -2785,8 +2794,8 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj,
2785
2794
Color16uTransitionState * colorTempTransitionState = getTempTransitionState (endpoint);
2786
2795
VerifyOrExit (colorTempTransitionState != nullptr , status = Status::UnsupportedEndpoint);
2787
2796
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 )
2790
2799
{
2791
2800
commandObj->AddStatus (commandPath, Status::InvalidCommand);
2792
2801
return true ;
0 commit comments