From 61055ecdd8cfa77391ffc1e43e92ef93bf468e68 Mon Sep 17 00:00:00 2001 From: Thirupathi S Date: Tue, 28 May 2024 12:02:22 +0530 Subject: [PATCH] build error resolved --- .../color-control-server.cpp | 83 +++++++++---------- .../color-control-server.h | 2 +- 2 files changed, 42 insertions(+), 43 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 508f4b691bb0d1..8f7ddb397e8895 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -37,27 +37,27 @@ using chip::Protocols::InteractionModel::Status; // These constants are NOT currently spec compliant // These should be changed once we have real specification enumeration // names. -namespace chip { -namespace app { -namespace Clusters { -namespace ColorControl { - -namespace EnhancedColorMode { -constexpr uint8_t kCurrentHueAndCurrentSaturation = ColorControlServer::EnhancedColorMode::kCurrentHueAndCurrentSaturation; -constexpr uint8_t kCurrentXAndCurrentY = ColorControlServer::EnhancedColorMode::kCurrentXAndCurrentY; -constexpr uint8_t kColorTemperature = ColorControlServer::EnhancedColorMode::kColorTemperature; -constexpr uint8_t kEnhancedCurrentHueAndCurrentSaturation = - ColorControlServer::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation; -} // namespace EnhancedColorMode - -namespace Options { -constexpr uint8_t kExecuteIfOff = 1; -} // namespace Options - -} // namespace ColorControl -} // namespace Clusters -} // namespace app -} // namespace chip +// namespace chip { +// namespace app { +// namespace Clusters { +// namespace ColorControl { + +// namespace EnhancedColorMode { +// constexpr uint8_t kCurrentHueAndCurrentSaturation = ColorControlServer::EnhancedColorMode::kCurrentHueAndCurrentSaturation; +// constexpr uint8_t kCurrentXAndCurrentY = ColorControlServer::EnhancedColorMode::kCurrentXAndCurrentY; +// constexpr uint8_t kColorTemperature = ColorControlServer::EnhancedColorMode::kColorTemperature; +// constexpr uint8_t kEnhancedCurrentHueAndCurrentSaturation = +// ColorControlServer::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation; +// } // namespace EnhancedColorMode + +// namespace Options { +// constexpr uint8_t kExecuteIfOff = 1; +// } // namespace Options + +// } // namespace ColorControl +// } // namespace Clusters +// } // namespace app +// } // namespace chip #if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl @@ -173,12 +173,12 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl AddAttributeValuePair(pairs, Attributes::ColorTemperatureMireds::Id, temperatureValue, attributeCount); } - uint8_t modeValue; + ColorControl::EnhancedColorMode modeValue; if (Status::Success != Attributes::EnhancedColorMode::Get(endpoint, &modeValue)) { modeValue = ColorControl::EnhancedColorMode::kCurrentXAndCurrentY; // Default mode value according to spec } - AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, modeValue, attributeCount); + AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, static_cast(modeValue), attributeCount); app::DataModel::List attributeValueList(pairs, attributeCount); @@ -223,7 +223,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; + ColorControl::EnhancedColorMode targetColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation; uint8_t loopActiveValue = 0x00; uint8_t loopDirectionValue = 0x00; uint16_t loopTimeValue = 0x0019; // Default loop time value according to spec @@ -282,7 +282,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl if (decodePair.attributeValue <= static_cast(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation)) { - targetColorMode = static_cast(decodePair.attributeValue); + targetColorMode =static_cast(decodePair.attributeValue); } break; default: @@ -350,7 +350,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl } private: - bool SupportsColorMode(EndpointId endpoint, uint8_t mode) + bool SupportsColorMode(EndpointId endpoint, ColorControl::EnhancedColorMode mode) { switch (mode) { @@ -502,7 +502,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM return true; } - uint8_t options = 0x00; + chip::BitMask options = 0x00; Attributes::Options::Get(endpoint, &options); bool on = true; @@ -534,18 +534,18 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM // 0xFF are the default values passed to the command handler when // the payload is not present - in that case there is use of option // attribute to decide execution of the command - return READBITS(options, ColorControl::Options::kExecuteIfOff); + return options.GetField(ColorControl::ColorControlOptions::kExecuteIfOff); } // ---------- The above is to distinguish if the payload is present or not - if (READBITS(optionMask, ColorControl::Options::kExecuteIfOff)) + if (READBITS(optionMask, static_cast(ColorControl::ColorControlOptions::kExecuteIfOff))) { // Mask is present and set in the command payload, this indicates // use the override as temporary option - return READBITS(optionOverride, ColorControl::Options::kExecuteIfOff); + return READBITS(optionOverride, static_cast(ColorControl::ColorControlOptions::kExecuteIfOff)); } // if we are here - use the option attribute bits - return (READBITS(options, ColorControl::Options::kExecuteIfOff)); + return options.GetField(ColorControl::ColorControlOptions::kExecuteIfOff); } /** @@ -559,14 +559,14 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM * @param endpoint * @param newColorMode */ -void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorMode) +void ColorControlServer::handleModeSwitch(EndpointId endpoint, ColorControl::EnhancedColorMode newColorMode) { uint8_t oldColorMode = 0; Attributes::ColorMode::Get(endpoint, &oldColorMode); uint8_t colorModeTransition; - if (oldColorMode == newColorMode) + if (oldColorMode == static_cast(newColorMode)) { return; } @@ -578,9 +578,9 @@ void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorM // EnhancedColorMode newColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation; } - Attributes::ColorMode::Set(endpoint, newColorMode); + Attributes::ColorMode::Set(endpoint, static_cast(newColorMode)); - colorModeTransition = static_cast((newColorMode << 4) + oldColorMode); + colorModeTransition = static_cast((static_cast(newColorMode) << 4) + static_cast(oldColorMode)); // Note: It may be OK to not do anything here. switch (colorModeTransition) @@ -1282,11 +1282,11 @@ Status ColorControlServer::moveToHueAndSaturation(uint16_t hue, uint8_t saturati // Handle color mode transition, if necessary. if (isEnhanced) { - handleModeSwitch(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation); } else { - handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation); + handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation); } // now, kick off the state machine. @@ -2173,7 +2173,7 @@ Status ColorControlServer::moveToColor(uint16_t colorX, uint16_t colorY, uint16_ stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, EnhancedColorMode::kCurrentXAndCurrentY); + handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY); // now, kick off the state machine. Attributes::CurrentX::Get(endpoint, &(colorXTransitionState->initialValue)); @@ -2578,11 +2578,10 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint) if (status == Status::Success) { // Set ColorMode attributes to reflect ColorTemperature. - uint8_t updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature; + uint8_t updateColorMode = static_cast(ColorControl::EnhancedColorMode::kColorTemperature); Attributes::ColorMode::Set(endpoint, updateColorMode); - updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature; - Attributes::EnhancedColorMode::Set(endpoint, updateColorMode); + Attributes::EnhancedColorMode::Set(endpoint, static_cast(updateColorMode)); } } } @@ -2902,7 +2901,7 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint) uint8_t colorMode = 0; Attributes::ColorMode::Get(endpoint, &colorMode); - if (colorMode == ColorControl::EnhancedColorMode::kColorTemperature) + if (static_cast(colorMode) == ColorControl::EnhancedColorMode::kColorTemperature) { app::DataModel::Nullable currentLevel; Status status = LevelControl::Attributes::CurrentLevel::Get(endpoint, currentLevel); 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 72dabb5600ff33..86e92c1c21d802 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -196,7 +196,7 @@ class ColorControlServer ColorControlServer() {} bool shouldExecuteIfOff(chip::EndpointId endpoint, uint8_t optionMask, uint8_t optionOverride); - void handleModeSwitch(chip::EndpointId endpoint, uint8_t newColorMode); + void handleModeSwitch(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorMode newColorMode); uint16_t computeTransitionTimeFromStateAndRate(Color16uTransitionState * p, uint16_t rate); EmberEventControl * getEventControl(chip::EndpointId endpoint); void computePwmFromHsv(chip::EndpointId endpoint);