Skip to content

Commit 0d097f4

Browse files
For unknownd effect variant, Default to the respective 0 value enum variant
1 parent 4ed3d8b commit 0d097f4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/app/clusters/on-off-server/on-off-server.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -620,12 +620,17 @@ bool OnOffServer::offWithEffectCommand(app::CommandHandler * commandObj, const a
620620
// Depending on effectId value, effectVariant enum type varies.
621621
// The following check validates that effectVariant value is valid in relation to the applicable enum type.
622622
// DelayedAllOffEffectVariantEnum or DyingLightEffectVariantEnum
623-
if ((effectId == EffectIdentifierEnum::kDelayedAllOff &&
624-
!isKnownEnumValue(static_cast<DelayedAllOffEffectVariantEnum>(effectVariant))) ||
625-
(effectId == EffectIdentifierEnum::kDyingLight &&
626-
!isKnownEnumValue(static_cast<DyingLightEffectVariantEnum>(effectVariant))))
623+
if (effectId == EffectIdentifierEnum::kDelayedAllOff &&
624+
!isKnownEnumValue(static_cast<DelayedAllOffEffectVariantEnum>(effectVariant)))
627625
{
628-
status = Status::ConstraintError;
626+
// The server does not support the given variant, it SHALL use the default variant.
627+
effectVariant = to_underlying(DelayedAllOffEffectVariantEnum::kDelayedOffFastFade);
628+
}
629+
else if (effectId == EffectIdentifierEnum::kDyingLight &&
630+
!isKnownEnumValue(static_cast<DyingLightEffectVariantEnum>(effectVariant)))
631+
{
632+
// The server does not support the given variant, it SHALL use the default variant.
633+
effectVariant = to_underlying(DyingLightEffectVariantEnum::kDyingLightFadeOff);
629634
}
630635
}
631636
else

0 commit comments

Comments
 (0)