From 7237a7270e7883b871331bea075e4aff6262bc9b Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:21:08 -0400 Subject: [PATCH] update changes based on latest spec pr changes --- .../color-control-server.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index ce950965468713..9953a23fcf35da 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -466,7 +466,15 @@ bool ColorControlServer::stopMoveStepCommand(app::CommandHandler * commandObj, c EndpointId endpoint = commandPath.mEndpointId; Status status = Status::Success; - if (shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) + // StopMoveStep command has no effect on an active color loop. + // Fetch if it is supported and active. + uint8_t isColorLoopActive = 0; + if (ColorControlServer::Instance().HasFeature(endpoint, ColorControlServer::Feature::kColorLoop)) + { + Attributes::ColorLoopActive::Get(endpoint, &isColorLoopActive); + } + + if (shouldExecuteIfOff(endpoint, optionsMask, optionsOverride) && !isColorLoopActive) { status = stopAllColorTransitions(endpoint); @@ -1140,7 +1148,7 @@ bool ColorControlServer::computeNewHueValue(ColorControlServer::ColorHueTransiti return true; } - // Check if we are in a color loop. If not, we are in a moveHue + // Check if we are in a color loop. If not, we are in a moveHue uint8_t isColorLoop = 0; Attributes::ColorLoopActive::Get(p->endpoint, &isColorLoop); @@ -2240,12 +2248,6 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons VerifyOrExit(colorXTransitionState != nullptr, status = Status::UnsupportedEndpoint); VerifyOrExit(colorYTransitionState != nullptr, status = Status::UnsupportedEndpoint); - if (rateX == 0 && rateY == 0) - { - commandObj->AddStatus(commandPath, Status::InvalidCommand); - return true; - } - if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) { commandObj->AddStatus(commandPath, Status::Success); @@ -2258,6 +2260,13 @@ bool ColorControlServer::moveColorCommand(app::CommandHandler * commandObj, cons // New command. Need to stop any active transitions. stopAllColorTransitions(endpoint); + if (rateX == 0 && rateY == 0) + { + // any current transition has been stopped. We are done. + commandObj->AddStatus(commandPath, Status::Success); + return true; + } + // Handle color mode transition, if necessary. handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY);