Skip to content

Commit 26435f0

Browse files
Sarthak-Shahawoody-appleKishokGrestyled-commitskorino-silabs
authored
Sync csa branch with main (#1262)
* [Darwin] Send delegate interested paths in XPC registration info (#74421) Registration info from an XPC-backed MTRDevice carries node IDs only, so a server reports every path of every registered node across the connection, whatever the client's delegates asked for. Each node's registration entry carries the union of its delegates' interested attribute and event paths, plus the paths of pending attribute-value waiters, sorted so the entry does not depend on delegate order, and is re-sent when that union changes. A delegate with nil interested paths omits the key, which means every path. The paths go on the wire as property-list values: an endpoint ID as an NSNumber, and a cluster, attribute or event path as a dictionary of NSNumbers under the keys declared in MTRXPCServerProtocol.h. A server that exports the plain MTRXPCServerProtocol interface allows only property-list classes for that argument, and NSXPC drops a message holding any other class, so path objects in the dictionary would cost such a server every node's registration. darwin-framework-tool's server decodes the keys and logs them. The union holds only the element types local delegate filtering recognizes: endpoint IDs, cluster paths, and attribute paths (attributes) or event paths (events). Any other cluster path, such as an event path among attribute paths, becomes its cluster path; anything else matches no report and is left out. A waiter records, under the device lock, whether it is still registered with the device, and only removing a registered waiter re-sends. A waiter released without -cancel has already left the weak table by the time its -dealloc runs, so the flag is what lets that removal still re-send, while a repeated -cancel or the -dealloc of a satisfied waiter sends nothing. -invalidate re-sends when it cancels pending waiters. Delegates are held weakly, and a delegate released without -removeDelegate: is only pruned when the device next iterates its delegates. A prune during that iteration now counts as a change, so the stale paths leave the registration on the next report for the node. * [TC-IDM-2.1] Log have been updated as per latest sample app response, IDM-2.2 removal as it's been converted to python (#41165) * Update Test_TC_IDM_2_2.yaml to match the test plan and manual verification steps * Update Test_TC_IDM_2_1.yaml * Update Test_TC_IDM_2_2.yaml * Update Test_TC_IDM_2_2.yaml * Update Test_TC_IDM_2_2.yaml * Restyled by whitespace * Delete src/app/tests/suites/certification/Test_TC_IDM_2_2.yaml --------- Co-authored-by: Restyled.io <commits@restyled.io> * [Silabs] Configure Closure Dimension conformance per panel endpoint (#74158) * Add ClusterInitParameters and ClusterConformance as a configurable from ClosureManager * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixed the if block * Added more verbose name * Add default resolution and step value constants --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [Silabs] Remove duplicate chip_openthread_ftd override from all-devices-app args.gni (Auto-merged by platform-bot) (#74638) * [Silabs] Remove duplicate chip_openthread_ftd override from all-devices-app args.gni args.gni takes precedence over openthread.gn, so Silabs all-devices-app always compiled with chip_openthread_ftd = true. Remove the override from args.gni and set the default in .gn and openthread.gn, matching other Silabs examples. * Drop optimize_debug_level override from Silabs all-devices-app GN dotfiles * [PAVST] Align TC_PAVST_2_15 steps with updated test plan PR #6376 (#74657) * [PAVST] Align TC_PAVST_2_15 steps with updated test plan PR #6376 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Use native arm64 zap on Apple Silicon Macs (#74663) Pull #26747 forced Apple Silicon Macs to download the mac-amd64 zap package because the arm64 build had been pulled at the time. That is no longer the case: experimental/matter/zap/mac-arm64 is published to CIPD for the pinned version (v2026.09.09.2). Running the x86_64 zap-cli requires Rosetta, which macOS does not install by default. Apple also states that Rosetta will only be available as a general-purpose tool through macOS 27, after which only a gaming-focused subset will remain: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment * [Silabs] MATTER-5943: Implement common file for CRTP documentation (#73446) * [SL-UP] [SL-ONLY] MATTER-5943: Implement common file for CRTP documentation (#1085) implement common doc * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix misspell ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [all-devices-app] Extract CodeDrivenDataModelDevices from posix/main.cpp (#74610) * [all-devices-app] Extract CodeDrivenDataModelDevices from posix/main.cpp Move CodeDrivenDataModelDevices and PosixDeviceFactory out of the anonymous namespace in examples/all-devices-app/posix/main.cpp into include/CodeDrivenDataModelDevices.h and CodeDrivenDataModelDevices.cpp, decouple CodeDrivenDataModelDevices from AppOptions singleton state, and expose a reusable code-driven-data-model-devices source_set target in examples/all-devices-app/posix/BUILD.gn. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Validate testEventTriggerDelegate is non-null in CodeDrivenDataModelDevices::Startup * Fix gn check dependencies for code-driven-data-model-devices * review feedback --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andrei Litvin <andy314@gmail.com> * Confine push_av_server WorkingDirectory.path() to the working directory (#74543) * Confine push_av_server WorkingDirectory.path() to the working directory path() joined caller-supplied segments with a bare os.path.join and no confinement, so an absolute segment or ".." resolved outside the intended stream directory. Neutralize absolute segments and reject any result that resolves outside the working directory. All file routes and mkdir() funnel through path(), so the single guard covers read, upload, ffprobe, and certificate routes. Add test/test_working_directory_path.py pinning that resolved paths stay within the working directory for relative, absolute, and ".." segments. * Reject absolute and parent-traversal segments in path() A root-only containment check still let a ".." segment cross from the prefix directory into a sibling under the same root (e.g. streams/<id> reaching certs/). Reject absolute segments and ".." components before resolution, keeping the resolved-root check for symlink escapes. Extend the tests to cover sibling traversal and use a tmp_path fixture. * Reject drive-anchored path segments os.path.isabs treats a Windows drive-relative segment ("C:foo") as relative, but Path(*paths) would discard the fixed prefix on Windows. Check each segment under both path flavours and reject any that carries an anchor or drive. Add a host-independent regression case. * Reject all anchored segments via anchor; harden tests A Windows rooted-relative segment ("\foo") is neither absolute nor drive-qualified, so the .drive check missed it. Check PurePosixPath and PureWindowsPath anchor instead, covering absolute, drive-relative and rooted-relative forms. Tests now assert containment with is_relative_to (not string prefix) and add rooted-relative and symlink-escape cases. * [CameraApp] Fix BufferSink memory leak in DefaultMediaController (#74296) * [CameraApp] Fix BufferSink memory leak in DefaultMediaController - Store BufferSink instances as std::unique_ptr<BufferSink> in mSinkMap and declare mSinkMap before mPreRollBuffer so sinks outlive the buffer. - Deregister remaining transports from mPreRollBuffer and clear mSinkMap in ~DefaultMediaController() on shutdown. - Clean up any existing BufferSink and Connection entry before overwriting if RegisterTransport() is called again for an already-registered transport. * [CameraApp] Synchronize all mSinkMap accesses with mConnectionsMutex * [CameraApp] Extract UnregisterTransportLocked with thread-safety annotations * Add Doorbell device type to all-devices app. (#74027) * Add build files * Remove Chime server * Override Client clusters method * Add Bindings cluster * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * address PR comments * try to fix compilation errors * PR fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Code cleanup and missing build reference * Add identify delegate and switch configuration * Add NamedPipe implementation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add changes to OOB implementation for Doorbell * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Restyled by gn * Add PR changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add simulated Doorbell and remove direct switch pipe * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update docs and add events to simulated doorbell * Remove Release event since it is not explicitly supported * Remove SimulatedDoorbell and arrange OOB handler * Remove SetPosition from Doorbell * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address PR comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add PR sugestions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> --------- Co-authored-by: Justin Wood <woody@apple.com> Co-authored-by: Kishok G <133193761+KishokG@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Pervin Korino Dasan A <pe1@silabs.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andrei Litvin <andy314@gmail.com> Co-authored-by: Pradip De <pradipd@google.com> Co-authored-by: pomeloy <45542782+pomeloy@users.noreply.github.com> Co-authored-by: Michael Duggan <miduggan@silabs.com> Co-authored-by: rob <rgoliver@google.com> Co-authored-by: Amine Alami <43780877+Alami-Amine@users.noreply.github.com> Co-authored-by: Daniel Nicoara <dnicoara@google.com> Co-authored-by: Moises Terrones <moises.tersal@gmail.com>
2 parents c5de744 + e36de71 commit 26435f0

66 files changed

Lines changed: 2395 additions & 1440 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/platforms/silabs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010

1111
[CLI guide](./silabs_cli_guide.md)
1212
[Common app behavior](./silabs_common_app_behavior.md)
13+
[Extending base app implementation](./silabs_extending_base_app_implementation.md)
1314
[EFR32 software update](./silabs_efr32_software_update.md)
1415
[Getting Started](./silabs_getting_started.md)
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Extending Base App Implementation
2+
3+
## Introduction
4+
5+
Silicon Labs Matter sample apps that support project upgrades use the Curiously
6+
Recurring Template Pattern (CRTP) so you can customize application behavior
7+
without editing the default `AppTask` implementation. Override `*Impl()` hooks
8+
in `CustomerAppTask` instead of modifying `AppTask.cpp` directly.
9+
10+
- [Introduction](#introduction)
11+
- [CustomerAppTask](#customerapptask)
12+
- [How to Override APIs](#how-to-override-apis)
13+
- [DataModelCallbacks and CustomerAppTask](#datamodelcallbacks-and-customerapptask)
14+
- [Sample Implementation](#sample-implementation)
15+
- [Override API Reference](#override-api-reference)
16+
17+
## CustomerAppTask
18+
19+
To implement custom app behavior you can override any Silicon Labs implemented
20+
API in the CustomerAppTask file. Each sample app provides
21+
[`CustomerAppTask.h`](../../../examples/platform/silabs/customer/CustomerAppTask.h)
22+
and
23+
[`CustomerAppTask.cpp`](../../../examples/platform/silabs/customer/CustomerAppTask.cpp)
24+
for that purpose. The base implementation and the full set of overridable
25+
`*Impl()` APIs live in that example's source tree under `include/AppTaskImpl.h`
26+
and `src/AppTask.cpp`. Any `*Impl()` you do not override keeps the Silicon Labs
27+
default behavior.
28+
29+
To customize behavior, copy
30+
[`CustomerAppTask.h`](../../../examples/platform/silabs/customer/CustomerAppTask.h)
31+
and
32+
[`CustomerAppTask.cpp`](../../../examples/platform/silabs/customer/CustomerAppTask.cpp)
33+
from `examples/platform/silabs/customer/` into your app's `include/` and `src/`
34+
folders, then update the corresponding paths in `BUILD.gn`.
35+
36+
## How to Override APIs
37+
38+
`CustomerAppTask` derives from the base AppTask through the Curiously Recurring
39+
Template Pattern (CRTP). You override only the `*Impl()` methods you need; the
40+
base declares one `*Impl()` per overridable API. Steps:
41+
42+
1. Find the method to override in the base API (see
43+
[Override API reference](#override-api-reference) below).
44+
2. Declare the same method signature in `CustomerAppTask` in your
45+
`CustomerAppTask.h` under `private:`. Match the base `*Impl()` signature
46+
exactly — note that `*Impl()` overrides are **non-static instance methods**
47+
even when the public dispatcher (e.g. `ButtonEventHandler`) is `static`.
48+
3. Implement the method in `CustomerAppTask.cpp`.
49+
4. Build. The CRTP layer automatically routes each call to your `*Impl()` if
50+
present, otherwise to the Silicon Labs default.
51+
52+
## DataModelCallbacks and CustomerAppTask
53+
54+
What used to live in `DataModelCallbacks.cpp` before Matter Extension 2.9.0 now
55+
lives in `AppTask.cpp`. The Matter SDK's `MatterPostAttributeChangeCallback` is
56+
implemented in
57+
[`examples/platform/silabs/BaseApplication.cpp`](../../../examples/platform/silabs/BaseApplication.cpp)
58+
and forwards to `AppTask::DMPostAttributeChangeCallback` (defined in
59+
`AppTask.cpp`), which you can customize via
60+
`DMPostAttributeChangeCallbackImpl()` in `CustomerAppTask`.
61+
62+
Forwarding into `AppTask` still goes through CRTP as in
63+
[How to Override APIs](#how-to-override-apis).
64+
65+
- **Methods that already exist in the AppTask** — Customize them by overriding
66+
the matching `*Impl()` method in `CustomerAppTask`. Do not edit
67+
`AppTask.cpp` for app-specific behavior.
68+
69+
- **New custom data model methods** — Add them in `CustomerAppTask` directly.
70+
Do not add new application logic in autogenerated sources; those edits will
71+
not survive regeneration or project upgrades.
72+
73+
## Sample Implementation
74+
75+
The following shows a minimal example `CustomerAppTask` that overrides
76+
`AppInitImpl()` and `ButtonEventHandlerImpl()` from the lighting app
77+
implementation.
78+
79+
**CustomerAppTask.h**
80+
81+
```cpp
82+
#pragma once
83+
#include "AppTaskImpl.h"
84+
85+
/**
86+
* Minimal AppTaskImpl-derived class. Override only the *Impl() methods you need;
87+
* add AppInitImpl(), GetAppTask(), and sAppTask as required by the CRTP base.
88+
*/
89+
class CustomerAppTask : public AppTaskImpl<CustomerAppTask>
90+
{
91+
public:
92+
static CustomerAppTask & GetAppTask() { return sAppTask; }
93+
94+
private:
95+
friend class AppTaskImpl<CustomerAppTask>;
96+
CHIP_ERROR AppInitImpl();
97+
void ButtonEventHandlerImpl(uint8_t button, uint8_t btnAction);
98+
static CustomerAppTask sAppTask;
99+
};
100+
```
101+
102+
**CustomerAppTask.cpp**
103+
104+
```cpp
105+
#include "CustomerAppTask.h"
106+
#include "AppTask.h"
107+
#include "AppConfig.h"
108+
#include "AppEvent.h"
109+
#include <platform/CHIPDeviceLayer.h>
110+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
111+
112+
using namespace ::chip::DeviceLayer::Silabs;
113+
114+
#define APP_FUNCTION_BUTTON 0
115+
#define APP_LIGHT_SWITCH 1
116+
117+
CustomerAppTask CustomerAppTask::sAppTask;
118+
119+
AppTask & AppTask::GetAppTask()
120+
{
121+
return CustomerAppTask::GetAppTask();
122+
}
123+
124+
CHIP_ERROR CustomerAppTask::AppInitImpl()
125+
{
126+
SILABS_LOG("CustomerAppTask: custom implementation (AppInitImpl)");
127+
CHIP_ERROR err = this->AppTask::AppInit();
128+
if (err == CHIP_NO_ERROR)
129+
{
130+
// Override the SDK default button handler registered in AppTask::AppInit().
131+
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(CustomerAppTask::ButtonEventHandler);
132+
}
133+
return err;
134+
}
135+
136+
void CustomerAppTask::ButtonEventHandlerImpl(uint8_t button, uint8_t btnAction)
137+
{
138+
SILABS_LOG("CustomerAppTask: custom implementation (ButtonEventHandlerImpl)");
139+
AppEvent button_event = {};
140+
button_event.Type = AppEvent::kEventType_Button;
141+
button_event.ButtonEvent.Action = btnAction;
142+
if (button == APP_LIGHT_SWITCH && btnAction == static_cast<uint8_t>(SilabsPlatform::ButtonAction::ButtonPressed))
143+
{
144+
button_event.Handler = LightActionEventHandler;
145+
AppTask::GetAppTask().PostEvent(&button_event);
146+
}
147+
else if (button == APP_FUNCTION_BUTTON)
148+
{
149+
button_event.Handler = BaseApplication::ButtonHandler;
150+
AppTask::GetAppTask().PostEvent(&button_event);
151+
}
152+
}
153+
```
154+
155+
## Override API Reference
156+
157+
`CHIP_ERROR StartAppTask()` is declared on `AppTask` only. It is not an
158+
`*Impl()` hook: platform code (for example `MatterConfig`) calls
159+
`AppTask::GetAppTask().StartAppTask()` with static type `AppTask &`, which runs
160+
the implementation in `AppTask.cpp` (creating the FreeRTOS app task via
161+
`BaseApplication::StartAppTask(...)`). To change startup behavior, edit
162+
`AppTask::StartAppTask()` or `BaseApplication::StartAppTask` in your product
163+
sources.
164+
165+
The base API and default AppTask behavior for each sample app are maintained
166+
under that app's `include/AppTaskImpl.h` and `src/AppTask.cpp`. Use those files
167+
as the reference for overridable methods and app configuration.
168+
169+
| File | Purpose |
170+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
171+
| `include/AppTaskImpl.h` | Declarations of every overridable `*Impl()` method. Copy the signatures you need from here into `CustomerAppTask.h`. |
172+
| `src/AppTask.cpp` | Silicon Labs default implementation of AppTask. This is what runs for any `*Impl()` you do not override. Use as reference when customizing behavior. |

‎examples/air-quality-sensor-app/silabs/README.md‎

Lines changed: 8 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG24.
77
- [Matter Air Quality Sensor Example](#matter-air-quality-sensor-example)
88
- [Introduction](#introduction)
99
- [Extending Base App Implementation](#extending-base-app-implementation)
10-
- [CustomerAppTask](#customerapptask)
11-
- [How to Override APIs](#how-to-override-apis)
12-
- [DataModelCallbacks and CustomerAppTask](#datamodelcallbacks-and-customerapptask)
13-
- [Sample Implementation](#sample-implementation)
14-
- [Override API Reference](#override-api-reference)
1510
- [Building](#building)
1611
- [Linux](#linux)
1712
- [Mac OS X](#mac-os-x)
@@ -63,145 +58,14 @@ the Silicon Labs platform.
6358

6459
## Extending Base App Implementation
6560

66-
### CustomerAppTask
67-
68-
To implement custom app behavior you can override any Silicon Labs implemented
69-
API in the CustomerAppTask file. This example provides
70-
[`CustomerAppTask.h`](../../platform/silabs/customer/CustomerAppTask.h) and
71-
[`CustomerAppTask.cpp`](../../platform/silabs/customer/CustomerAppTask.cpp) for
72-
that purpose. The base implementation and the full set of overridable `*Impl()`
73-
APIs live in this example's source tree under
74-
[`include/AppTaskImpl.h`](include/AppTaskImpl.h) and
75-
[`src/AppTask.cpp`](src/AppTask.cpp). Any `*Impl()` you do not override keeps
76-
the Silicon Labs default behavior. To customize behavior, copy
77-
[`CustomerAppTask.h`](../../platform/silabs/customer/CustomerAppTask.h) and
78-
[`CustomerAppTask.cpp`](../../platform/silabs/customer/CustomerAppTask.cpp) from
79-
`examples/platform/silabs/customer/` into this app's `include/` and `src/`
80-
folders, then update the corresponding paths in `BUILD.gn`.
81-
82-
### How to Override APIs
83-
84-
`CustomerAppTask` derives from the base AppTask through the Curiously Recurring
85-
Template Pattern (CRTP). You override only the `*Impl()` methods you need, the
86-
base declares one `*Impl()` per overridable API. Steps:
87-
88-
1. Find the method to override in the base API (see
89-
[Override API reference](#override-api-reference) below).
90-
2. Declare the same method signature in `CustomerAppTask` in your
91-
`CustomerAppTask.h` under `private:`. Match the base `*Impl()` signature
92-
exactly — note that `*Impl()` overrides are **non-static instance methods**
93-
even when the public dispatcher (e.g. `ButtonEventHandler`) is `static`.
94-
3. Implement the method in `CustomerAppTask.cpp`.
95-
4. Build. The CRTP layer automatically routes each call to your `*Impl()` if
96-
present, otherwise to the Silicon Labs default.
97-
98-
### DataModelCallbacks and CustomerAppTask
99-
100-
What used to live in `DataModelCallbacks.cpp` now lives in `AppTask.cpp`. The
101-
Matter SDK's `MatterPostAttributeChangeCallback` is implemented in
102-
`examples/platform/silabs/BaseApplication.cpp` and forwards to
103-
`AppTask::DMPostAttributeChangeCallback` (defined in `AppTask.cpp`), which you
104-
can customize via `DMPostAttributeChangeCallbackImpl()` in `CustomerAppTask`.
105-
106-
Forwarding into `AppTask` still goes through CRTP as in
107-
[How to Override APIs](#how-to-override-apis).
108-
109-
- **Methods that already exist in the AppTask** — Customize them by overriding
110-
the matching `*Impl()` method in `CustomerAppTask`. Do not edit the
111-
`AppTask.cpp` for app-specific behavior.
112-
113-
- **New custom data model methods** — Add them in `CustomerAppTask` directly.
114-
Do not add new application logic in autogenerated sources; those edits will
115-
not survive regeneration or project upgrades.
116-
117-
### Sample Implementation
118-
119-
The following shows a minimal example `CustomerAppTask` that overrides
120-
`AppInitImpl()` and `ButtonEventHandlerImpl()`.
121-
122-
**CustomerAppTask.h**
123-
124-
```cpp
125-
#pragma once
126-
#include "AppTaskImpl.h"
127-
128-
/** Minimal AppTaskImpl-derived class. Override only the *Impl() methods you need **/
129-
class CustomerAppTask : public AppTaskImpl<CustomerAppTask>
130-
{
131-
public:
132-
static CustomerAppTask & GetAppTask() { return sAppTask; }
133-
134-
private:
135-
friend class AppTaskImpl<CustomerAppTask>;
136-
CHIP_ERROR AppInitImpl();
137-
void ButtonEventHandlerImpl(uint8_t button, uint8_t btnAction);
138-
static CustomerAppTask sAppTask;
139-
};
140-
```
141-
142-
**CustomerAppTask.cpp**
143-
144-
```cpp
145-
#include "CustomerAppTask.h"
146-
#include "AppTask.h"
147-
#include "AppEvent.h"
148-
#include <platform/CHIPDeviceLayer.h>
149-
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
150-
151-
#define APP_FUNCTION_BUTTON 0
152-
153-
CustomerAppTask CustomerAppTask::sAppTask;
154-
155-
AppTask & AppTask::GetAppTask()
156-
{
157-
return CustomerAppTask::GetAppTask();
158-
}
159-
160-
CHIP_ERROR CustomerAppTask::AppInitImpl()
161-
{
162-
SILABS_LOG("CustomerAppTask: custom implementation (AppInitImpl)");
163-
CHIP_ERROR err = AppTask::AppInit();
164-
if (err == CHIP_NO_ERROR)
165-
{
166-
// Override the SDK default button handler registered in AppTask::AppInit().
167-
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(CustomerAppTask::ButtonEventHandler);
168-
}
169-
return err;
170-
}
171-
172-
void CustomerAppTask::ButtonEventHandlerImpl(uint8_t button, uint8_t btnAction)
173-
{
174-
SILABS_LOG("CustomerAppTask: custom implementation (ButtonEventHandlerImpl)");
175-
AppEvent aEvent = {};
176-
aEvent.Type = AppEvent::kEventType_Button;
177-
aEvent.ButtonEvent.Action = btnAction;
178-
179-
if (button == APP_FUNCTION_BUTTON)
180-
{
181-
aEvent.Handler = BaseApplication::ButtonHandler;
182-
AppTask::GetAppTask().PostEvent(&aEvent);
183-
}
184-
}
185-
```
186-
187-
### Override API Reference
188-
189-
`CHIP_ERROR StartAppTask()` is declared on `AppTask` only. It is not an
190-
`*Impl()` hook: platform code (for example `MatterConfig`) calls
191-
`AppTask::GetAppTask().StartAppTask()` with static type `AppTask &`, which runs
192-
the implementation in `AppTask.cpp` (creating the FreeRTOS app task via
193-
`BaseApplication::StartAppTask(...)`). To change startup behavior, edit
194-
`AppTask::StartAppTask()` or `BaseApplication::StartAppTask` in your product
195-
sources.
196-
197-
The base API and default AppTask behavior for this example are maintained under
198-
[`include/`](include/AppTaskImpl.h) and [`src/`](src/AppTask.cpp). Use them as
199-
the reference for overridable methods and app configuration.
200-
201-
| File | Purpose |
202-
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
203-
| [`include/AppTaskImpl.h`](include/AppTaskImpl.h) | Declarations of every overridable `*Impl()` method. Copy the signatures you need from here into `CustomerAppTask.h`. |
204-
| [`src/AppTask.cpp`](src/AppTask.cpp) | Silicon Labs default implementation of AppTask. This is what runs for any `*Impl()` you do not override. Use as reference when customizing behavior. |
61+
See
62+
[Extending Base App Implementation](../../../docs/platforms/silabs/silabs_extending_base_app_implementation.md)
63+
for how to customize application behavior using `CustomerAppTask` and CRTP
64+
`*Impl()` hooks.
65+
66+
Per-example override API references:
67+
[`include/AppTaskImpl.h`](include/AppTaskImpl.h),
68+
[`src/AppTask.cpp`](src/AppTask.cpp).
20569

20670
## Building
20771

‎examples/all-devices-app/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The application supports the following device types (specified via the
8181
- `dimmable-light`
8282
- `dimmable-plug-in-unit`
8383
- `dishwasher`
84+
- `doorbell`
8485
- `electrical-sensor`
8586
- `extractor-hood`
8687
- `fan`
@@ -131,7 +132,7 @@ Usage: ./out/linux-x64-all-devices-boringssl-no-ble/all-devices-app
131132
132133
PROGRAM OPTIONS
133134
134-
--device <aggregator|air-purifier|air-quality-sensor|air-quality-sensor-full|ambient-context-sensor|bridged-node|chime|commissioning-proxy|contact-sensor|cooktop|device-energy-management|dimmable-light|dimmable-plug-in-unit|dishwasher|electrical-sensor|extractor-hood|fan|fan-no-onoff|flow-sensor|generic-switch|humidity-conditioner|humidity-sensor|laundry-dryer|laundry-washer|light-sensor|microwave-oven|mode-select|mounted-dimmable-load-control|mounted-on-off-control|network-infrastructure-manager|occupancy-sensor|on-off-light|on-off-light-switch|on-off-plug-in-unit|oven|oven-2|power-source|pressure-sensor|proximity-ranger|rain-sensor|refrigerator|refrigerator-2|robotic-vacuum-cleaner|room-air-conditioner|room-air-conditioner-with-sensors|smoke-co-alarm|soil-sensor|speaker|temperature-sensor|thread-border-router|water-freeze-detector|water-leak-detector|water-valve|window-covering>
135+
--device <aggregator|air-purifier|air-quality-sensor|air-quality-sensor-full|ambient-context-sensor|bridged-node|chime|commissioning-proxy|contact-sensor|cooktop|device-energy-management|dimmable-light|dimmable-plug-in-unit|dishwasher|doorbell|electrical-sensor|extractor-hood|fan|fan-no-onoff|flow-sensor|generic-switch|humidity-conditioner|humidity-sensor|laundry-dryer|laundry-washer|light-sensor|microwave-oven|mode-select|mounted-dimmable-load-control|mounted-on-off-control|network-infrastructure-manager|occupancy-sensor|on-off-light|on-off-light-switch|on-off-plug-in-unit|oven|oven-2|power-source|pressure-sensor|proximity-ranger|rain-sensor|refrigerator|refrigerator-2|robotic-vacuum-cleaner|room-air-conditioner|room-air-conditioner-with-sensors|smoke-co-alarm|soil-sensor|speaker|temperature-sensor|thread-border-router|water-freeze-detector|water-leak-detector|water-valve|window-covering>
135136
Select the device to start up. Format: 'type' or 'type:endpoint' or 'type:endpoint,parent=parentId'
136137
Can be specified multiple times for multi-endpoint devices.
137138
Example: --device chime:1 --device speaker:2,parent=1

‎examples/all-devices-app/all-devices-common/device-factory/BUILD.gn‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ source_set("device-factory") {
4848
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-light:logging",
4949
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-plug-in-unit",
5050
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dishwasher:emulated",
51+
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/doorbell",
5152
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/electrical-sensor:logging",
5253
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/extended-color-light:logging",
5354
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/extractor-hood",

‎examples/all-devices-app/all-devices-common/device-factory/DeviceFactory.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <device/types/dimmable-light/impl/LoggingDimmableLight.h>
3939
#include <device/types/dimmable-plug-in-unit/DimmablePlugInUnit.h>
4040
#include <device/types/dishwasher/impl/EmulatedDishwasher.h>
41+
#include <device/types/doorbell/Doorbell.h>
4142
#include <device/types/electrical-sensor/impl/SimulatedElectricalSensor.h>
4243
#include <device/types/extended-color-light/impl/LoggingExtendedColorLight.h>
4344
#include <device/types/extractor-hood/ExtractorHood.h>
@@ -530,6 +531,19 @@ class DeviceFactory
530531
MountedDimmableLoadControl::Config{ .levelControl = DimmableLoad::LevelControlConfig::CiPicsDefaults() });
531532
});
532533
}
534+
if constexpr (ALL_DEVICES_ENABLE_DOORBELL)
535+
{
536+
RegisterCreator("doorbell", [this]() {
537+
VerifyOrDie(mContext.has_value());
538+
return MakeDevice<Doorbell>(Doorbell::Config{
539+
.timerDelegate = mContext->timerDelegate,
540+
.platformManager = mContext->platformManager,
541+
.bindingTable = mContext->bindingTable,
542+
.bindingManager = mContext->bindingManager,
543+
.identifyDelegate = mContext->identifyDelegate,
544+
});
545+
});
546+
}
533547
if constexpr (ALL_DEVICES_ENABLE_MOUNTED_ON_OFF_CONTROL)
534548
{
535549
RegisterCreator("mounted-on-off-control", [this]() {

0 commit comments

Comments
 (0)