Skip to content

Commit

Permalink
Update SMOKECO SDK (#28751)
Browse files Browse the repository at this point in the history
* Update SMOKECO server

* Replace "if success" with "VerifyOrReturn"
* Move SetExpressedState to private
* Change unused bool to void

* Adapt all-cluster-app to server changes

* Adapt telink smokeco to server changes

* Add RequestSelfTest public function

* Add smokeco long press command to all-cluster-app

* Adapt smokeco example to server changes

* Revert "Add RequestSelfTest public function"

This reverts commit 89bdf78.

* Add RequestSelfTest public function

* Add LockChipStack

* Adapt telink example to server changes

---------

Co-authored-by: Hare <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 6, 2023
1 parent dec9134 commit 4730458
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 600 deletions.
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
70 changes: 2 additions & 68 deletions examples/smoke-co-alarm-app/silabs/include/SmokeCoAlarmManager.h
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

0 comments on commit 4730458

Please sign in to comment.