Skip to content

Commit c5de744

Browse files
Sync csa branch with main (#1254)
2 parents e1be758 + d34948b commit c5de744

87 files changed

Lines changed: 6867 additions & 3659 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.

‎.github/.wordlist.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ ClusterName
269269
ClusterObjectTests
270270
ClusterRevision
271271
ClusterTestGeneration
272+
ClosureControl
272273
CMAC
273274
cmake
274275
CMakeLists

‎.github/workflows/silabs-common-build.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
container:
21-
image: ghcr.io/project-chip/chip-build-efr32:211
21+
image: ghcr.io/project-chip/chip-build-efr32:215
2222

2323
strategy:
2424
fail-fast: false

‎.github/workflows/silabs-custom-thread-build.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
container:
21-
image: ghcr.io/project-chip/chip-build-efr32:211
21+
image: ghcr.io/project-chip/chip-build-efr32:215
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v7

‎config/silabs/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ config CHIP_FACTORY_DATA
6767
bool "Use provisioned factory data from Zephyr settings"
6868
default n
6969
help
70-
Enables Provision::Storage (ProvisionStorageZephyr) that reads
70+
Enables ProvisionStorageReader, which reads
7171
provisioned credentials and commissionable data from Zephyr settings
7272
stored in the storage partition. Factory data is expected to be
7373
provisioned into NVS separately using Silicon Labs generator

‎examples/closure-app/silabs/BUILD.gn‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ if (wifi_soc) {
7676
include_dirs = [
7777
"${chip_root}/src/platform/silabs/SiWx",
7878
"${silabs_project_dir}/include",
79+
"${silabs_project_dir}/include/customer",
7980
"${examples_plat_dir}",
81+
"${examples_common_plat_dir}/customer",
8082
"${chip_root}/src/lib",
8183
"${examples_common_plat_dir}",
8284
"${examples_common_plat_dir}/freertos_config",
@@ -100,7 +102,9 @@ if (wifi_soc) {
100102
include_dirs = [
101103
"${chip_root}/src/platform/silabs/efr32",
102104
"${silabs_project_dir}/include",
105+
"${silabs_project_dir}/include/customer",
103106
"${examples_plat_dir}",
107+
"${examples_common_plat_dir}/customer",
104108
"${chip_root}/src/lib",
105109
"${examples_common_plat_dir}",
106110
"${examples_common_plat_dir}/freertos_config",
@@ -119,6 +123,7 @@ silabs_executable("closure_app") {
119123
output_name = "matter-silabs-closure-example.out"
120124
include_dirs = [
121125
"include",
126+
"include/customer",
122127
"${example_closure_dir}/closure-common/include",
123128
]
124129
defines = []
@@ -130,9 +135,10 @@ silabs_executable("closure_app") {
130135
sources = [
131136
"${example_closure_dir}/closure-common/src/ClosureControlEndpoint.cpp",
132137
"${example_closure_dir}/closure-common/src/ClosureDimensionEndpoint.cpp",
138+
"${examples_common_plat_dir}/customer/CustomerAppTask.cpp",
133139
"src/AppTask.cpp",
134140
"src/ClosureManager.cpp",
135-
"src/DataModelCallbacks.cpp",
141+
"src/customer/CustomerAppManager.cpp",
136142
]
137143

138144
if (!disable_lcd) {

‎examples/closure-app/silabs/README.md‎

Lines changed: 505 additions & 45 deletions
Large diffs are not rendered by default.

‎examples/closure-app/silabs/include/AppEvent.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ struct AppEvent : public BaseAppEvent
3333
{
3434
uint8_t Action;
3535
uint16_t EndpointId;
36+
uint32_t Generation;
3637
} ClosureEvent;
3738
};

‎examples/closure-app/silabs/include/AppTask.h‎

Lines changed: 19 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,19 @@
1919

2020
#pragma once
2121

22-
/**********************************************************
23-
* Includes
24-
*********************************************************/
25-
26-
#include <stdbool.h>
27-
#include <stdint.h>
28-
29-
#include "AppEvent.h"
3022
#include "BaseApplication.h"
31-
32-
#include "FreeRTOS.h"
33-
#include "timers.h" // provides FreeRTOS timer support
34-
#include <ble/BLEEndPoint.h>
23+
#include <app/ConcreteAttributePath.h>
24+
#include <cstdint>
3525
#include <lib/core/CHIPError.h>
36-
#include <platform/CHIPDeviceLayer.h>
37-
38-
/**********************************************************
39-
* AppTask Declaration
40-
*********************************************************/
4126

4227
class AppTask : public BaseApplication
4328
{
4429

4530
public:
4631
AppTask() = default;
4732

48-
static AppTask & GetAppTask() { return sAppTask; }
33+
/** @brief Returns the active app instance */
34+
static AppTask & GetAppTask();
4935

5036
/**
5137
* @brief AppTask task main loop function
@@ -54,57 +40,31 @@ class AppTask : public BaseApplication
5440
*/
5541
static void AppTaskMain(void * pvParameter);
5642

43+
/** @brief Creates and starts the AppTask thread */
5744
CHIP_ERROR StartAppTask();
5845

5946
/**
60-
* @brief Event handler when a button is pressed
61-
* Function posts an event for button processing
47+
* @brief Event handler when a button is pressed.
6248
*
63-
* @param buttonHandle APP_FUNCTION_BUTTON
64-
* @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
65-
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
49+
* @param button APP_CLOSURE_BUTTON or APP_FUNCTION_BUTTON
50+
* @param btnAction SL_SIMPLE_BUTTON_PRESSED, SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
6651
*/
6752
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);
6853

69-
#if SL_MATTER_DISPLAY_ENABLED
70-
/**
71-
* @brief Updates the closure UI with current closure state
72-
*/
73-
static void UpdateClosureUI();
54+
/** @brief AppTask thread event handler for closure button actions */
55+
static void ClosureButtonActionEventHandler(AppEvent * aEvent);
7456

75-
/**
76-
* @brief Event handler for UI update events
77-
* Called from app task context to safely update UI with chip stack locked
78-
*
79-
* @param aEvent pointer to the UI update event being processed
80-
*/
81-
static void UpdateClosureUIHandler(AppEvent * aEvent);
82-
#endif // SL_MATTER_DISPLAY_ENABLED
57+
/** @brief Data model hook invoked when a cluster attribute changes */
58+
void DMPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
59+
uint8_t * value);
8360

84-
/**
85-
* @brief Closure button action event handler
86-
* Handles button press events for closure control operations
87-
*
88-
* @param aEvent pointer to the button event being processed
89-
*/
90-
static void ClosureButtonActionEventHandler(AppEvent * aEvent);
61+
/** @brief ClosureControl cluster attribute-change hook */
62+
void DMClosureControlClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath);
9163

92-
private:
93-
static AppTask sAppTask;
64+
/** @brief ClosureDimension cluster attribute-change hook */
65+
void DMClosureDimensionClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath);
9466

95-
/**
96-
* @brief Override of BaseApplication::AppInit() virtual method, called by BaseApplication::Init()
97-
*
98-
* @return CHIP_ERROR
99-
*/
67+
protected:
68+
/** @brief Override of `BaseApplication::AppInit()` */
10069
CHIP_ERROR AppInit() override;
101-
102-
/**
103-
* @brief PB0 Button event processing function
104-
* Press and hold will trigger a factory reset timer start
105-
* Press and release will restart BLEAdvertising if not commisionned
106-
*
107-
* @param aEvent button event being processed
108-
*/
109-
static void ButtonHandler(AppEvent * aEvent);
11070
};
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* Copyright (c) 2025 Google LLC.
5+
* All rights reserved.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#pragma once
21+
22+
#include "AppTask.h"
23+
#include "CRTPHelpers.h"
24+
25+
/**
26+
* @brief CRTP override layer for `AppTask`.
27+
*
28+
* Each public entry point dispatches to a corresponding `Derived::*Impl()` hook.
29+
* The default `*Impl()` (declared private below) forwards to `AppTask`, so
30+
* `Derived` only needs to override the hooks whose behavior it wants to
31+
* customize.
32+
*
33+
* Customer code overrides these hooks in `CustomerAppTask`; see the app README
34+
* ("How to Override APIs").
35+
*
36+
* @tparam Derived The CRTP derived class (`CustomerAppTask`).
37+
*/
38+
template <typename Derived>
39+
class AppTaskImpl : public AppTask
40+
{
41+
public:
42+
// Common AppTask bring up
43+
CHIP_ERROR AppInit() override { CRTP_OPTIONAL_DISPATCH(AppTaskImpl, Derived, AppInitImpl); }
44+
45+
// Handle button press
46+
static void ButtonEventHandler(uint8_t button, uint8_t btnAction)
47+
{
48+
CRTP_OPTIONAL_STATIC_DISPATCH(AppTaskImpl, Derived, ButtonEventHandlerImpl, button, btnAction);
49+
}
50+
51+
// AppTask thread handler for the closure button action event
52+
static void ClosureButtonActionEventHandler(AppEvent * aEvent)
53+
{
54+
CRTP_OPTIONAL_STATIC_DISPATCH(AppTaskImpl, Derived, ClosureButtonActionEventHandlerImpl, aEvent);
55+
}
56+
57+
// Data model hook invoked when a cluster attribute changes
58+
void DMPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
59+
uint8_t * value)
60+
{
61+
CRTP_OPTIONAL_VOID_DISPATCH(AppTaskImpl, Derived, DMPostAttributeChangeCallbackImpl, attributePath, type, size, value);
62+
}
63+
64+
// Data model hook for ClosureControl cluster attribute changes
65+
void DMClosureControlClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath)
66+
{
67+
CRTP_OPTIONAL_VOID_DISPATCH(AppTaskImpl, Derived, DMClosureControlClusterAttributeChangedCallbackImpl, attributePath);
68+
}
69+
70+
// Data model hook for ClosureDimension cluster attribute changes
71+
void DMClosureDimensionClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath)
72+
{
73+
CRTP_OPTIONAL_VOID_DISPATCH(AppTaskImpl, Derived, DMClosureDimensionClusterAttributeChangedCallbackImpl, attributePath);
74+
}
75+
76+
private:
77+
friend Derived;
78+
79+
// Default *Impl() hooks, each forwards to the matching AppTask method
80+
// Override the corresponding hook in CustomerAppTask to customize behavior
81+
82+
CHIP_ERROR AppInitImpl() { return AppTask::AppInit(); }
83+
84+
void ButtonEventHandlerImpl(uint8_t button, uint8_t btnAction) { AppTask::ButtonEventHandler(button, btnAction); }
85+
86+
void ClosureButtonActionEventHandlerImpl(AppEvent * aEvent) { AppTask::ClosureButtonActionEventHandler(aEvent); }
87+
88+
void DMPostAttributeChangeCallbackImpl(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
89+
uint8_t * value)
90+
{
91+
AppTask::DMPostAttributeChangeCallback(attributePath, type, size, value);
92+
}
93+
94+
void DMClosureControlClusterAttributeChangedCallbackImpl(const chip::app::ConcreteAttributePath & attributePath)
95+
{
96+
AppTask::DMClosureControlClusterAttributeChangedCallback(attributePath);
97+
}
98+
99+
void DMClosureDimensionClusterAttributeChangedCallbackImpl(const chip::app::ConcreteAttributePath & attributePath)
100+
{
101+
AppTask::DMClosureDimensionClusterAttributeChangedCallback(attributePath);
102+
}
103+
};

‎examples/closure-app/silabs/include/CHIPProjectConfig.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,6 @@
100100
*
101101
*/
102102
#define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (2000_ms32)
103+
104+
// This is a temporary setting to use the CustomerAppTask for the apps which are not upgraded to the new architecture.
105+
#define CHIP_SILABS_APP_USE_CUSTOMER_APP_TASK

0 commit comments

Comments
 (0)