Skip to content

Commit

Permalink
Fix INVALID_COMMAND
Browse files Browse the repository at this point in the history
  • Loading branch information
hare-siterwell committed Jul 14, 2023
1 parent 77fb72d commit 1399ccd
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,183 +210,185 @@ bool SmokeCoAlarmManager::ManualSelfTesting()

bool SmokeCoAlarmManager::OnEventTriggerHandle(uint64_t eventTrigger)
{
bool success = false;
bool isValidCommand = true;
bool success = false;

switch (eventTrigger)
{
case kTriggeredEvent_WarningSmokeAlarm:
success = SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, true);
}
break;

case kTriggeredEvent_CriticalSmokeAlarm:
success = SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kCritical);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, true);
}
break;

case kTriggeredEvent_SmokeAlarmClear:
success = SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, false);
}
break;

case kTriggeredEvent_WarningCOAlarm:
success = SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, true);
}
break;

case kTriggeredEvent_CriticalCOAlarm:
success = SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kCritical);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, true);
}
break;

case kTriggeredEvent_COAlarmClear:
success = SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kCOAlarm, false);
}
break;

case kTriggeredEvent_WarningBatteryAlert:
success = SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, true);
}
break;

case kTriggeredEvent_CriticalBatteryAlert:
success = SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kCritical);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, true);
}
break;

case kTriggeredEvent_BatteryAlertClear:
success = SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kBatteryAlert, false);
}
break;

case kTriggeredEvent_HardwareFaultAlert:
success = SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, true);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kHardwareFault, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kHardwareFault, true);
}
break;

case kTriggeredEvent_HardwareFaultAlertClear:
success = SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, false);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kHardwareFault, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kHardwareFault, false);
}
break;

case kTriggeredEvent_EndofServiceAlert:
success = SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kExpired);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kEndOfService, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kEndOfService, true);
}
break;

case kTriggeredEvent_EndofServiceAlertClear:
success = SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kEndOfService, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kEndOfService, false);
}
break;

case kTriggeredEvent_DeviceMute:
success = SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kMuted);
SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kMuted);
break;

case kTriggeredEvent_DeviceMuteClear:
success = SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kNotMuted);
SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kNotMuted);
break;

case kTriggeredEvent_InterconnectSmokeAlarm:
success = SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectSmoke, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectSmoke, true);
}
break;

case kTriggeredEvent_InterconnectSmokeAlarmClear:
success = SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectSmoke, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectSmoke, false);
}
break;

case kTriggeredEvent_InterconnectCOAlarm:
success = SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectCO, true);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectCO, true);
}
break;

case kTriggeredEvent_InterconnectCOAlarmClear:
success = SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kNormal);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectCO, false);
AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kInterconnectCO, false);
}
break;

case kTriggeredEvent_ContaminationStateHigh:
success = SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kWarning);
SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kWarning);
break;

case kTriggeredEvent_ContaminationStateLow:
success = SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kLow);
SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kLow);
break;

case kTriggeredEvent_ContaminationStateClear:
success = SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kNormal);
SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kNormal);
break;

case kTriggeredEvent_SensitivityLevelHigh:
success = SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kHigh);
SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kHigh);
break;

case kTriggeredEvent_SensitivityLevelLow:
success = SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kLow);
SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kLow);
break;

case kTriggeredEvent_SensitivityLevelClear:
success = SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kStandard);
SmokeCoAlarmServer::Instance().SetSensitivityLevel(1, SensitivityEnum::kStandard);
break;

default:
isValidCommand = false;
break;
}

return success;
return isValidCommand;
}

bool SmokeCoAlarmManager::SetExpressedState(EndpointId endpointId, ExpressedStateEnum expressedState, bool isSet)
Expand Down

0 comments on commit 1399ccd

Please sign in to comment.