Skip to content

Commit 4c4970a

Browse files
authored
Documentation: getting started - changing examples (project-chip#35929)
* Documentation: getting started - changing examples Add a new documentation file that shows how to change, re-gen and recompile examples. * Add to index * Fix spelling
1 parent 0d78b5f commit 4c4970a

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Changing Examples
2+
3+
The composition of most examples in the SDK is static and code generated.
4+
5+
The tool used to describe and change the composition of an example is called
6+
ZAP. More information about ZAP and a walk-through of the tool can be found in
7+
the [ZAP introduction](./zap.md). The composition of the device is captured in a
8+
.zap file, which is readable by the ZAP tool. This is then compiled into a
9+
human-readable .matter file, which is used to build the static features of the
10+
example.
11+
12+
To change the composition of a device example, you need to
13+
14+
1. Change the zap file to implement your desired changes
15+
2. Run the code generation tool to generate the .matter file
16+
3. Re-build the example
17+
18+
## Changing the zap file in an example
19+
20+
Most examples in the SDK keep the .zap file in a sub-directory called
21+
example-name-common (ex. lighting-common). To load an existing .zap file into
22+
the ZAP tool, from the chip-root use
23+
24+
```
25+
./scripts/tools/zap/run_zaptool.sh <location of the .zap file>
26+
```
27+
28+
For example, to make changes to the lighting app, use:
29+
30+
```
31+
./scripts/tools/zap/run_zaptool.sh examples/lighting-app/lighting-common/lighting-app.zap
32+
```
33+
34+
This will open the ZAP GUI tool, which can be used to change the endpoint
35+
composition, clusters, features, attributes, commands and events exposed by the
36+
device.
37+
38+
Details of how to use the tool can be found in the [ZAP Introduction](./zap.md).
39+
40+
## Running code generation
41+
42+
To compile the .matter file for use in building, use:
43+
44+
```
45+
./scripts/tools/zap/generate.py <location of the .zap file>
46+
```
47+
48+
For example, for changes to the lighting app, use:
49+
50+
```
51+
./scripts/tools/zap/generate.py examples/lighting-app/lighting-common/lighting-app.zap
52+
```
53+
54+
If there are changes to many .zap files, the following script can be used to
55+
recompile the .zap files for all the examples and the controller.
56+
57+
```
58+
./scripts/tools/zap_regen_all.py
59+
```
60+
61+
## Rebuilding the example
62+
63+
After generating the .matter file, re-build the example. Instructions for
64+
building examples are given in [Building your first example](./first_example.md)

docs/getting_started/index.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ The following docs are a brief introduction to SDK development.
1212
```
1313

1414
- [Running your first example](./first_example.md)
15-
- [SDK Basics](./SDKBasics.md)
16-
- [ZAP](./zap.md)
15+
- [Changing examples](./changing_examples.md)
16+
- [SDK Architecture Introduction](./SDKBasics.md)
17+
- [ZAP Introduction](./zap.md)

0 commit comments

Comments
 (0)