Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SMOKECO SDK #28751

Merged
merged 11 commits into from
Aug 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ void EndSelfTestingEventHandler(System::Layer * systemLayer, void * appState)
ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test complete");
}

bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId)
void 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;
}

bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/att-storage.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
#include <app/clusters/software-diagnostics-server/software-diagnostics-server.h>
#include <app/clusters/switch-server/switch-server.h>
#include <app/server/Server.h>
Expand Down Expand Up @@ -286,6 +287,9 @@ void AllClustersAppCommandHandler::OnSwitchLongPressedHandler(uint8_t newPositio
ChipLogDetail(NotSpecified, "The new position when the momentary switch has been pressed for a long time:%d", newPosition);

Clusters::SwitchServer::Instance().OnLongPress(endpoint, newPosition);

// Long press to trigger smokeco self-test
SmokeCoAlarmServer::Instance().RequestSelfTest(endpoint);
}

void AllClustersAppCommandHandler::OnSwitchShortReleasedHandler(uint8_t previousPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,23 @@
class SmokeCoAlarmManager
{
public:
using ExpressedStateEnum = chip::app::Clusters::SmokeCoAlarm::ExpressedStateEnum;

enum TriggeredEvent_t
{
kTriggeredEvent_WarningSmokeAlarm = 0xffffffff00000090,
kTriggeredEvent_CriticalSmokeAlarm = 0xffffffff0000009c,
kTriggeredEvent_SmokeAlarmClear = 0xffffffff000000a0,
kTriggeredEvent_WarningCOAlarm = 0xffffffff00000091,
kTriggeredEvent_CriticalCOAlarm = 0xffffffff0000009d,
kTriggeredEvent_COAlarmClear = 0xffffffff000000a1,
kTriggeredEvent_WarningBatteryAlert = 0xffffffff00000095,
kTriggeredEvent_CriticalBatteryAlert = 0xffffffff0000009e,
kTriggeredEvent_BatteryAlertClear = 0xffffffff000000a5,
kTriggeredEvent_HardwareFaultAlert = 0xffffffff00000093,
kTriggeredEvent_HardwareFaultAlertClear = 0xffffffff000000a3,
kTriggeredEvent_EndofServiceAlert = 0xffffffff0000009a,
kTriggeredEvent_EndofServiceAlertClear = 0xffffffff000000aa,
kTriggeredEvent_DeviceMute = 0xffffffff0000009b,
kTriggeredEvent_DeviceMuteClear = 0xffffffff000000ab,
kTriggeredEvent_InterconnectSmokeAlarm = 0xffffffff00000092,
kTriggeredEvent_InterconnectSmokeAlarmClear = 0xffffffff000000a2,
kTriggeredEvent_InterconnectCOAlarm = 0xffffffff00000094,
kTriggeredEvent_InterconnectCOAlarmClear = 0xffffffff000000a4,
kTriggeredEvent_ContaminationStateHigh = 0xffffffff00000096,
kTriggeredEvent_ContaminationStateLow = 0xffffffff00000097,
kTriggeredEvent_ContaminationStateClear = 0xffffffff000000a6,
kTriggeredEvent_SensitivityLevelHigh = 0xffffffff00000098,
kTriggeredEvent_SensitivityLevelLow = 0xffffffff00000099,
kTriggeredEvent_SensitivityLevelClear = 0xffffffff000000a8,
} TriggeredEvent;

CHIP_ERROR Init();

/**
* @brief Execute the self-test process and attribute changes
*
*/
bool OnSelfTesting();

/**
* @brief Execute the self-test process manually
*
*/
bool ManualSelfTesting();

/**
* @brief Execute the HandleEventTrigger process
*
*/
bool OnEventTriggerHandle(uint64_t eventTrigger);

/**
* @brief Updates the expressed state with new value
* @brief Execute the self-test process
*
* @param endpointId ID of the endpoint
* @param expressedState expressed state
* @param isSet true on set, false on unset
* @return true on success, false on failure
*/
bool SetExpressedState(chip::EndpointId endpointId, ExpressedStateEnum expressedState, bool isSet);
void SelfTestingEventHandler();

private:
friend SmokeCoAlarmManager & AlarmMgr(void);

/**
* @brief Record expressed state in decreasing priority
*
*/
std::array<ExpressedStateEnum, 9> mExpressedStatePriority;

/**
* @brief Expression status record values
*
*/
int mExpressedStateMask = 1;

bool mEndSelfTesting;

void CancelTimer(void);
void StartTimer(uint32_t aTimeoutMs);

static void TimerEventHandler(TimerHandle_t xTimer);
static void SelfTestingEventHandler(AppEvent * aEvent);
static void EndSelfTestingEventHandler(AppEvent * aEvent);

static SmokeCoAlarmManager sAlarm;
Expand Down
4 changes: 3 additions & 1 deletion examples/smoke-co-alarm-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ void AppTask::AppTaskMain(void * pvParameter)

void AppTask::ButtonActionEventHandler(AppEvent * aEvent)
{
bool success = AlarmMgr().ManualSelfTesting();
chip::DeviceLayer::PlatformMgr().LockChipStack();
bool success = SmokeCoAlarmServer::Instance().RequestSelfTest(1);
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
if (!success)
{
SILABS_LOG("Manual self-test failed");
Expand Down
Loading