Skip to content

Commit

Permalink
samples: matter: Added DSLS support to the smoke co alarm
Browse files Browse the repository at this point in the history
Integrated and enabled ICD DSLS feature with the smoke CO alarm
sample. Additionally, added documentation of test event triggers
dedicated for switching the power source.

Signed-off-by: Kamil Kasperczyk <[email protected]>
  • Loading branch information
kkasperczyk-no committed Nov 29, 2024
1 parent f7eb8c8 commit 1b0802b
Show file tree
Hide file tree
Showing 8 changed files with 582 additions and 458 deletions.
10 changes: 10 additions & 0 deletions doc/nrf/protocols/matter/end_product/test_event_triggers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ The following table lists the available triggers and their activation codes:
- Trigger an action that ceases end of service alarm
- ``0x005c0000000000aa``
- No additional value supported.
* - Power source on
- Only for :ref:`Matter Smoke CO Alarm <matter_smoke_co_alarm_sample>`
- Trigger an action that changes power source state to active
- ``0xFFFFFFFF80000000`` - ``0xFFFFFFFF80000001``
- The range of ``0x0`` - ``0x1`` is the endpoint id that has power source cluster instance enabled.
* - Power source off
- Only for :ref:`Matter Smoke CO Alarm <matter_smoke_co_alarm_sample>`
- Trigger an action that changes power source state to unavailable
- ``0xFFFFFFFF80010000`` - ``0xFFFFFFFF80010001``
- The range of ``0x0`` - ``0x1`` is the endpoint id that has power source cluster instance enabled.
* - Door lock jammed
- :kconfig:option:`CONFIG_CHIP_DEVICE_PRODUCT_ID` = ``32774``
- Simulate the jammed lock state.
Expand Down
1 change: 1 addition & 0 deletions samples/matter/light_switch/snippets/lit_icd/lit_icd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

# Enable LIT ICD configuration
CONFIG_CHIP_ICD_LIT_SUPPORT=y
CONFIG_CHIP_ICD_SIT_SLOW_POLL_LIMIT=5000
CONFIG_NCS_SAMPLE_MATTER_ZAP_FILES_PATH="snippets/lit_icd"
3 changes: 3 additions & 0 deletions samples/matter/smoke_co_alarm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ config CHIP_ENABLE_ICD_SUPPORT
config CHIP_ICD_LIT_SUPPORT
default y

config CHIP_ICD_SIT_SLOW_POLL_LIMIT
default 5000

# Increase the supported event triggers due to the multiple alarm triggers
config NCS_SAMPLE_MATTER_TEST_EVENT_TRIGGERS_MAX
default 12
Expand Down
16 changes: 16 additions & 0 deletions samples/matter/smoke_co_alarm/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ The implementation demonstrated in this sample supports issuing the following al
* End of service alert - Issued if the device service was ended either by the expiration date or other physical conditions, and it needs to be replaced.
* Battery level alert - Issued if the device battery level is too low.

The sample implements two instances of a Power Source cluster:

* Wired power source on the endpoint 0
* Batter power source on the endpoint 1

The usage of power sources is implemented with a preference to select wired power source and switch to battery power source, only if the wired one is not available.
The power source changes are emulated using :ref:`test event triggers <ug_matter_test_event_triggers>`.
Every power source can be independently enabled or disabled using dedicated test event trigger.

You can test the device remotely over a Thread network, which requires more devices.

The remote control testing requires a Matter controller that you can configure either on a PC or a mobile device.
Expand All @@ -60,6 +69,13 @@ The smoke CO alarm works as a Matter Intermittently Connected Device (ICD) with
The device starts operation in the Short Idle Time (SIT) mode and remains in it until it is commissioned to the Matter fabric and registers the first ICD client.
It then switches the operation mode to LIT to reduce the power consumption.

The sample supports ICD Dynamic SIT LIT switching (DSLS) feature to switch between SIT and LIT modes, depending on the used power source.
The device uses a SIT mode, when the wired power source is active.
Otherwise it moves to the LIT mode, to present that it is possible to save the energy, when using battery power source.
The dynamic switching is possible only, if the ICD device meets all criteria for operating in the LIT mode (it has at least one client registered).
The DSLS support is by default enabled.
To disable it, set the :kconfig:option:`CONFIG_CHIP_ICD_DSLS_SUPPORT` Kconfig option to ``n``.

In the LIT mode, the device responsiveness is much lower than in the SIT mode.
However, you can request the device to become responsive to, for example, change its configuration.
To do that, you need to use the User Active Mode Trigger (UAT) feature by pressing the appropriate button.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5208,7 +5208,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "3",
"defaultValue": "15",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down

Large diffs are not rendered by default.

35 changes: 31 additions & 4 deletions samples/matter/smoke_co_alarm/src/zcl_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>

#ifdef CONFIG_CHIP_ICD_DSLS_SUPPORT
#include <app/icd/server/ICDNotifier.h>
#endif

#include <lib/support/logging/CHIPLogging.h>

using namespace ::chip;
using namespace ::chip::app;
using namespace ::chip::app::Clusters;

#ifdef CONFIG_CHIP_ICD_DSLS_SUPPORT
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &attributePath, uint8_t type,
uint16_t size, uint8_t *value)
{
Expand All @@ -39,16 +44,38 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &a

if (state == PowerSource::PowerSourceStatusEnum::kActive) {
/* Wired source is active, we can switch into the SIT mode. */
/* TODO: Add requesting mode update once it will be implemented in the ICDManager. */
ChipLogProgress(Zcl, "Wired power source was activated, moving into the ICD SIT mode.");
chip::DeviceLayer::PlatformMgr().ScheduleWork(
[](intptr_t arg) {
chip::app::ICDNotifier::GetInstance().NotifySITModeRequestNotification();
},
0);
ChipLogProgress(Zcl, "Wired power source was activated, moving into the ICD SIT mode.");
} else {
/* Wired source is inactive, so we need to change mode into LIT to save power. */
/* TODO: Add requesting mode update once it will be implemented in the ICDManager. */
ChipLogProgress(Zcl, "Wired power source was deactivated, moving into the ICD LIT mode.");
chip::DeviceLayer::PlatformMgr().ScheduleWork(
[](intptr_t arg) {
chip::app::ICDNotifier::GetInstance().NotifySITModeRequestWithdrawal();
},
0);
ChipLogProgress(Zcl, "Wired power source was deactivated, moving into the ICD LIT mode.");
}
}
}

void emberAfPowerSourceClusterInitCallback(EndpointId endpoint)
{
Clusters::PowerSource::PowerSourceStatusEnum wiredPowerSourceState;
Clusters::PowerSource::Attributes::Status::Get(AppTask::Instance().kWiredPowerSourceEndpointId, &wiredPowerSourceState);

if (wiredPowerSourceState == Clusters::PowerSource::PowerSourceStatusEnum::kActive) {
/* Request switching to SIT, as soon as it's possible. */
chip::DeviceLayer::PlatformMgr().ScheduleWork(
[](intptr_t arg) { chip::app::ICDNotifier::GetInstance().NotifySITModeRequestNotification(); },
0);
}
}
#endif /* CONFIG_CHIP_ICD_DSLS_SUPPORT */

void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId)
{
if (endpointId == AppTask::Instance().kSmokeCoAlarmEndpointId) {
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ manifest:
- name: matter
repo-path: sdk-connectedhomeip
path: modules/lib/matter
revision: 9cfd6e13a239a61288f34b1219e1b41dc70f8457
revision: pull/515/head
west-commands: scripts/west/west-commands.yml
submodules:
- name: nlio
Expand Down

0 comments on commit 1b0802b

Please sign in to comment.