Skip to content

Commit

Permalink
Update Smoke CO Alarm Implementation (#27566)
Browse files Browse the repository at this point in the history
* Smoke/CO: Add ExpiryDate

* Smoke/CO: Add emberAfHandleEventTrigger

* Smoke/CO: Update the handling of attribute changes

Unmute when critical alarm is triggered

* Smoke/CO: Update the handling of DeviceMuted

Cannot mute when critical alarms exist

* Smoke/CO: Update zap

* Smoke/CO: Update README.md

Add building options description

* Smoke/CO: Update zap

fix UnitTesting cluster

* Revert "Smoke/CO: Update zap"

This reverts commit 4607dab.

* Revert "Smoke/CO: Update zap"

This reverts commit 7534419.

* Add Unit Testing

* Smoke/CO: Update zap

Sync Silab changes

* Smoke/CO: Add ExpressedState priority

* Smoke/CO: Update endOfServiceAlert of zap

* [SMCO] Add mExpressedStatePriority

* [SMCO] Add timer for test

* Separate Warning and Critical Triggered Event

---------

Co-authored-by: Hare <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 22, 2023
1 parent 8c4f524 commit 2134162
Show file tree
Hide file tree
Showing 11 changed files with 2,418 additions and 4,067 deletions.
23 changes: 19 additions & 4 deletions examples/smoke-co-alarm-app/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ declare_args() {
chip_print_memory_usage = false
}

if (slc_generate) {
# Generate Project Specific config (Board, hardware used etc..)
print(exec_script("${chip_root}/third_party/silabs/slc_gen/run_slc.py",
[
rebase_path(chip_root),
"${silabs_board}",
"${disable_lcd}",
"${use_wstk_buttons}",
"${use_wstk_leds}",
"${use_external_flash}",
"${silabs_mcu}",
],
"list lines"))
}

if (wifi_soc) {
siwx917_sdk("sdk") {
sources = [
Expand Down Expand Up @@ -115,17 +130,17 @@ silabs_executable("smoke_co_alarm_app") {
include_dirs = [ "include" ]
defines = []

if (silabs_board == "BRD2704A") {
defines += [ "SL_STATUS_LED=0" ]
}

sources = [
"${examples_common_plat_dir}/main.cpp",
"src/AppTask.cpp",
"src/SmokeCoAlarmManager.cpp",
"src/ZclCallbacks.cpp",
]

if (chip_build_libshell) {
sources += [ "src/EventHandlerLibShell.cpp" ]
}

deps = [
":sdk",
app_data_model,
Expand Down
10 changes: 10 additions & 0 deletions examples/smoke-co-alarm-app/silabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,13 @@ features can easily be toggled on or off. Here is a short list of options :

$ ./scripts/examples/gn_silabs_example.sh ./examples/smoke-co-alarm-app/silabs ./out/smoke-co-alarm-app BRD4164A kvs_max_entries=50
```

### Enabling test event trigger

`silabs_test_event_trigger_enabled, silabs_test_event_trigger_enable_key`

```
The value of silabs_test_event_trigger_enable_key is specific to each device manufacturer

$ ./scripts/examples/gn_silabs_example.sh ./examples/smoke-co-alarm-app/silabs ./out/smoke-co-alarm-app BRD4164A silabs_test_event_trigger_enabled=true silabs_test_event_trigger_enable_key=\"00112233445566778899aabbccddeeff\"
```
76 changes: 74 additions & 2 deletions examples/smoke-co-alarm-app/silabs/include/SmokeCoAlarmManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,90 @@
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 StartSelfTesting();
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
*
* @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);

private:
friend SmokeCoAlarmManager & AlarmMgr(void);

chip::app::Clusters::SmokeCoAlarm::ExpressedStateEnum mExpressedState;
/**
* @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
9 changes: 6 additions & 3 deletions examples/smoke-co-alarm-app/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "LEDWidget.h"

#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
Expand All @@ -38,7 +37,7 @@

#include <platform/CHIPDeviceLayer.h>

#if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT)
#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(BRD4325B))
#define LIGHT_LED 1
#else
#define LIGHT_LED 0
Expand Down Expand Up @@ -141,7 +140,11 @@ void AppTask::AppTaskMain(void * pvParameter)

void AppTask::ButtonActionEventHandler(AppEvent * aEvent)
{
SILABS_LOG("Button pressed!");
bool success = AlarmMgr().ManualSelfTesting();
if (!success)
{
SILABS_LOG("Manual self-test failed");
}
}

void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
Expand Down
Loading

0 comments on commit 2134162

Please sign in to comment.