Skip to content

Commit

Permalink
Improved handling of SetAllEnabledAlarmsActive and ClearAllAlarms (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneJosefsen authored and pull[bot] committed Feb 2, 2024
1 parent 88db60d commit 1390066
Showing 1 changed file with 20 additions and 4 deletions.
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));
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

0 comments on commit 1390066

Please sign in to comment.