From 29a93669b55a18f1248e0d5247f4250b1b4b3fd6 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:15:05 -0400 Subject: [PATCH] remove contraint error on optionsMask and optionsOverride undefined bits --- .../color-control-server.cpp | 39 ------------------- .../color-control-server.h | 12 +++--- 2 files changed, 6 insertions(+), 45 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 f3e6bae358210a..7d5a5e5fe19b1b 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -474,10 +474,6 @@ Status ColorControlServer::stopMoveStepCommand(EndpointId endpoint, const Comman { Status status = Status::Success; - // Command parameters constraint checks: - VerifyOrReturnValue(commandData.optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsOverride <= kMaxOptionValue, Status::ConstraintError); - // StopMoveStep command has no effect on an active color loop. // Fetch if it is supported and active. uint8_t isColorLoopActive = 0; @@ -1421,10 +1417,6 @@ Status ColorControlServer::moveHueCommand(EndpointId endpoint, HueMoveMode moveM VerifyOrReturnValue(moveMode != HueMoveMode::kUnknownEnumValue, Status::InvalidCommand); VerifyOrReturnValue((rate != 0 || moveMode == HueMoveMode::kStop), Status::InvalidCommand); - // Command Parameters constraint checks: - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); - uint16_t epIndex = getEndpointIndex(endpoint); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionStateByIndex(epIndex); VerifyOrReturnValue(colorHueTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -1523,8 +1515,6 @@ Status ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, D // Command Parameters constraint checks: VerifyOrReturnValue((isEnhanced || hue <= MAX_HUE_VALUE), Status::ConstraintError); VerifyOrReturnValue(transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); VerifyOrReturnValue(colorHueTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -1642,8 +1632,6 @@ Status ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, ui VerifyOrReturnValue((isEnhanced || hue <= MAX_HUE_VALUE), Status::ConstraintError); VerifyOrReturnValue(saturation <= MAX_SATURATION_VALUE, Status::ConstraintError); VerifyOrReturnValue(transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); VerifyOrReturnValue(shouldExecuteIfOff(endpoint, optionsMask, optionsOverride), Status::Success); @@ -1688,8 +1676,6 @@ Status ColorControlServer::stepHueCommand(EndpointId endpoint, HueStepMode stepM { VerifyOrReturnValue(transitionTime <= UINT8_MAX, Status::ConstraintError); } - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionState(endpoint); VerifyOrReturnValue(colorHueTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -1777,10 +1763,6 @@ Status ColorControlServer::moveSaturationCommand(EndpointId endpoint, const Comm VerifyOrReturnValue(moveMode != SaturationMoveMode::kUnknownEnumValue, Status::InvalidCommand); VerifyOrReturnValue(rate != 0 || moveMode == SaturationMoveMode::kStop, Status::InvalidCommand); - // Command Parameters constraint checks - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); - uint16_t epIndex = getEndpointIndex(endpoint); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionStateByIndex(epIndex); VerifyOrReturnValue(colorSaturationTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -1841,8 +1823,6 @@ Status ColorControlServer::moveToSaturationCommand(EndpointId endpoint, // Command Parameters constraint checks: VerifyOrReturnValue(commandData.saturation <= MAX_SATURATION_VALUE, Status::ConstraintError); VerifyOrReturnValue(commandData.transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsOverride <= kMaxOptionValue, Status::ConstraintError); VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); Status status = moveToSaturation(endpoint, commandData.saturation, commandData.transitionTime); @@ -1875,8 +1855,6 @@ Status ColorControlServer::stepSaturationCommand(EndpointId endpoint, const Comm VerifyOrReturnValue(stepSize != 0, Status::InvalidCommand); // Command Parameters constraint checks: VerifyOrReturnValue(transitionTime <= UINT8_MAX, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); Color16uTransitionState * colorSaturationTransitionState = getSaturationTransitionState(endpoint); VerifyOrReturnValue(colorSaturationTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -1943,8 +1921,6 @@ Status ColorControlServer::colorLoopCommand(EndpointId endpoint, const Commands: VerifyOrReturnValue(direction != ColorLoopDirectionEnum::kUnknownEnumValue, Status::InvalidCommand); VerifyOrReturnValue(updateFlags <= maxUpdateFlagsValue, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); uint16_t epIndex = getEndpointIndex(endpoint); ColorHueTransitionState * colorHueTransitionState = getColorHueTransitionStateByIndex(epIndex); @@ -2282,8 +2258,6 @@ Status ColorControlServer::moveToColorCommand(EndpointId endpoint, const Command { // Command Parameters constraint checks: VerifyOrReturnValue(commandData.transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsOverride <= kMaxOptionValue, Status::ConstraintError); VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); @@ -2310,9 +2284,6 @@ Status ColorControlServer::moveColorCommand(EndpointId endpoint, const Commands: auto & optionsMask = commandData.optionsMask; auto & optionsOverride = commandData.optionsOverride; - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); - uint16_t epIndex = getEndpointIndex(endpoint); Color16uTransitionState * colorXTransitionState = getXTransitionStateByIndex(epIndex); Color16uTransitionState * colorYTransitionState = getYTransitionStateByIndex(epIndex); @@ -2407,8 +2378,6 @@ Status ColorControlServer::stepColorCommand(EndpointId endpoint, const Commands: // Command Parameters constraint checks: VerifyOrReturnValue(transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); uint16_t epIndex = getEndpointIndex(endpoint); Color16uTransitionState * colorXTransitionState = getXTransitionStateByIndex(epIndex); @@ -2757,10 +2726,6 @@ Status ColorControlServer::moveColorTempCommand(EndpointId endpoint, VerifyOrReturnValue(moveMode != HueMoveMode::kUnknownEnumValue, Status::InvalidCommand); VerifyOrReturnValue((rate != 0 || moveMode == HueMoveMode::kStop), Status::InvalidCommand); - // Command Parameters constraint checks: - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); - Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); VerifyOrReturnValue(colorTempTransitionState != nullptr, Status::UnsupportedEndpoint); @@ -2853,8 +2818,6 @@ Status ColorControlServer::moveToColorTempCommand(EndpointId endpoint, { // Command Parameters constraint checks: VerifyOrReturnValue(commandData.transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(commandData.optionsOverride <= kMaxOptionValue, Status::ConstraintError); VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); @@ -2891,8 +2854,6 @@ Status ColorControlServer::stepColorTempCommand(EndpointId endpoint, // Command Parameters constraint checks: VerifyOrReturnValue(transitionTime <= kMaxtransitionTime, Status::ConstraintError); - VerifyOrReturnValue(optionsMask <= kMaxOptionValue, Status::ConstraintError); - VerifyOrReturnValue(optionsOverride <= kMaxOptionValue, Status::ConstraintError); Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); VerifyOrReturnValue(colorTempTransitionState != nullptr, Status::UnsupportedEndpoint); diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 6a97e19c47d602..561fa8a50fb1c6 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -239,9 +239,10 @@ class ColorControlServer uint16_t getEndpointIndex(chip::EndpointId); #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV - chip::Protocols::InteractionModel::Status moveToSaturation(chip::EndpointId endpoint, uint8_t saturation, uint16_t transitionTime); - chip::Protocols::InteractionModel::Status moveToHueAndSaturation(chip::EndpointId endpoint, uint16_t hue, uint8_t saturation, uint16_t transitionTime, - bool isEnhanced); + chip::Protocols::InteractionModel::Status moveToSaturation(chip::EndpointId endpoint, uint8_t saturation, + uint16_t transitionTime); + chip::Protocols::InteractionModel::Status moveToHueAndSaturation(chip::EndpointId endpoint, uint16_t hue, uint8_t saturation, + uint16_t transitionTime, bool isEnhanced); ColorHueTransitionState * getColorHueTransitionState(chip::EndpointId endpoint); Color16uTransitionState * getSaturationTransitionState(chip::EndpointId endpoint); ColorHueTransitionState * getColorHueTransitionStateByIndex(uint16_t index); @@ -262,7 +263,8 @@ class ColorControlServer #endif // MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_XY - chip::Protocols::InteractionModel::Status moveToColor(chip::EndpointId endpoint, uint16_t colorX, uint16_t colorY, uint16_t transitionTime); + chip::Protocols::InteractionModel::Status moveToColor(chip::EndpointId endpoint, uint16_t colorX, uint16_t colorY, + uint16_t transitionTime); Color16uTransitionState * getXTransitionState(chip::EndpointId endpoint); Color16uTransitionState * getYTransitionState(chip::EndpointId endpoint); Color16uTransitionState * getXTransitionStateByIndex(uint16_t index); @@ -289,8 +291,6 @@ class ColorControlServer static_assert(kColorControlClusterServerMaxEndpointCount <= kEmberInvalidEndpointIndex, "ColorControl endpoint count error"); static constexpr uint16_t kMaxtransitionTime = 65534; // Max value as defined by the spec. - static constexpr chip::BitMask kMaxOptionValue = - chip::app::Clusters::ColorControl::OptionsBitmap::kExecuteIfOff; // add any new bitmap field to this value! #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_HSV ColorHueTransitionState colorHueTransitionStates[kColorControlClusterServerMaxEndpointCount];