Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Boolean State Configuration] Improved handling of SetAllEnabledAlarmsActive and ClearAllAlarms #31649

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,46 @@ CHIP_ERROR SetAllEnabledAlarmsActive(EndpointId ep)
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsEnabled::Get(ep, &alarmsEnabled),
CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));

VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsActive::Set(ep, alarmsEnabled), CHIP_IM_GLOBAL_STATUS(Failure));
emitAlarmsStateChangedEvent(ep);
if (alarmsEnabled.HasAny())
{
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsActive::Set(ep, alarmsEnabled), CHIP_IM_GLOBAL_STATUS(Failure));
ReneJosefsen marked this conversation as resolved.
Show resolved Hide resolved
emitAlarmsStateChangedEvent(ep);
}

return CHIP_NO_ERROR;
}

CHIP_ERROR ClearAllAlarms(EndpointId ep)
{
BitMask<BooleanStateConfiguration::AlarmModeBitmap> alarmsActive, alarmsSuppressed;
bool emitEvent = false;

VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsActive::Get(ep, &alarmsActive),
CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsSuppressed::Get(ep, &alarmsSuppressed),
CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));

if (alarmsActive.HasAny() || alarmsSuppressed.HasAny())
if (alarmsActive.HasAny())
{
alarmsActive.ClearAll();
alarmsSuppressed.ClearAll();
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsActive::Set(ep, alarmsActive),
CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
emitEvent = true;
}

if (alarmsSuppressed.HasAny())
{
alarmsSuppressed.ClearAll();
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == AlarmsSuppressed::Set(ep, alarmsSuppressed),
CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
emitEvent = true;
}

if (emitEvent)
{
emitAlarmsStateChangedEvent(ep);
}

return CHIP_NO_ERROR;
}

Expand Down
Loading