Skip to content

Commit 4730458

Browse files
ericzijian1994hare-siterwell
authored andcommitted
Update SMOKECO SDK (#28751)
* 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 <renilr0@outlook.com>
1 parent dec9134 commit 4730458

File tree

12 files changed

+353
-600
lines changed

12 files changed

+353
-600
lines changed

examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@ void EndSelfTestingEventHandler(System::Layer * systemLayer, void * appState)
4444
ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test complete");
4545
}
4646

47-
bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId)
47+
void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId)
4848
{
49-
SmokeCoAlarmServer::Instance().SetTestInProgress(1, true);
50-
5149
ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test running");
5250

5351
DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(kSelfTestingTimeoutSec), EndSelfTestingEventHandler, nullptr);
54-
55-
return true;
5652
}
5753

5854
bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger)

examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <app-common/zap-generated/attributes/Accessors.h>
2222
#include <app/att-storage.h>
2323
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
24+
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
2425
#include <app/clusters/software-diagnostics-server/software-diagnostics-server.h>
2526
#include <app/clusters/switch-server/switch-server.h>
2627
#include <app/server/Server.h>
@@ -286,6 +287,9 @@ void AllClustersAppCommandHandler::OnSwitchLongPressedHandler(uint8_t newPositio
286287
ChipLogDetail(NotSpecified, "The new position when the momentary switch has been pressed for a long time:%d", newPosition);
287288

288289
Clusters::SwitchServer::Instance().OnLongPress(endpoint, newPosition);
290+
291+
// Long press to trigger smokeco self-test
292+
SmokeCoAlarmServer::Instance().RequestSelfTest(endpoint);
289293
}
290294

291295
void AllClustersAppCommandHandler::OnSwitchShortReleasedHandler(uint8_t previousPosition)

examples/smoke-co-alarm-app/silabs/include/SmokeCoAlarmManager.h

+2-68
Original file line numberDiff line numberDiff line change
@@ -31,89 +31,23 @@
3131
class SmokeCoAlarmManager
3232
{
3333
public:
34-
using ExpressedStateEnum = chip::app::Clusters::SmokeCoAlarm::ExpressedStateEnum;
35-
36-
enum TriggeredEvent_t
37-
{
38-
kTriggeredEvent_WarningSmokeAlarm = 0xffffffff00000090,
39-
kTriggeredEvent_CriticalSmokeAlarm = 0xffffffff0000009c,
40-
kTriggeredEvent_SmokeAlarmClear = 0xffffffff000000a0,
41-
kTriggeredEvent_WarningCOAlarm = 0xffffffff00000091,
42-
kTriggeredEvent_CriticalCOAlarm = 0xffffffff0000009d,
43-
kTriggeredEvent_COAlarmClear = 0xffffffff000000a1,
44-
kTriggeredEvent_WarningBatteryAlert = 0xffffffff00000095,
45-
kTriggeredEvent_CriticalBatteryAlert = 0xffffffff0000009e,
46-
kTriggeredEvent_BatteryAlertClear = 0xffffffff000000a5,
47-
kTriggeredEvent_HardwareFaultAlert = 0xffffffff00000093,
48-
kTriggeredEvent_HardwareFaultAlertClear = 0xffffffff000000a3,
49-
kTriggeredEvent_EndofServiceAlert = 0xffffffff0000009a,
50-
kTriggeredEvent_EndofServiceAlertClear = 0xffffffff000000aa,
51-
kTriggeredEvent_DeviceMute = 0xffffffff0000009b,
52-
kTriggeredEvent_DeviceMuteClear = 0xffffffff000000ab,
53-
kTriggeredEvent_InterconnectSmokeAlarm = 0xffffffff00000092,
54-
kTriggeredEvent_InterconnectSmokeAlarmClear = 0xffffffff000000a2,
55-
kTriggeredEvent_InterconnectCOAlarm = 0xffffffff00000094,
56-
kTriggeredEvent_InterconnectCOAlarmClear = 0xffffffff000000a4,
57-
kTriggeredEvent_ContaminationStateHigh = 0xffffffff00000096,
58-
kTriggeredEvent_ContaminationStateLow = 0xffffffff00000097,
59-
kTriggeredEvent_ContaminationStateClear = 0xffffffff000000a6,
60-
kTriggeredEvent_SensitivityLevelHigh = 0xffffffff00000098,
61-
kTriggeredEvent_SensitivityLevelLow = 0xffffffff00000099,
62-
kTriggeredEvent_SensitivityLevelClear = 0xffffffff000000a8,
63-
} TriggeredEvent;
64-
6534
CHIP_ERROR Init();
6635

6736
/**
68-
* @brief Execute the self-test process and attribute changes
69-
*
70-
*/
71-
bool OnSelfTesting();
72-
73-
/**
74-
* @brief Execute the self-test process manually
75-
*
76-
*/
77-
bool ManualSelfTesting();
78-
79-
/**
80-
* @brief Execute the HandleEventTrigger process
81-
*
82-
*/
83-
bool OnEventTriggerHandle(uint64_t eventTrigger);
84-
85-
/**
86-
* @brief Updates the expressed state with new value
37+
* @brief Execute the self-test process
8738
*
88-
* @param endpointId ID of the endpoint
89-
* @param expressedState expressed state
90-
* @param isSet true on set, false on unset
91-
* @return true on success, false on failure
9239
*/
93-
bool SetExpressedState(chip::EndpointId endpointId, ExpressedStateEnum expressedState, bool isSet);
40+
void SelfTestingEventHandler();
9441

9542
private:
9643
friend SmokeCoAlarmManager & AlarmMgr(void);
9744

98-
/**
99-
* @brief Record expressed state in decreasing priority
100-
*
101-
*/
102-
std::array<ExpressedStateEnum, 9> mExpressedStatePriority;
103-
104-
/**
105-
* @brief Expression status record values
106-
*
107-
*/
108-
int mExpressedStateMask = 1;
109-
11045
bool mEndSelfTesting;
11146

11247
void CancelTimer(void);
11348
void StartTimer(uint32_t aTimeoutMs);
11449

11550
static void TimerEventHandler(TimerHandle_t xTimer);
116-
static void SelfTestingEventHandler(AppEvent * aEvent);
11751
static void EndSelfTestingEventHandler(AppEvent * aEvent);
11852

11953
static SmokeCoAlarmManager sAlarm;

examples/smoke-co-alarm-app/silabs/src/AppTask.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ void AppTask::AppTaskMain(void * pvParameter)
140140

141141
void AppTask::ButtonActionEventHandler(AppEvent * aEvent)
142142
{
143-
bool success = AlarmMgr().ManualSelfTesting();
143+
chip::DeviceLayer::PlatformMgr().LockChipStack();
144+
bool success = SmokeCoAlarmServer::Instance().RequestSelfTest(1);
145+
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
144146
if (!success)
145147
{
146148
SILABS_LOG("Manual self-test failed");

0 commit comments

Comments
 (0)