Skip to content

Commit

Permalink
Update stubs.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
hare-siterwell committed Aug 10, 2023
1 parent e901817 commit 7b78d03
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,44 @@ void emberAfChannelClusterInitCallback(EndpointId endpoint)
static_cast<app::Clusters::Channel::Delegate *>(&(ChefChannelManager::Instance())));
}
#endif // EMBER_AF_PLUGIN_CHANNEL_SERVER

#ifdef EMBER_AF_PLUGIN_SMOKE_CO_ALARM_SERVER
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>

#include <platform/CHIPDeviceLayer.h>

using namespace chip;
using namespace chip::app::Clusters::SmokeCoAlarm;
using namespace chip::DeviceLayer;

namespace {

constexpr const uint16_t kSelfTestingTimeoutSec = 10;

} // namespace

static std::array<ExpressedStateEnum, SmokeCoAlarmServer::kPriorityOrderLength> 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

0 comments on commit 7b78d03

Please sign in to comment.