Skip to content

Commit

Permalink
Merge branch 'master' into bl706_ethernet_support
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh authored Jul 16, 2023
2 parents 687958d + b6caecf commit 6a53531
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 178 deletions.
141 changes: 45 additions & 96 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,132 @@ bool SmokeCoAlarmManager::ManualSelfTesting()

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

switch (eventTrigger)
{
case kTriggeredEvent_WarningSmokeAlarm:
success = SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kWarning);
if (success)
{
success = AlarmMgr().SetExpressedState(1, ExpressedStateEnum::kSmokeAlarm, true);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kWarning), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kCritical), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kNormal), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kWarning), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kCritical), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kNormal), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kWarning), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kCritical), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kNormal), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, true), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, false), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kExpired), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kNormal), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kWarning), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kNormal), true);
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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kWarning), 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);
}
VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kNormal), true);
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:
break;
isValidCommand = false;
}

return success;
return isValidCommand;
}

bool SmokeCoAlarmManager::SetExpressedState(EndpointId endpointId, ExpressedStateEnum expressedState, bool isSet)
Expand Down
10 changes: 5 additions & 5 deletions src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool SmokeCoAlarmServer::SetSmokeState(EndpointId endpointId, AlarmStateEnum new

if (success && (newSmokeState == AlarmStateEnum::kWarning || newSmokeState == AlarmStateEnum::kCritical))
{
Events::SmokeAlarm::Type event{};
Events::SmokeAlarm::Type event{ newSmokeState };
SendEvent(endpointId, event);
}

Expand All @@ -107,7 +107,7 @@ bool SmokeCoAlarmServer::SetCOState(EndpointId endpointId, AlarmStateEnum newCOS

if (success && (newCOState == AlarmStateEnum::kWarning || newCOState == AlarmStateEnum::kCritical))
{
Events::COAlarm::Type event{};
Events::COAlarm::Type event{ newCOState };
SendEvent(endpointId, event);
}

Expand All @@ -131,7 +131,7 @@ bool SmokeCoAlarmServer::SetBatteryAlert(EndpointId endpointId, AlarmStateEnum n

if (success && (newBatteryAlert == AlarmStateEnum::kWarning || newBatteryAlert == AlarmStateEnum::kCritical))
{
Events::LowBattery::Type event{};
Events::LowBattery::Type event{ newBatteryAlert };
SendEvent(endpointId, event);
}

Expand Down Expand Up @@ -297,7 +297,7 @@ bool SmokeCoAlarmServer::SetInterconnectSmokeAlarm(EndpointId endpointId, AlarmS
if (success &&
(newInterconnectSmokeAlarm == AlarmStateEnum::kWarning || newInterconnectSmokeAlarm == AlarmStateEnum::kCritical))
{
Events::InterconnectSmokeAlarm::Type event{};
Events::InterconnectSmokeAlarm::Type event{ newInterconnectSmokeAlarm };
SendEvent(endpointId, event);
}

Expand All @@ -323,7 +323,7 @@ bool SmokeCoAlarmServer::SetInterconnectCOAlarm(EndpointId endpointId, AlarmStat

if (success && (newInterconnectCOAlarm == AlarmStateEnum::kWarning || newInterconnectCOAlarm == AlarmStateEnum::kCritical))
{
Events::InterconnectCOAlarm::Type event{};
Events::InterconnectCOAlarm::Type event{ newInterconnectCOAlarm };
SendEvent(endpointId, event);
}

Expand Down
10 changes: 10 additions & 0 deletions src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ bool InterfaceIterator::IsUp()
return (GetFlags() & IFF_UP) != 0;
}

bool InterfaceIterator::IsLoopback()
{
return (GetFlags() & IFF_LOOPBACK) != 0;
}

bool InterfaceIterator::SupportsMulticast()
{
return (GetFlags() & IFF_MULTICAST) != 0;
Expand Down Expand Up @@ -706,6 +711,11 @@ bool InterfaceAddressIterator::IsUp()
return HasCurrent() && (mCurAddr->ifa_flags & IFF_UP) != 0;
}

bool InterfaceAddressIterator::IsLoopback()
{
return HasCurrent() && (mCurAddr->ifa_flags & IFF_LOOPBACK) != 0;
}

bool InterfaceAddressIterator::SupportsMulticast()
{
return HasCurrent() && (mCurAddr->ifa_flags & IFF_MULTICAST) != 0;
Expand Down
16 changes: 16 additions & 0 deletions src/inet/InetInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ class InterfaceIterator
*/
bool IsUp();

/**
* Returns whether the current network interface is a loopback interface
*
* @return \c true if current network interface is a loopback interface, \c false
* if not, or if the iterator is positioned beyond the end of the list.
*/
bool IsLoopback();

/**
* Returns whether the current network interface supports multicast.
*
Expand Down Expand Up @@ -504,6 +512,14 @@ class DLL_EXPORT InterfaceAddressIterator
*/
bool IsUp();

/**
* Returns whether the current network interface is a loopback interface
*
* @return \c true if current network interface is a loopback interface, \c false
* if not, or if the iterator is positioned beyond the end of the list.
*/
bool IsLoopback();

/**
* Returns whether the network interface associated with the current interface address supports multicast.
*
Expand Down
Loading

0 comments on commit 6a53531

Please sign in to comment.