@@ -89,6 +89,12 @@ void UpdateModeBaseCurrentModeToOnMode(EndpointId endpoint)
89
89
90
90
#endif // MATTER_DM_PLUGIN_MODE_BASE
91
91
92
+ template <typename EnumType>
93
+ bool isKnownEnumValue (EnumType value)
94
+ {
95
+ return (EnsureKnownEnumValue (value) == EnumType::kUnknownEnumValue ) ? false : true ;
96
+ }
97
+
92
98
} // namespace
93
99
94
100
#ifdef MATTER_DM_PLUGIN_LEVEL_CONTROL
@@ -609,6 +615,30 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a
609
615
chip::EndpointId endpoint = commandPath.mEndpointId ;
610
616
Status status = Status::Success;
611
617
618
+ if (isKnownEnumValue (effectId))
619
+ {
620
+ // Depending on effectId value, effectVariant enum type varies.
621
+ // The following check validates that effectVariant value is valid in relation to the applicable enum type.
622
+ // DelayedAllOffEffectVariantEnum or DyingLightEffectVariantEnum
623
+ if ((effectId == EffectIdentifierEnum::kDelayedAllOff &&
624
+ !isKnownEnumValue (static_cast <DelayedAllOffEffectVariantEnum>(effectVariant))) ||
625
+ (effectId == EffectIdentifierEnum::kDyingLight &&
626
+ !isKnownEnumValue (static_cast <DyingLightEffectVariantEnum>(effectVariant))))
627
+ {
628
+ status = Status::ConstraintError;
629
+ }
630
+ }
631
+ else
632
+ {
633
+ status = Status::ConstraintError;
634
+ }
635
+
636
+ if (status != Status::Success)
637
+ {
638
+ commandObj->AddStatus (commandPath, status);
639
+ return true ;
640
+ }
641
+
612
642
if (SupportsLightingApplications (endpoint))
613
643
{
614
644
#ifdef MATTER_DM_PLUGIN_SCENES_MANAGEMENT
0 commit comments