Skip to content

Commit

Permalink
build error resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirsrin committed May 28, 2024
1 parent 9619c2f commit 61055ec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
83 changes: 41 additions & 42 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<uint32_t>(modeValue), attributeCount);

app::DataModel::List<AttributeValuePair> attributeValueList(pairs, attributeCount);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -282,7 +282,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
if (decodePair.attributeValue <=
static_cast<uint8_t>(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation))
{
targetColorMode = static_cast<uint8_t>(decodePair.attributeValue);
targetColorMode =static_cast<ColorControl::EnhancedColorMode>(decodePair.attributeValue);
}
break;
default:
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -502,7 +502,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
return true;
}

uint8_t options = 0x00;
chip::BitMask<chip::app::Clusters::ColorControl::ColorControlOptions> options = 0x00;
Attributes::Options::Get(endpoint, &options);

bool on = true;
Expand Down Expand Up @@ -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<uint8_t>(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<uint8_t>(ColorControl::ColorControlOptions::kExecuteIfOff));
}
// if we are here - use the option attribute bits
return (READBITS(options, ColorControl::Options::kExecuteIfOff));
return options.GetField(ColorControl::ColorControlOptions::kExecuteIfOff);
}

/**
Expand All @@ -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<uint8_t>(newColorMode))
{
return;
}
Expand All @@ -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<uint8_t>(newColorMode));

colorModeTransition = static_cast<uint8_t>((newColorMode << 4) + oldColorMode);
colorModeTransition = static_cast<uint8_t>((static_cast<uint8_t>(newColorMode) << 4) + static_cast<uint8_t>(oldColorMode));

// Note: It may be OK to not do anything here.
switch (colorModeTransition)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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<uint8_t>(ColorControl::EnhancedColorMode::kColorTemperature);
Attributes::ColorMode::Set(endpoint, updateColorMode);

updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature;
Attributes::EnhancedColorMode::Set(endpoint, updateColorMode);
Attributes::EnhancedColorMode::Set(endpoint, static_cast<ColorControl::EnhancedColorMode>(updateColorMode));
}
}
}
Expand Down Expand Up @@ -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<ColorControl::EnhancedColorMode>(colorMode) == ColorControl::EnhancedColorMode::kColorTemperature)
{
app::DataModel::Nullable<uint8_t> currentLevel;
Status status = LevelControl::Attributes::CurrentLevel::Get(endpoint, currentLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 61055ec

Please sign in to comment.