Skip to content

Commit

Permalink
Make targetColorMode typesafe
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Oct 10, 2023
1 parent 6967453 commit 98e0b56
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
#endif

// Initialize action attributes to default values in case they are not in the scene
uint8_t targetColorMode = 0x00;
EnahncedColorModeEnum targetEnhancedColorMode = EnhancedColorModeEnum::kCurrentHueAndCurrentSaturation;
uint8_t loopActiveValue = 0x00;
uint8_t loopDirectionValue = 0x00;
uint16_t loopTimeValue = 0x0019; // Default loop time value according to spec
Expand Down Expand Up @@ -256,7 +256,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
case Attributes::EnhancedColorMode::Id:
if (decodePair.attributeValue <= static_cast<uint8_t>(ColorControlServer::ColorMode::COLOR_MODE_EHSV))
{
targetColorMode = static_cast<uint8_t>(decodePair.attributeValue);
targetEnhancedColorMode = static_cast<EnhancedColorModeEnum>(decodePair.attributeValue);
}
break;
default:
Expand All @@ -267,9 +267,11 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
ReturnErrorOnFailure(pair_iterator.GetStatus());

// Switch to the mode saved in the scene
if (SupportsColorMode(endpoint, static_cast<EnhancedColorModeEnum>(targetColorMode)))
if (SupportsColorMode(endpoint, targetEnhancedColorMode))
{
ColorControlServer::Instance().handleModeSwitch(endpoint, targetColorMode);
// TODO: this seems buggy: how do we know in SupportsColorMode and handleModeSwitch
// if the color mode is "ColorMode" or "EnhancedColorMode"
ColorControlServer::Instance().handleModeSwitch(endpoint, targetEnhancedColorMode);
}
else
{
Expand Down

0 comments on commit 98e0b56

Please sign in to comment.