From 7b78d03ee44e6b49c6e776cd3d2e432bc3308c8c Mon Sep 17 00:00:00 2001 From: Hare Date: Thu, 10 Aug 2023 17:23:05 +0800 Subject: [PATCH] Update stubs.cpp --- examples/chef/common/stubs.cpp | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 74f72b0a57cb67..f632018b826aae 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -249,3 +249,44 @@ void emberAfChannelClusterInitCallback(EndpointId endpoint) static_cast(&(ChefChannelManager::Instance()))); } #endif // EMBER_AF_PLUGIN_CHANNEL_SERVER + +#ifdef EMBER_AF_PLUGIN_SMOKE_CO_ALARM_SERVER +#include + +#include + +using namespace chip; +using namespace chip::app::Clusters::SmokeCoAlarm; +using namespace chip::DeviceLayer; + +namespace { + +constexpr const uint16_t kSelfTestingTimeoutSec = 10; + +} // namespace + +static std::array sPriorityOrder = { + ExpressedStateEnum::kSmokeAlarm, ExpressedStateEnum::kInterconnectSmoke, ExpressedStateEnum::kCOAlarm, + ExpressedStateEnum::kInterconnectCO, ExpressedStateEnum::kHardwareFault, ExpressedStateEnum::kTesting, + ExpressedStateEnum::kEndOfService, ExpressedStateEnum::kBatteryAlert +}; + +void EndSelfTestingEventHandler(System::Layer * systemLayer, void * appState) +{ + SmokeCoAlarmServer::Instance().SetTestInProgress(1, false); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test complete"); +} + +bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) +{ + SmokeCoAlarmServer::Instance().SetTestInProgress(1, true); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test running"); + + DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(kSelfTestingTimeoutSec), EndSelfTestingEventHandler, nullptr); + + return true; +} +#endif // EMBER_AF_PLUGIN_SMOKE_CO_ALARM_SERVER