From 98e0b56f944a90ea3be576eb75dd236c83fc43c3 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 10 Oct 2023 16:24:08 -0400 Subject: [PATCH] Make targetColorMode typesafe --- .../color-control-server/color-control-server.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 92e6a348b901b2..77ca91d2e69719 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -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 @@ -256,7 +256,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl case Attributes::EnhancedColorMode::Id: if (decodePair.attributeValue <= static_cast(ColorControlServer::ColorMode::COLOR_MODE_EHSV)) { - targetColorMode = static_cast(decodePair.attributeValue); + targetEnhancedColorMode = static_cast(decodePair.attributeValue); } break; default: @@ -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(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 {