Skip to content

Commit 51bde28

Browse files
Sync csa branch with main (#646)
2 parents c05da7f + 90d5659 commit 51bde28

File tree

250 files changed

+2717
-2122
lines changed

Some content is hidden

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

250 files changed

+2717
-2122
lines changed

.gemini/styleguide.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
# Gemini Code Review Instructions
22

33
- Do not comment on content for XML files or .matter content for clusters
4-
- Assume the matter specification is unknown and out of scope. Do not make uninformed assumptions about the Matter specification, or its contents.
5-
- Do not comment unless a change is probably desirable
4+
- The SDK is implementing an in-progress matter specification that may not be available yet.
5+
Assume the matter specification is unknown and out of scope. Do not make uninformed assumptions
6+
about the Matter specification, or its contents.
7+
- Do not comment unless a change is probably desirable
68
- Do not repeat yourself. Be concise without losing meaning
79
- Do not over-explain what you see in the code. Only describe code if there are specific questions or concerns (or if a question is asked)
810
- Ensure that extensions or fixes to existing code should match the prevailing style of the original code
911
- Look for common typos and suggest fixes
10-
- The current year is 2025.
1112
- Wrong years and years in the future are OK. Humans will catch these issues.
12-
- Comments regarding issues about whitespace or code alignment are not needed. A code formatter will take care of these problems.
13+
- The SDK uses automated code formatting. Do not comment on whitespace, line length or other formatting
14+
or whitespace issues. A code formatter will handle this.
15+
16+
## Development guides
17+
18+
The SDK source code contains guides for development best practices in `docs/guides`, `docs/testing` and other `docs` locations.
19+
Use these as a reference for finding common patterns and potential issues in new code. In particular:
20+
- [docs/guides/writing_clusters](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/writing_clusters.md) describes how cluster handling
21+
is to be implemented
22+
- [docs/guides/migrating_ember_cluster_to_code_driven.md](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/migrating_ember_cluster_to_code_driven.md)
23+
describes how ember clusters can be migrated to code driven
24+
- [docs/testing/unit_testing.md](https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/unit_testing.md)
25+
describes how to implement unit testing
26+
- [docs/testing/integration_tests.md](https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/integration_tests.md)
27+
describes how to implement integration tests.
28+
29+

.github/workflows/analyze-changed-paths.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@ env:
3636
CHIP_NO_LOG_TIMESTAMPS: true
3737

3838
jobs:
39-
changed_paths:
40-
uses: ./.github/workflows/analyze-changed-paths.yaml
41-
4239
build_linux_gcc_debug:
4340
name: Build on Linux (gcc_debug)
44-
needs: changed_paths
41+
4542
runs-on: ubuntu-latest
46-
if: github.actor != 'restyled-io[bot]' && needs.changed_paths.outputs.non_md_changes == 'true'
43+
if: github.actor != 'restyled-io[bot]'
4744

4845
container:
4946
image: ghcr.io/project-chip/chip-build:167
@@ -151,9 +148,9 @@ jobs:
151148

152149
build_linux:
153150
name: Build on Linux (fake, gcc_release, clang, simulated)
154-
needs: changed_paths
151+
155152
runs-on: ubuntu-latest
156-
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true && needs.changed_paths.outputs.non_md_changes == 'true'
153+
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true
157154

158155
container:
159156
image: ghcr.io/project-chip/chip-build:167
@@ -329,9 +326,9 @@ jobs:
329326

330327
build_linux_python_lib:
331328
name: Build on Linux (python_lib)
332-
needs: changed_paths
329+
333330
runs-on: ubuntu-latest
334-
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true && needs.changed_paths.outputs.non_md_changes == 'true'
331+
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true
335332

336333
container:
337334
image: ghcr.io/project-chip/chip-build:167
@@ -392,9 +389,9 @@ jobs:
392389

393390
build_linux_python_lighting_device:
394391
name: Build on Linux (python lighting-app)
395-
needs: changed_paths
392+
396393
runs-on: ubuntu-latest
397-
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true && needs.changed_paths.outputs.non_md_changes == 'true'
394+
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true
398395

399396
container:
400397
image: ghcr.io/project-chip/chip-build:167
@@ -426,9 +423,8 @@ jobs:
426423
427424
build_darwin:
428425
name: Build on Darwin (clang, simulated)
429-
needs: changed_paths
430426
runs-on: macos-13
431-
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true && needs.changed_paths.outputs.non_md_changes == 'true'
427+
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true
432428

433429
steps:
434430
- name: Checkout
@@ -514,11 +510,11 @@ jobs:
514510

515511
build_linux_gcc_coverage:
516512
name: Build on Linux (coverage)
517-
needs: changed_paths
513+
518514
env:
519515
TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt"
520516

521-
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true && needs.changed_paths.outputs.non_md_changes == 'true'
517+
if: github.actor != 'restyled-io[bot]' && inputs.run-codeql != true
522518
runs-on: ubuntu-latest
523519

524520
container:

.github/workflows/tests.yaml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ env:
4343
CHIP_NO_LOG_TIMESTAMPS: true
4444

4545
jobs:
46-
changed_paths:
47-
uses: ./.github/workflows/analyze-changed-paths.yaml
48-
4946
test_suites_linux:
5047
name: Test Suites - Linux
51-
needs: changed_paths
48+
5249
strategy:
5350
matrix:
5451
build_variant: [no-ble-no-shell-tsan-clang]
@@ -61,7 +58,7 @@ jobs:
6158
DISABLE_CCACHE: ${{ (github.event_name == 'workflow_dispatch' && inputs.disable_ccache == 'true') && 'true' || (contains(github.event.head_commit.message, '[no-ccache]') && 'true') || 'false' }}
6259
CCACHE_KEY_SUFFIX: ${{ github.event_name == 'workflow_dispatch' && inputs.cache_suffix || '' }}
6360

64-
if: github.actor != 'restyled-io[bot]' && needs.changed_paths.outputs.non_md_changes == 'true'
61+
if: github.actor != 'restyled-io[bot]'
6562
runs-on: ubuntu-latest
6663

6764
container:
@@ -436,7 +433,7 @@ jobs:
436433

437434
test_suites_darwin:
438435
name: Test Suites - Darwin
439-
needs: changed_paths
436+
440437
strategy:
441438
matrix:
442439
build_variant: [no-ble-no-shell-asan-clang, no-ble-no-shell-tsan-clang]
@@ -447,7 +444,7 @@ jobs:
447444
TSAN_OPTIONS: "halt_on_error=1"
448445
LSAN_OPTIONS: detect_leaks=1 suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt
449446

450-
if: github.actor != 'restyled-io[bot]' && needs.changed_paths.outputs.non_md_changes == 'true'
447+
if: github.actor != 'restyled-io[bot]'
451448
runs-on: macos-13
452449

453450
steps:
@@ -553,8 +550,8 @@ jobs:
553550

554551
repl_tests_linux:
555552
name: REPL Tests - Linux
556-
needs: changed_paths
557-
if: github.actor != 'restyled-io[bot]' && needs.changed_paths.outputs.non_md_changes == 'true'
553+
554+
if: github.actor != 'restyled-io[bot]'
558555

559556
strategy:
560557
matrix:
@@ -849,17 +846,17 @@ jobs:
849846
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/test_TC_ICDM_2_1_min_pics.py'
850847
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/test_TC_SC_7_1.py'
851848
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestDecorators.py'
852-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestChoiceConformanceSupport.py'
853-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestConformanceSupport.py'
854-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestConformanceTest.py'
855-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestDefaultWarnings.py'
856-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestIdChecks.py'
857-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestMatterTestingSupport.py'
858-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestPics.py'
859-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestSpecParsingDeviceType.py'
860-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestSpecParsingNamespace.py'
861-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestSpecParsingSelection.py'
862-
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/TestSpecParsingSupport.py'
849+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestChoiceConformanceSupport.py'
850+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestConformanceSupport.py'
851+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestConformanceTest.py'
852+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestDefaultWarnings.py'
853+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestIdChecks.py'
854+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestMatterTestingSupport.py'
855+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestPics.py'
856+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestSpecParsingDeviceType.py'
857+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestSpecParsingNamespace.py'
858+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestSpecParsingSelection.py'
859+
scripts/run_in_python_env.sh out/venv 'python3 src/python_testing/test_testing/TestSpecParsingSupport.py'
863860
scripts/run_in_python_env.sh out/venv 'PYTHONPATH=src/python_testing:$PYTHONPATH python3 -m unittest discover -s src/python_testing/mdns_discovery/tests -p "test_*.py"'
864861
865862
- name: Run Tests
@@ -913,15 +910,15 @@ jobs:
913910

914911
repl_tests_darwin:
915912
name: REPL Tests - Darwin (Build Only)
916-
needs: changed_paths
913+
917914
strategy:
918915
matrix:
919916
build_variant: [no-ble-no-wifi-tsan-clang]
920917
env:
921918
BUILD_VARIANT: ${{matrix.build_variant}}
922919
TSAN_OPTIONS: "halt_on_error=1"
923920

924-
if: github.actor != 'restyled-io[bot]' && needs.changed_paths.outputs.non_md_changes == 'true'
921+
if: github.actor != 'restyled-io[bot]'
925922
runs-on: macos-13
926923

927924
steps:

.restyled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ restylers:
224224
- "**/*.sh"
225225
- "**/*.bash"
226226
- name: autopep8
227-
image: restyled/restyler-autopep8:v2.0.0
227+
image: restyled/restyler-autopep8:v2.3.0
228228
command:
229229
- autopep8
230230
- "--in-place"

credentials/generate_revocation_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ def cli():
864864
@optgroup.option('--use-test-net-dcld', type=str, default='', metavar='PATH', help="Location of `dcld` binary, to use `dcld` for mirroring TestNet.")
865865
@optgroup.option('--use-main-net-http', is_flag=True, type=str, help="Use RESTful API with HTTPS against public MainNet observer.")
866866
@optgroup.option('--use-test-net-http', is_flag=True, type=str, help="Use RESTful API with HTTPS against public TestNet observer.")
867-
@optgroup.option('--use-local-data', is_flag=True, type=bool, help="Fake response directory: see \" DATA_DIR/",)
867+
@optgroup.option('--use-local-data', is_flag=True, type=bool, help="Fake response directory: see \" DATA_DIR/")
868868
@optgroup.group('Required arguments if use-local-data is used', cls=AllOptionGroup)
869869
@optgroup.option('--certificates', type=click.File('rb'), multiple=True, help='Paths to PEM formated certificates (i.e. PAA) in DCL but missing from the revocation-points-response file.')
870870
@optgroup.option('--crls', type=click.File('rb'), multiple=True, help='Paths to the crl der files')

docs/guides/migrating_ember_cluster_to_code_driven.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ type-safe accessors in
2323
In a code-driven implementation, this data must be moved into member variables
2424
within your new cluster class.
2525

26+
In some cases the cluster directory may not exist. In that case, create a new
27+
directory and add the mapping in
28+
[src/app/zap_cluster_list.json](https://github.com/project-chip/connectedhomeip/blob/master/src/app/zap_cluster_list.json)
29+
under the `ServerDirectories` key.
30+
2631
### `AttributeAccessInterface` (`AAI`) and `CommandHandlerInterface` (`CHI`)
2732

2833
When more complex logic is needed, Ember clusters use these interfaces.
@@ -100,8 +105,31 @@ new code-driven class structure.
100105

101106
#### Command Handling
102107

103-
- Translate `emberAf...Callback` functions into logic inside your
104-
`InvokeCommand` method.
108+
- Translate `CommandHandlerInterface` calls or `emberAf...Callback` functions
109+
into logic inside your `InvokeCommand` method:
110+
111+
- ember calls of the form `emberAf<CLUSTER>Cluster<COMMAND>Callback` will
112+
be converted to a switch `case <CLUSTER>::Commands::<COMMAND>::Id: ...`
113+
implementation
114+
115+
Example:
116+
117+
```cpp
118+
// This
119+
emberAfAccessControlClusterReviewFabricRestrictionsCallback(...);
120+
121+
// Becomes this in the `InvokeCommand` implementation:
122+
switch (request.path.mCommandId) {
123+
// ...
124+
case AccessControl::Commands::ReviewFabricRestrictions::Id:
125+
// ...
126+
}
127+
```
128+
129+
- Command Handler Interface logic translates directly: `CHI` has a switch
130+
on command ID inside its `InvokeCommand` call. You should have the same
131+
logic inside the `ServerClusterInterface` processing logic.
132+
105133
- The `InvokeCommand` method can return an `ActionReturnStatus` optional. For
106134
better readability, prefer returning a status code directly (e.g.,
107135
`return Status::Success;`) rather than using the command handler to set the
@@ -157,6 +185,11 @@ data.
157185
`zcl-with-test-extensions.json`, add all of your cluster's non-list
158186
attributes to the `attributeAccessInterfaceAttributes` list. This tells ZAP
159187
not to allocate RAM for these attributes, as your class now manages them.
188+
3. Re-run ZAP regeneration, like
189+
190+
```bash
191+
./scripts/run_in_build_env.sh 'scripts/tools/zap_regen_all.py'
192+
```
160193

161194
---
162195

docs/guides/writing_clusters.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,23 @@ generated from XML definitions located in
4646

4747
### File Structure
4848

49-
Create a new directory for your cluster at `src/app/clusters/<cluster-name>/`.
50-
This directory will house the cluster implementation and its unit tests.
49+
Create a new directory for your cluster at
50+
`src/app/clusters/<cluster-directory>/`. This directory will house the cluster
51+
implementation and its unit tests.
52+
53+
For zap-based support, the directory mapping is defined in
54+
[src/app/zap_cluster_list.json](https://github.com/project-chip/connectedhomeip/blob/master/src/app/zap_cluster_list.json)
55+
under the `ServerDirectories` key. This maps the `UPPER_SNAKE_CASE` define of
56+
the cluster to the directory name under `src/app/clusters`.
57+
58+
#### Naming conventions
59+
60+
Names vary, however to be consistent with most of the existing code use:
61+
62+
- `cluster-name-server` for the cluster directory name
63+
- `ClusterNameSnakeCluster.h/cpp` for the `ServerClusterInterface`
64+
implementation
65+
- `ClusterNameSnakeLogic.h/cpp` for the `Logic` implementation if applicable
5166

5267
### Recommended Modular Layout
5368

@@ -91,10 +106,34 @@ attribute's value changes.
91106
- Use the context to call
92107
`interactionContext->dataModelChangeListener->MarkDirty(path)`. A
93108
`NotifyAttributeChanged` helper exists for paths managed by this cluster.
109+
94110
- For write implementations, you can use `NotifyAttributeChangedIfSuccess`
95111
together with a separate `WriteImpl` such that any successful attribute
96112
write will notify.
97113
114+
Canonical example code would look like:
115+
116+
```cpp
117+
DataModel::ActionReturnStatus SomeCluster::WriteAttribute(const DataModel::WriteAttributeRequest & request,
118+
AttributeValueDecoder & decoder)
119+
{
120+
// Delegate everything to WriteImpl. If write succeeds, notify that the attribute changed.
121+
return NotifyAttributeChangedIfSuccess(request.path.mAttributeId, WriteImpl(request, decoder));
122+
}
123+
```
124+
125+
- For the `NotifyAttributeChangedIfSuccess` ensure that WriteImpl is
126+
returning
127+
[ActionReturnStatus::FixedStatus::kWriteSuccessNoOp](https://github.com/project-chip/connectedhomeip/blob/master/src/app/data-model-provider/ActionReturnStatus.h)
128+
when no notification should be sent (e.g. write was a `noop` because
129+
existing value was already the same).
130+
131+
Canonical example is:
132+
133+
```cpp
134+
VerifyOrReturnValue(mValue != value, ActionReturnStatus::FixedStatus::kWriteSuccessNoOp);
135+
```
136+
98137
#### Persistent Storage
99138
100139
- **Attributes:** For scalar attribute values, use `AttributePersistence` from
@@ -162,6 +201,12 @@ implementation.
162201
`zcl-with-test-extensions.json`, add all non-list attributes of your
163202
cluster to `attributeAccessInterfaceAttributes`. This marks them as
164203
externally handled.
204+
7. Once `config-data.yaml` and `zcl.json/zcl-with-test-extensions.json` are
205+
updated, run the ZAP regeneration command, like
206+
207+
```bash
208+
./scripts/run_in_build_env.sh 'scripts/tools/zap_regen_all.py'
209+
```
165210
166211
---
167212

examples/air-purifier-app/air-purifier-common/air-purifier-app.matter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,8 +2950,8 @@ endpoint 0 {
29502950
}
29512951

29522952
server cluster DiagnosticLogs {
2953-
ram attribute featureMap default = 0;
2954-
ram attribute clusterRevision default = 1;
2953+
callback attribute featureMap;
2954+
callback attribute clusterRevision;
29552955

29562956
handle command RetrieveLogsRequest;
29572957
}

0 commit comments

Comments
 (0)