@@ -37,27 +37,27 @@ using chip::Protocols::InteractionModel::Status;
37
37
// These constants are NOT currently spec compliant
38
38
// These should be changed once we have real specification enumeration
39
39
// 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
61
61
62
62
#if defined(MATTER_DM_PLUGIN_SCENES_MANAGEMENT) && CHIP_CONFIG_SCENES_USE_DEFAULT_HANDLERS
63
63
class DefaultColorControlSceneHandler : public scenes ::DefaultSceneHandlerImpl
@@ -173,12 +173,12 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
173
173
AddAttributeValuePair (pairs, Attributes::ColorTemperatureMireds::Id, temperatureValue, attributeCount);
174
174
}
175
175
176
- uint8_t modeValue;
176
+ ColorControl::EnhancedColorMode modeValue;
177
177
if (Status::Success != Attributes::EnhancedColorMode::Get (endpoint, &modeValue))
178
178
{
179
179
modeValue = ColorControl::EnhancedColorMode::kCurrentXAndCurrentY ; // Default mode value according to spec
180
180
}
181
- AddAttributeValuePair (pairs, Attributes::EnhancedColorMode::Id, modeValue, attributeCount);
181
+ AddAttributeValuePair (pairs, Attributes::EnhancedColorMode::Id, static_cast < uint32_t >( modeValue) , attributeCount);
182
182
183
183
app::DataModel::List<AttributeValuePair> attributeValueList (pairs, attributeCount);
184
184
@@ -223,7 +223,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
223
223
#endif
224
224
225
225
// 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 ;
227
227
uint8_t loopActiveValue = 0x00 ;
228
228
uint8_t loopDirectionValue = 0x00 ;
229
229
uint16_t loopTimeValue = 0x0019 ; // Default loop time value according to spec
@@ -282,7 +282,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
282
282
if (decodePair.attributeValue <=
283
283
static_cast <uint8_t >(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation ))
284
284
{
285
- targetColorMode = static_cast <uint8_t >(decodePair.attributeValue );
285
+ targetColorMode =static_cast <ColorControl::EnhancedColorMode >(decodePair.attributeValue );
286
286
}
287
287
break ;
288
288
default :
@@ -350,7 +350,7 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
350
350
}
351
351
352
352
private:
353
- bool SupportsColorMode (EndpointId endpoint, uint8_t mode)
353
+ bool SupportsColorMode (EndpointId endpoint, ColorControl::EnhancedColorMode mode)
354
354
{
355
355
switch (mode)
356
356
{
@@ -502,7 +502,7 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
502
502
return true ;
503
503
}
504
504
505
- uint8_t options = 0x00 ;
505
+ chip::BitMask<chip::app::Clusters::ColorControl::ColorControlOptions> options = 0x00 ;
506
506
Attributes::Options::Get (endpoint, &options);
507
507
508
508
bool on = true ;
@@ -534,18 +534,18 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
534
534
// 0xFF are the default values passed to the command handler when
535
535
// the payload is not present - in that case there is use of option
536
536
// attribute to decide execution of the command
537
- return READBITS ( options, ColorControl::Options ::kExecuteIfOff );
537
+ return options. GetField ( ColorControl::ColorControlOptions ::kExecuteIfOff );
538
538
}
539
539
// ---------- The above is to distinguish if the payload is present or not
540
540
541
- if (READBITS (optionMask, ColorControl::Options ::kExecuteIfOff ))
541
+ if (READBITS (optionMask, static_cast < uint8_t >( ColorControl::ColorControlOptions ::kExecuteIfOff ) ))
542
542
{
543
543
// Mask is present and set in the command payload, this indicates
544
544
// use the override as temporary option
545
- return READBITS (optionOverride, ColorControl::Options ::kExecuteIfOff );
545
+ return READBITS (optionOverride, static_cast < uint8_t >( ColorControl::ColorControlOptions ::kExecuteIfOff ) );
546
546
}
547
547
// if we are here - use the option attribute bits
548
- return ( READBITS ( options, ColorControl::Options ::kExecuteIfOff ) );
548
+ return options. GetField ( ColorControl::ColorControlOptions ::kExecuteIfOff );
549
549
}
550
550
551
551
/* *
@@ -559,14 +559,14 @@ bool ColorControlServer::shouldExecuteIfOff(EndpointId endpoint, uint8_t optionM
559
559
* @param endpoint
560
560
* @param newColorMode
561
561
*/
562
- void ColorControlServer::handleModeSwitch (EndpointId endpoint, uint8_t newColorMode)
562
+ void ColorControlServer::handleModeSwitch (EndpointId endpoint, ColorControl::EnhancedColorMode newColorMode)
563
563
{
564
564
uint8_t oldColorMode = 0 ;
565
565
Attributes::ColorMode::Get (endpoint, &oldColorMode);
566
566
567
567
uint8_t colorModeTransition;
568
568
569
- if (oldColorMode == newColorMode)
569
+ if (oldColorMode == static_cast < uint8_t >( newColorMode) )
570
570
{
571
571
return ;
572
572
}
@@ -578,9 +578,9 @@ void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorM
578
578
// EnhancedColorMode
579
579
newColorMode = ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation ;
580
580
}
581
- Attributes::ColorMode::Set (endpoint, newColorMode);
581
+ Attributes::ColorMode::Set (endpoint, static_cast < uint8_t >( newColorMode) );
582
582
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) );
584
584
585
585
// Note: It may be OK to not do anything here.
586
586
switch (colorModeTransition)
@@ -1282,11 +1282,11 @@ Status ColorControlServer::moveToHueAndSaturation(uint16_t hue, uint8_t saturati
1282
1282
// Handle color mode transition, if necessary.
1283
1283
if (isEnhanced)
1284
1284
{
1285
- handleModeSwitch (endpoint, EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation );
1285
+ handleModeSwitch (endpoint, ColorControl:: EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation );
1286
1286
}
1287
1287
else
1288
1288
{
1289
- handleModeSwitch (endpoint, EnhancedColorMode::kCurrentHueAndCurrentSaturation );
1289
+ handleModeSwitch (endpoint, ColorControl:: EnhancedColorMode::kCurrentHueAndCurrentSaturation );
1290
1290
}
1291
1291
1292
1292
// now, kick off the state machine.
@@ -2173,7 +2173,7 @@ Status ColorControlServer::moveToColor(uint16_t colorX, uint16_t colorY, uint16_
2173
2173
stopAllColorTransitions (endpoint);
2174
2174
2175
2175
// Handle color mode transition, if necessary.
2176
- handleModeSwitch (endpoint, EnhancedColorMode::kCurrentXAndCurrentY );
2176
+ handleModeSwitch (endpoint, ColorControl:: EnhancedColorMode::kCurrentXAndCurrentY );
2177
2177
2178
2178
// now, kick off the state machine.
2179
2179
Attributes::CurrentX::Get (endpoint, &(colorXTransitionState->initialValue ));
@@ -2578,11 +2578,10 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint)
2578
2578
if (status == Status::Success)
2579
2579
{
2580
2580
// Set ColorMode attributes to reflect ColorTemperature.
2581
- uint8_t updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature ;
2581
+ uint8_t updateColorMode = static_cast < uint8_t >( ColorControl::EnhancedColorMode::kColorTemperature ) ;
2582
2582
Attributes::ColorMode::Set (endpoint, updateColorMode);
2583
2583
2584
- updateColorMode = ColorControl::EnhancedColorMode::kColorTemperature ;
2585
- Attributes::EnhancedColorMode::Set (endpoint, updateColorMode);
2584
+ Attributes::EnhancedColorMode::Set (endpoint, static_cast <ColorControl::EnhancedColorMode>(updateColorMode));
2586
2585
}
2587
2586
}
2588
2587
}
@@ -2902,7 +2901,7 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint)
2902
2901
uint8_t colorMode = 0 ;
2903
2902
Attributes::ColorMode::Get (endpoint, &colorMode);
2904
2903
2905
- if (colorMode == ColorControl::EnhancedColorMode::kColorTemperature )
2904
+ if (static_cast <ColorControl::EnhancedColorMode>( colorMode) == ColorControl::EnhancedColorMode::kColorTemperature )
2906
2905
{
2907
2906
app::DataModel::Nullable<uint8_t > currentLevel;
2908
2907
Status status = LevelControl::Attributes::CurrentLevel::Get (endpoint, currentLevel);
0 commit comments