Skip to content

Commit a6dc62c

Browse files
Stop generating weakly-typed enums for the color loop enum types. (#25790)
* Stop generating weakly-typed enums for the color loop enum types. * Regenerate generated code.
1 parent e214d1e commit a6dc62c

File tree

7 files changed

+21
-86
lines changed

7 files changed

+21
-86
lines changed

examples/all-clusters-app/ameba/main/include/ColorControlCommands.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E
505505
case Clusters::ColorControl::Commands::ColorLoopSet::Id:
506506
colorLoopSetCommand.updateFlags =
507507
static_cast<chip::BitMask<chip::app::Clusters::ColorControl::ColorLoopUpdateFlags>>(data->args[0]);
508-
colorLoopSetCommand.action = static_cast<EmberAfColorLoopAction>(data->args[1]);
509-
colorLoopSetCommand.direction = static_cast<EmberAfColorLoopDirection>(data->args[2]);
508+
colorLoopSetCommand.action = static_cast<ColorLoopAction>(data->args[1]);
509+
colorLoopSetCommand.direction = static_cast<ColorLoopDirection>(data->args[2]);
510510
colorLoopSetCommand.time = static_cast<uint16_t>(data->args[3]);
511511
colorLoopSetCommand.startHue = static_cast<uint16_t>(data->args[4]);
512512
colorLoopSetCommand.optionsMask = static_cast<uint8_t>(data->args[5]);
@@ -708,8 +708,8 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb
708708
case Clusters::ColorControl::Commands::ColorLoopSet::Id:
709709
colorLoopSetCommand.updateFlags =
710710
static_cast<chip::BitMask<chip::app::Clusters::ColorControl::ColorLoopUpdateFlags>>(data->args[0]);
711-
colorLoopSetCommand.action = static_cast<EmberAfColorLoopAction>(data->args[1]);
712-
colorLoopSetCommand.direction = static_cast<EmberAfColorLoopDirection>(data->args[2]);
711+
colorLoopSetCommand.action = static_cast<ColorLoopAction>(data->args[1]);
712+
colorLoopSetCommand.direction = static_cast<ColorLoopDirection>(data->args[2]);
713713
colorLoopSetCommand.time = static_cast<uint16_t>(data->args[3]);
714714
colorLoopSetCommand.startHue = static_cast<uint16_t>(data->args[4]);
715715
colorLoopSetCommand.optionsMask = static_cast<uint8_t>(data->args[5]);

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

+17-21
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt
608608

609609
colorHueTransitionState->initialEnhancedHue = startHue;
610610

611-
if (direction)
611+
if (direction == to_underlying(ColorLoopDirection::kIncrementHue))
612612
{
613613
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(startHue - 1);
614614
}
@@ -617,7 +617,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt
617617
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(startHue + 1);
618618
}
619619

620-
colorHueTransitionState->up = direction;
620+
colorHueTransitionState->up = (direction == to_underlying(ColorLoopDirection::kIncrementHue));
621621
colorHueTransitionState->repeat = true;
622622

623623
colorHueTransitionState->stepsRemaining = static_cast<uint16_t>(time * TRANSITION_TIME_1S);
@@ -1496,9 +1496,9 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
14961496
bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
14971497
const Commands::ColorLoopSet::DecodableType & commandData)
14981498
{
1499-
uint8_t updateFlags = commandData.updateFlags.Raw();
1500-
uint8_t action = commandData.action;
1501-
uint8_t direction = commandData.direction;
1499+
auto updateFlags = commandData.updateFlags;
1500+
auto action = commandData.action;
1501+
auto direction = commandData.direction;
15021502
uint16_t time = commandData.time;
15031503
uint16_t startHue = commandData.startHue;
15041504
uint8_t optionsMask = commandData.optionsMask;
@@ -1512,10 +1512,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
15121512
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);
15131513

15141514
// Validate the action and direction parameters of the command
1515-
if ((action != EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE &&
1516-
action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE &&
1517-
action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE) ||
1518-
(direction != DECREMENT_HUE && direction != INCREMENT_HUE))
1515+
if (action == ColorLoopAction::kUnknownEnumValue || direction == ColorLoopDirection::kUnknownEnumValue)
15191516
{
15201517
commandObj->AddStatus(commandPath, Status::InvalidCommand);
15211518
return true;
@@ -1529,20 +1526,19 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
15291526

15301527
Attributes::ColorLoopActive::Get(endpoint, &isColorLoopActive);
15311528

1532-
deactiveColorLoop =
1533-
(updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION) && (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE);
1529+
deactiveColorLoop = updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction) && (action == ColorLoopAction::kDeactivate);
15341530

1535-
if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_DIRECTION)
1531+
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction))
15361532
{
1537-
Attributes::ColorLoopDirection::Set(endpoint, direction);
1533+
Attributes::ColorLoopDirection::Set(endpoint, to_underlying(direction));
15381534

15391535
// Checks if color loop is active and stays active
15401536
if (isColorLoopActive && !deactiveColorLoop)
15411537
{
1542-
colorHueTransitionState->up = direction;
1538+
colorHueTransitionState->up = (direction == ColorLoopDirection::kIncrementHue);
15431539
colorHueTransitionState->initialEnhancedHue = colorHueTransitionState->currentEnhancedHue;
15441540

1545-
if (direction)
1541+
if (direction == ColorLoopDirection::kIncrementHue)
15461542
{
15471543
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(colorHueTransitionState->initialEnhancedHue - 1);
15481544
}
@@ -1554,7 +1550,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
15541550
}
15551551
}
15561552

1557-
if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_TIME)
1553+
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateTime))
15581554
{
15591555
Attributes::ColorLoopTime::Set(endpoint, time);
15601556

@@ -1576,14 +1572,14 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
15761572
}
15771573
}
15781574

1579-
if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_START_HUE)
1575+
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateStartHue))
15801576
{
15811577
Attributes::ColorLoopStartEnhancedHue::Set(endpoint, startHue);
15821578
}
15831579

1584-
if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION)
1580+
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction))
15851581
{
1586-
if (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE)
1582+
if (action == ColorLoopAction::kDeactivate)
15871583
{
15881584
if (isColorLoopActive)
15891585
{
@@ -1600,11 +1596,11 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
16001596
// Do Nothing since it's not on
16011597
}
16021598
}
1603-
else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE)
1599+
else if (action == ColorLoopAction::kActivateFromColorLoopStartEnhancedHue)
16041600
{
16051601
startColorLoop(endpoint, true);
16061602
}
1607-
else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE)
1603+
else if (action == ColorLoopAction::kActivateFromEnhancedCurrentHue)
16081604
{
16091605
startColorLoop(endpoint, false);
16101606
}

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

-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ class ColorControlServer
7070
using HueMoveMode = chip::app::Clusters::ColorControl::HueMoveMode;
7171
using HueDirection = chip::app::Clusters::ColorControl::HueDirection;
7272

73-
enum ColorLoopDirection
74-
{
75-
DECREMENT_HUE = 0x00,
76-
INCREMENT_HUE = 0x01,
77-
};
78-
7973
enum ColorMode
8074
{
8175
COLOR_MODE_HSV = 0x00,

src/app/common/templates/config-data.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ WeakEnums:
44
- BarrierControlBarrierPosition
55
- BarrierControlMovingState
66
- ColorControlOptions
7-
- ColorLoopAction
8-
- ColorLoopDirection
97
- ColorMode
108
- EnhancedColorMode
119
- HardwareFaultEnum
@@ -25,7 +23,6 @@ DefineBitmaps:
2523
# The goal is to drive this down to 0.
2624
- BarrierControlCapabilities
2725
- BarrierControlSafetyStatus
28-
- ColorLoopUpdateFlags
2926

3027
# We need a more configurable way of deciding which clusters have which init functions....
3128
# See https://github.com/project-chip/connectedhomeip/issues/4369

zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h

-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/app-common/app-common/zap-generated/cluster-enums.h

-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/app-common/app-common/zap-generated/enums.h

-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)