Skip to content

Commit 61055ec

Browse files
committed
build error resolved
1 parent 9619c2f commit 61055ec

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

src/app/clusters/color-control-server/color-control-server.cpp

+41-42
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ using chip::Protocols::InteractionModel::Status;
3737
// These constants are NOT currently spec compliant
3838
// These should be changed once we have real specification enumeration
3939
// names.
40-
namespace chip {
41-
namespace app {
42-
namespace Clusters {
43-
namespace ColorControl {
44-
45-
namespace EnhancedColorMode {
46-
constexpr uint8_t kCurrentHueAndCurrentSaturation = ColorControlServer::EnhancedColorMode::kCurrentHueAndCurrentSaturation;
47-
constexpr uint8_t kCurrentXAndCurrentY = ColorControlServer::EnhancedColorMode::kCurrentXAndCurrentY;
48-
constexpr uint8_t kColorTemperature = ColorControlServer::EnhancedColorMode::kColorTemperature;
49-
constexpr uint8_t kEnhancedCurrentHueAndCurrentSaturation =
50-
ColorControlServer::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation;
51-
} // namespace EnhancedColorMode
52-
53-
namespace Options {
54-
constexpr uint8_t kExecuteIfOff = 1;
55-
} // namespace Options
56-
57-
} // namespace ColorControl
58-
} // namespace Clusters
59-
} // namespace app
60-
} // namespace chip
40+
// namespace chip {
41+
// namespace app {
42+
// namespace Clusters {
43+
// namespace ColorControl {
44+
45+
// namespace EnhancedColorMode {
46+
// constexpr uint8_t kCurrentHueAndCurrentSaturation = ColorControlServer::EnhancedColorMode::kCurrentHueAndCurrentSaturation;
47+
// constexpr uint8_t kCurrentXAndCurrentY = ColorControlServer::EnhancedColorMode::kCurrentXAndCurrentY;
48+
// constexpr uint8_t kColorTemperature = ColorControlServer::EnhancedColorMode::kColorTemperature;
49+
// constexpr uint8_t kEnhancedCurrentHueAndCurrentSaturation =
50+
// ColorControlServer::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation;
51+
// } // namespace EnhancedColorMode
52+
53+
// namespace Options {
54+
// constexpr uint8_t kExecuteIfOff = 1;
55+
// } // namespace Options
56+
57+
// } // namespace ColorControl
58+
// } // namespace Clusters
59+
// } // namespace app
60+
// } // namespace chip
6161

6262
#if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
6363
class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
@@ -173,12 +173,12 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
173173
AddAttributeValuePair(pairs, Attributes::ColorTemperatureMireds::Id, temperatureValue, attributeCount);
174174
}
175175

176-
uint8_t modeValue;
176+
ColorControl::EnhancedColorMode modeValue;
177177
if (Status::Success != Attributes::EnhancedColorMode::Get(endpoint, &modeValue))
178178
{
179179
modeValue = ColorControl::EnhancedColorMode::kCurrentXAndCurrentY; // Default mode value according to spec
180180
}
181-
AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, modeValue, attributeCount);
181+
AddAttributeValuePair(pairs, Attributes::EnhancedColorMode::Id, static_cast<uint32_t>(modeValue), attributeCount);
182182

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

@@ -223,7 +223,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
223223
#endif
224224

225225
// Initialize action attributes to default values in case they are not in the scene
226-
uint8_t targetColorMode = 0x00;
226+
ColorControl::EnhancedColorMode targetColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation;
227227
uint8_t loopActiveValue = 0x00;
228228
uint8_t loopDirectionValue = 0x00;
229229
uint16_t loopTimeValue = 0x0019; // Default loop time value according to spec
@@ -282,7 +282,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
282282
if (decodePair.attributeValue <=
283283
static_cast<uint8_t>(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation))
284284
{
285-
targetColorMode = static_cast<uint8_t>(decodePair.attributeValue);
285+
targetColorMode =static_cast<ColorControl::EnhancedColorMode>(decodePair.attributeValue);
286286
}
287287
break;
288288
default:
@@ -350,7 +350,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
350350
}
351351

352352
private:
353-
bool SupportsColorMode(EndpointId endpoint, uint8_t mode)
353+
bool SupportsColorMode(EndpointId endpoint, ColorControl::EnhancedColorMode mode)
354354
{
355355
switch (mode)
356356
{
@@ -502,7 +502,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
502502
return true;
503503
}
504504

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

508508
bool on = true;
@@ -534,18 +534,18 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
534534
// 0xFF are the default values passed to the command handler when
535535
// the payload is not present - in that case there is use of option
536536
// attribute to decide execution of the command
537-
return READBITS(options, ColorControl::Options::kExecuteIfOff);
537+
return options.GetField(ColorControl::ColorControlOptions::kExecuteIfOff);
538538
}
539539
// ---------- The above is to distinguish if the payload is present or not
540540

541-
if (READBITS(optionMask, ColorControl::Options::kExecuteIfOff))
541+
if (READBITS(optionMask, static_cast<uint8_t>(ColorControl::ColorControlOptions::kExecuteIfOff)))
542542
{
543543
// Mask is present and set in the command payload, this indicates
544544
// use the override as temporary option
545-
return READBITS(optionOverride, ColorControl::Options::kExecuteIfOff);
545+
return READBITS(optionOverride, static_cast<uint8_t>(ColorControl::ColorControlOptions::kExecuteIfOff));
546546
}
547547
// if we are here - use the option attribute bits
548-
return (READBITS(options, ColorControl::Options::kExecuteIfOff));
548+
return options.GetField(ColorControl::ColorControlOptions::kExecuteIfOff);
549549
}
550550

551551
/**
@@ -559,14 +559,14 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
559559
* @param endpoint
560560
* @param newColorMode
561561
*/
562-
void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorMode)
562+
void ColorControlServer::handleModeSwitch(EndpointId endpoint, ColorControl::EnhancedColorMode newColorMode)
563563
{
564564
uint8_t oldColorMode = 0;
565565
Attributes::ColorMode::Get(endpoint, &oldColorMode);
566566

567567
uint8_t colorModeTransition;
568568

569-
if (oldColorMode == newColorMode)
569+
if (oldColorMode == static_cast<uint8_t>(newColorMode))
570570
{
571571
return;
572572
}
@@ -578,9 +578,9 @@ void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorM
578578
// EnhancedColorMode
579579
newColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation;
580580
}
581-
Attributes::ColorMode::Set(endpoint, newColorMode);
581+
Attributes::ColorMode::Set(endpoint, static_cast<uint8_t>(newColorMode));
582582

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

585585
// Note: It may be OK to not do anything here.
586586
switch (colorModeTransition)
@@ -1282,11 +1282,11 @@ Status ColorControlServer::moveToHueAndSaturation(uint16_t hue, uint8_t saturati
12821282
// Handle color mode transition, if necessary.
12831283
if (isEnhanced)
12841284
{
1285-
handleModeSwitch(endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation);
1285+
handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation);
12861286
}
12871287
else
12881288
{
1289-
handleModeSwitch(endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation);
1289+
handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation);
12901290
}
12911291

12921292
// now, kick off the state machine.
@@ -2173,7 +2173,7 @@ Status ColorControlServer::moveToColor(uint16_t colorX, uint16_t colorY, uint16_
21732173
stopAllColorTransitions(endpoint);
21742174

21752175
// Handle color mode transition, if necessary.
2176-
handleModeSwitch(endpoint, EnhancedColorMode::kCurrentXAndCurrentY);
2176+
handleModeSwitch(endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY);
21772177

21782178
// now, kick off the state machine.
21792179
Attributes::CurrentX::Get(endpoint, &(colorXTransitionState->initialValue));
@@ -2578,11 +2578,10 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint)
25782578
if (status == Status::Success)
25792579
{
25802580
// Set ColorMode attributes to reflect ColorTemperature.
2581-
uint8_t updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature;
2581+
uint8_t updateColorMode = static_cast<uint8_t>(ColorControl::EnhancedColorMode::kColorTemperature);
25822582
Attributes::ColorMode::Set(endpoint, updateColorMode);
25832583

2584-
updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature;
2585-
Attributes::EnhancedColorMode::Set(endpoint, updateColorMode);
2584+
Attributes::EnhancedColorMode::Set(endpoint, static_cast<ColorControl::EnhancedColorMode>(updateColorMode));
25862585
}
25872586
}
25882587
}
@@ -2902,7 +2901,7 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint)
29022901
uint8_t colorMode = 0;
29032902
Attributes::ColorMode::Get(endpoint, &colorMode);
29042903

2905-
if (colorMode == ColorControl::EnhancedColorMode::kColorTemperature)
2904+
if (static_cast<ColorControl::EnhancedColorMode>(colorMode) == ColorControl::EnhancedColorMode::kColorTemperature)
29062905
{
29072906
app::DataModel::Nullable<uint8_t> currentLevel;
29082907
Status status = LevelControl::Attributes::CurrentLevel::Get(endpoint, currentLevel);

src/app/clusters/color-control-server/color-control-server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class ColorControlServer
196196

197197
ColorControlServer() {}
198198
bool shouldExecuteIfOff(chip::EndpointId endpoint, uint8_t optionMask, uint8_t optionOverride);
199-
void handleModeSwitch(chip::EndpointId endpoint, uint8_t newColorMode);
199+
void handleModeSwitch(chip::EndpointId endpoint, chip::app::Clusters::ColorControl::EnhancedColorMode newColorMode);
200200
uint16_t computeTransitionTimeFromStateAndRate(Color16uTransitionState * p, uint16_t rate);
201201
EmberEventControl * getEventControl(chip::EndpointId endpoint);
202202
void computePwmFromHsv(chip::EndpointId endpoint);

0 commit comments

Comments
 (0)