Skip to content

Commit 7dab42a

Browse files
s07641069pull[bot]
authored andcommitted
[Telink] Add all clusters app & clusters minimal app (#23383)
* [Telink] Add all-cluster-minimal-app & all-cluster-app * [Telink] update md files & set Teilink Light as FTD * [Telink] Restyled * [Telink] Add targets * [Telink] Fix pair cmd example * [Telink] restyled * [Telink] Add new apps for target linux * [Telink] Add note reg set up a valid Network Commissioning cluster; Remove ThreadStartButton from minimal app.
1 parent ed30fb0 commit 7dab42a

File tree

35 files changed

+1905
-32
lines changed

35 files changed

+1905
-32
lines changed

.github/workflows/examples-telink.yaml

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020 Project CHIP Authors
1+
# Copyright (c) 2022 Project CHIP Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -54,37 +54,46 @@ jobs:
5454
GH_CONTEXT: ${{ toJson(github) }}
5555
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"
5656

57-
- name: Build example Telink Lighting App
57+
- name: Build example Telink All Clusters App
5858
run: |
5959
./scripts/run_in_build_env.sh \
60-
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-light' build"
60+
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-all-clusters' build"
61+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
62+
telink tlsr9518adk80d all-clusters-app \
63+
out/telink-tlsr9518adk80d-all-clusters/zephyr/zephyr.elf \
64+
/tmp/bloat_reports/
6165
62-
- name: Build example Telink Light Switch App
66+
- name: Build example Telink All Clusters Minimal App
6367
run: |
6468
./scripts/run_in_build_env.sh \
65-
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-light-switch' build"
69+
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-all-clusters-minimal' build"
70+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
71+
telink tlsr9518adk80d all-clusters-minimal-app \
72+
out/telink-tlsr9518adk80d-all-clusters-minimal/zephyr/zephyr.elf \
73+
/tmp/bloat_reports/
6674
67-
- name: Build example Telink OTA Requestor App
75+
- name: Build example Telink Lighting App
6876
run: |
6977
./scripts/run_in_build_env.sh \
70-
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-ota-requestor' build"
71-
72-
- name: Get Lighting size stats
73-
run: |
78+
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-light' build"
7479
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
7580
telink tlsr9518adk80d lighting-app \
7681
out/telink-tlsr9518adk80d-light/zephyr/zephyr.elf \
7782
/tmp/bloat_reports/
7883
79-
- name: Get Light Switch size stats
84+
- name: Build example Telink Light Switch App
8085
run: |
86+
./scripts/run_in_build_env.sh \
87+
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-light-switch' build"
8188
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
8289
telink tlsr9518adk80d light-switch-app \
8390
out/telink-tlsr9518adk80d-light-switch/zephyr/zephyr.elf \
8491
/tmp/bloat_reports/
8592
86-
- name: Get OTA Requestor size stats
93+
- name: Build example Telink OTA Requestor App
8794
run: |
95+
./scripts/run_in_build_env.sh \
96+
"./scripts/build/build_examples.py --no-log-timestamps --target 'telink-tlsr9518adk80d-ota-requestor' build"
8897
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
8998
telink tlsr9518adk80d ota-requestor-app \
9099
out/telink-tlsr9518adk80d-ota-requestor/zephyr/zephyr.elf \

.vscode/tasks.json

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@
429429
"nrf-nrf5340-pump-controller",
430430
"nrf-nrf5340-shell",
431431
"qpg-qpg6100-lock",
432+
"telink-tlsr9518adk80d-all-clusters",
433+
"telink-tlsr9518adk80d-all-clusters-minimal",
432434
"telink-tlsr9518adk80d-light",
433435
"telink-tlsr9518adk80d-light-switch",
434436
"telink-tlsr9518adk80d-ota-requestor",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Copyright (c) 2022 Project CHIP Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
cmake_minimum_required(VERSION 3.13.1)
17+
18+
set(BOARD tlsr9518adk80d)
19+
20+
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
21+
get_filename_component(NLIO_ROOT ${CHIP_ROOT}/third_party/nlio/repo/include REALPATH)
22+
get_filename_component(TELINK_COMMON ${CHIP_ROOT}/examples/platform/telink REALPATH)
23+
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
24+
get_filename_component(ALL_CLUSTERS_COMMON_DIR ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common REALPATH)
25+
26+
set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf)
27+
28+
# Load NCS/Zephyr build system
29+
list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module)
30+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
31+
32+
project(chip-telink-all-clusters-app-example)
33+
34+
include(${CHIP_ROOT}/config/telink/app/enable-gnu-std.cmake)
35+
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)
36+
37+
target_compile_options(app PRIVATE -fpermissive)
38+
39+
target_include_directories(app PRIVATE
40+
include
41+
${ALL_CLUSTERS_COMMON_DIR}/include
42+
${GEN_DIR}/app-common
43+
${GEN_DIR}/all-clusters-app
44+
${NLIO_ROOT}
45+
${TELINK_COMMON}/util/include)
46+
47+
add_definitions(
48+
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
49+
)
50+
51+
target_sources(app PRIVATE
52+
src/AppTask.cpp
53+
src/main.cpp
54+
src/ZclDoorLockCallbacks.cpp
55+
${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp
56+
${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp
57+
${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp
58+
${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp
59+
${GEN_DIR}/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp
60+
${TELINK_COMMON}/util/src/LEDWidget.cpp
61+
${TELINK_COMMON}/util/src/ButtonManager.cpp
62+
${TELINK_COMMON}/util/src/ThreadUtil.cpp)
63+
64+
chip_configure_data_model(app
65+
INCLUDE_SERVER
66+
ZAP_FILE ${ALL_CLUSTERS_COMMON_DIR}/all-clusters-app.zap
67+
)
68+
69+
if(CONFIG_CHIP_OTA_REQUESTOR)
70+
target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp)
71+
endif()
+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Matter Telink All Clusters Example Application
2+
3+
The Telink All Clusters Example Application implements various ZCL clusters
4+
populated on three endpoints. You can use this example as a reference for
5+
creating your own application.
6+
7+
![Telink B91 EVK](http://wiki.telink-semi.cn/wiki/assets/Hardware/B91_Generic_Starter_Kit_Hardware_Guide/connection_chart.png)
8+
9+
## Build and flash
10+
11+
1. Pull docker image from repository:
12+
13+
```bash
14+
$ docker pull connectedhomeip/chip-build-telink:latest
15+
```
16+
17+
1. Run docker container:
18+
19+
```bash
20+
$ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" connectedhomeip/chip-build-telink:latest
21+
```
22+
23+
here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay
24+
attention that OUTPUT_DIR should contains ABSOLUTE path to output dir**
25+
26+
1. Activate the build environment:
27+
28+
```bash
29+
$ source ./scripts/activate.sh
30+
```
31+
32+
1. In the example dir run:
33+
34+
```bash
35+
$ west build
36+
```
37+
38+
1. Flash binary:
39+
40+
```
41+
$ west flash --erase
42+
```
43+
44+
## Usage
45+
46+
### UART
47+
48+
To get output from device, connect UART to following pins:
49+
50+
| Name | Pin |
51+
| :--: | :---------------------------- |
52+
| RX | PB3 (pin 17 of J34 connector) |
53+
| TX | PB2 (pin 16 of J34 connector) |
54+
| GND | GND |
55+
56+
### Buttons
57+
58+
The following buttons are available on **tlsr9518adk80d** board:
59+
60+
| Name | Function | Description |
61+
| :------- | :--------------------- | :----------------------------------------------------------------------------------------------------- |
62+
| Button 1 | Factory reset | Perform factory reset to forget currently commissioned Thread network and back to uncommissioned state |
63+
| Button 2 | Not used | Not used |
64+
| Button 3 | Thread start | Commission thread with static credentials and enables the Thread on device |
65+
| Button 4 | Open commission window | The button is opening commissioning window to perform commissioning over BLE |
66+
67+
### LEDs
68+
69+
**Red** LED indicates current state of Thread network. It ables to be in
70+
following states:
71+
72+
| State | Description |
73+
| :-------------------------- | :--------------------------------------------------------------------------- |
74+
| Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled |
75+
| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network |
76+
| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD |
77+
78+
### CHIP tool commands
79+
80+
1. Build
81+
[chip-tool cli](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md)
82+
83+
2. Pair with device
84+
85+
```
86+
${CHIP_TOOL_DIR}/chip-tool pairing ble-thread ${NODE_ID} hex:${DATASET} ${PIN_CODE} ${DISCRIMINATOR}
87+
```
88+
89+
Example:
90+
91+
```
92+
./chip-tool pairing ble-thread 1234 hex:0e080000000000010000000300000f35060004001fffe0020811111111222222220708fd61f77bd3df233e051000112233445566778899aabbccddeeff030e4f70656e54687265616444656d6f010212340410445f2b5ca6f2a93a55ce570a70efeecb0c0402a0fff8 20202021 3840
93+
```
94+
95+
### OTA with Linux OTA Provider
96+
97+
OTA feature enabled by default only for ota-requestor-app example. To enable OTA
98+
feature for another Telink example:
99+
100+
- set CONFIG_CHIP_OTA_REQUESTOR=y in corresponding "prj.conf" configuration
101+
file.
102+
103+
After build application with enabled OTA feature, use next binary files:
104+
105+
- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
106+
- zephyr-ota.bin - binary for OTA Provider
107+
108+
All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
109+
higher SW version than base SW. Set CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2 in
110+
corresponding “prj.conf” configuration file.
111+
112+
Usage of OTA:
113+
114+
- Build the [Linux OTA Provider](../../ota-provider-app/linux)
115+
116+
```
117+
./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false
118+
```
119+
120+
- Run the Linux OTA Provider with OTA image.
121+
122+
```
123+
./chip-ota-provider-app -f zephyr-ota.bin
124+
```
125+
126+
- Provision the Linux OTA Provider using chip-tool
127+
128+
```
129+
./chip-tool pairing onnetwork ${OTA_PROVIDER_NODE_ID} 20202021
130+
```
131+
132+
here:
133+
134+
- \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider
135+
136+
- Configure the ACL of the ota-provider-app to allow access
137+
138+
```
139+
./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' ${OTA_PROVIDER_NODE_ID} 0
140+
```
141+
142+
here:
143+
144+
- \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider
145+
146+
- Use the chip-tool to announce the ota-provider-app to start the OTA process
147+
148+
```
149+
./chip-tool otasoftwareupdaterequestor announce-ota-provider ${OTA_PROVIDER_NODE_ID} 0 0 0 ${DEVICE_NODE_ID} 0
150+
```
151+
152+
here:
153+
154+
- \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider
155+
- \${DEVICE_NODE_ID} is the node id of paired device
156+
157+
Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to
158+
OTA provider for applying the image. Device will restart on successful
159+
application of OTA image.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
*
3+
* Copyright (c) 2022 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
// ---- All Clusters Application example config ----
22+
23+
// Buttons config
24+
#define BUTTON_PORT DEVICE_DT_GET(DT_NODELABEL(gpioc))
25+
26+
#define BUTTON_PIN_1 2
27+
#define BUTTON_PIN_3 3
28+
#define BUTTON_PIN_4 1
29+
#define BUTTON_PIN_2 0
30+
31+
// LEDs config
32+
// System led config
33+
#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob))
34+
#define SYSTEM_STATE_LED_PIN 7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
*
3+
* Copyright (c) 2022 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <cstdint>
22+
23+
struct AppEvent;
24+
typedef void (*EventHandler)(AppEvent *);
25+
26+
struct AppEvent
27+
{
28+
enum AppEventTypes
29+
{
30+
kEventType_Button = 0,
31+
};
32+
33+
uint16_t Type;
34+
35+
union
36+
{
37+
struct
38+
{
39+
uint8_t Action;
40+
} ButtonEvent;
41+
};
42+
43+
EventHandler Handler;
44+
};

0 commit comments

Comments
 (0)