Skip to content

Commit

Permalink
remove contraint error on optionsMask and optionsOverride undefined bits
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinez-silabs committed Oct 22, 2024
1 parent e56ee3d commit 29a9366
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 45 deletions.
39 changes: 0 additions & 39 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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<chip::app::Clusters::ColorControl::OptionsBitmap> 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];
Expand Down

0 comments on commit 29a9366

Please sign in to comment.