Skip to content

Commit 631893c

Browse files
Martin-NXPrestyled-commits
authored andcommitted
[NXP] Add TBRM and wifi connect support (project-chip#35646)
* [NXP] Update ot-nxp submodule Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][third_party] Enable lwip and ephemeral key CLI addons Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][examples] Add support for TBR management cluster and secondary nwk, Updated common app to work with SNI and TBRM Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][src] Add support for TBR management cluster and secondary nwk, Updated common app to work with SNI and TBRM Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][workflows] Only thermostat app support OTBR feature Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][doc] add OTBR guide Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP][platform][rw61x] Add support of boot reason Signed-off-by: Martin Girardot <martin.girardot@nxp.com> (cherry picked from commit d8f44419ea89d5ecec73fe8d82fdb30d444f49b3) * [NXP] Adding wifi_connect module Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP] setup_discriminator argument value was only applied when OTA requestor enabled (cherry picked from commit fa9de443e3129ecf7befb4404fb2dd0efc213a29) * Restyled by gn * Restyled by prettier-markdown * [NXP] Regenerate .zap and .matter file for BR Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP] Fix spelling issue Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * Restyled by prettier-markdown * [NXP] Fix spelling issue Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * [NXP] Fix otbr build issue Signed-off-by: Martin Girardot <martin.girardot@nxp.com> * Restyled by gn * [NXP] Disable identify cluster on endpoint 0 Signed-off-by: Martin Girardot <martin.girardot@nxp.com> --------- Signed-off-by: Martin Girardot <martin.girardot@nxp.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 3a199d5 commit 631893c

File tree

25 files changed

+9604
-1010
lines changed

25 files changed

+9604
-1010
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1630,3 +1630,4 @@ Zigbee
16301630
zigbeealliance
16311631
zigbeethread
16321632
zsdk
1633+
TBR

.github/workflows/examples-nxp.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ jobs:
242242
./scripts/build/build_examples.py \
243243
--target nxp-rw61x-freertos-all-clusters-wifi \
244244
--target nxp-rw61x-freertos-all-clusters-thread \
245-
--target nxp-rw61x-freertos-all-clusters-thread-wifi \
246245
--target nxp-rw61x-freertos-all-clusters-wifi-ota-cmake \
247246
build \
248247
--copy-artifacts-to out/artifacts \
@@ -265,7 +264,6 @@ jobs:
265264
./scripts/build/build_examples.py \
266265
--target nxp-rw61x-freertos-laundry-washer-wifi \
267266
--target nxp-rw61x-freertos-laundry-washer-thread \
268-
--target nxp-rw61x-freertos-laundry-washer-thread-wifi \
269267
build \
270268
--copy-artifacts-to out/artifacts \
271269
"

docs/guides/nxp/nxp_otbr_guide.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Thread Border Router usage
2+
3+
This document describes the use of the Thread Border router and secondary
4+
network interface for a Matter application
5+
6+
<hr>
7+
8+
- [Thread Border Router usage](#thread-border-router-usage)
9+
- [Thread Border Router overview](#thread-border-router-overview)
10+
- [Using the Thread Border Router management cluster](#using-the-thread-border-router-management-cluster)
11+
- [Using the Secondary Network commissioning interface](#using-the-secondary-network-commissioning-interface)
12+
- [Using the Thread credential sharing mechanism](#using-the-thread-credential-sharing-mechanism)
13+
14+
<hr>
15+
16+
<a name="thread-border-router-overview"></a>
17+
18+
## Thread Border Router overview
19+
20+
This section contains an overview of the Border Router architecture and
21+
describes the general use cases.
22+
23+
<a name="using-the-thread-border-router-management-cluster"></a>
24+
25+
## Using the Thread Border Router management cluster
26+
27+
The Thread Border Router management cluster allows provisioning of the Thread
28+
interface using a Matter commissioner.
29+
30+
After the device has been provisioned over WIFI the set active dataset command
31+
can be used to configure the Thread active dataset on the border router. Once
32+
the dataset is set successfully the Thread network interface will be enabled and
33+
the device will create a new PAN or join an existing one if already present.
34+
Note that this command cannot be used on a device that already has an active
35+
dataset configured. In this situation the set pending dataset command must be
36+
used instead.
37+
38+
Before using the set active dataset command a fail-safe timer must be armed
39+
(recommend using a timeout of 120 seconds):
40+
41+
```
42+
ubuntu@ubuntu:~$ ./chip-tool generalcommissioning arm-fail-safe timeout-seconds 1 node-id 0
43+
```
44+
45+
Then an active dataset in HEX TLV format (the same type used to provision a
46+
Matter over Thread device using the `ble-thread` command) can be used to
47+
provision the Border Router. What the active dataset should be is outside the
48+
scope of this README but as an example one can be obtained from the OpenThread
49+
cli on an already provisioned device using the `dataset active -x` command.
50+
51+
Note that the Thread Border Router management cluster has been set to endpoint 2
52+
in the zap file.
53+
54+
```
55+
ubuntu@ubuntu:~$ ./chip-tool threadborderroutermanagement set-active-dataset-request hex:<active-dataset> node id 2
56+
```
57+
58+
If the active dataset command is successful, a commissioning complete command
59+
must be send to disarm the fail-safe timer and commit the configuration to
60+
non-volatile storage.
61+
62+
```
63+
ubuntu@ubuntu:~$ ./chip-tool-19-jul generalcommissioning commissioning-complete node-id 0
64+
```
65+
66+
Note that this command cannot be used on a device that already has an active
67+
dataset configured. In this situation the set pending dataset command must be
68+
used instead.
69+
70+
```
71+
ubuntu@ubuntu:~$ ./chip-tool threadborderroutermanagement set-pending-dataset-request hex:<active-dataset> node id 2
72+
```
73+
74+
To read the active dataset of an already provisioned device, for example to make
75+
a joining Border Router use the same Thread network as an already configured
76+
one, the get active dataset command can be used:
77+
78+
```
79+
ubuntu@ubuntu:~$ ./chip-tool-19-jul threadborderroutermanagement get-active-dataset-request node-id 2
80+
```
81+
82+
<a name="using-the-secondary-network-commissioning-interface"></a>
83+
84+
## Using the Secondary Network commissioning interface
85+
86+
To use the secondary network commissioning interface over Thread the device must
87+
not be provisioned over WIFI. The regular `ble-thread` pairing is used as for
88+
any other Matter over Thread device. The chip-tool will read all the endpoints
89+
of the device and discover Thread network commissioning cluster on endpoint 3
90+
and use that to provision the device. As for any other Matter over Thread device
91+
a Thread Border Router is required in this case.
92+
93+
```
94+
ubuntu@ubuntu:~$ ./chip-tool pairing ble-thread node-id hex:<active-dataset> 20202021 3840
95+
```
96+
97+
<a name="using-the-thread-credential-sharing-mechanism"></a>
98+
99+
## Using the Thread credential sharing mechanism
100+
101+
The details about using the credential sharing mechanism are in the ot-nxp repo
102+
border router application
103+
[readme](https://github.com/NXP/ot-nxp/blob/v1.4.0-pvw1/examples/br/README-OTBR.md).
104+
See `Ephemeral Key functionality` section.
105+
106+
Note that all OpenThread commands executed from then Matter CLI must have
107+
`otcli` added before the command.

examples/all-clusters-app/nxp/rt/rw61x/BUILD.gn

+12-42
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ assert(target_os == "freertos")
3535
assert(nxp_platform == "rt/rw61x")
3636

3737
declare_args() {
38-
# Allows to start the tcp download test app
39-
tcp_download = false
40-
41-
# Allows to start the wifi connect test app
42-
wifi_connect = false
43-
44-
# The 2 params below are used only if tcp_download or wifi_connect are true, otherwise they're unused.
45-
wifi_ssid = ""
46-
wifi_password = ""
38+
# Allows to connect to a predefine Wi-Fi network at boot
39+
wifi_auto_connect_at_boot = false
40+
wifi_auto_connect_at_boot_ssid = ""
41+
wifi_auto_connect_at_boot_password = ""
4742

4843
# Setup discriminator as argument
4944
setup_discriminator = 3840
@@ -53,10 +48,6 @@ example_platform_dir =
5348
"${nxp_sdk_matter_support_root}/examples/platform/${nxp_platform}"
5449
common_example_dir = "${chip_root}/examples/platform/nxp/common"
5550

56-
if (tcp_download == true && wifi_connect == true) {
57-
assert("Cannot enable tcp_download and wifi_connect at the same time!")
58-
}
59-
6051
app_common_folder = "all-clusters-app/all-clusters-common"
6152

6253
# Create here the SDK instance.
@@ -213,42 +204,21 @@ rt_executable("all_cluster_app") {
213204
]
214205
}
215206

216-
if (wifi_connect) {
207+
if (wifi_auto_connect_at_boot) {
208+
assert(wifi_auto_connect_at_boot_ssid != "" &&
209+
wifi_auto_connect_at_boot_password != "",
210+
"WiFi SSID and password must be specified at build time!")
211+
217212
defines += [
218-
"WIFI_CONNECT_TASK=1",
219-
"WIFI_CONNECT=1",
213+
"CONFIG_CHIP_APP_WIFI_CONNECT_AT_BOOT=1",
214+
"CONFIG_CHIP_APP_WIFI_SSID=\"${wifi_auto_connect_at_boot_ssid}\"",
215+
"CONFIG_CHIP_APP_WIFI_PASSWORD=\"${wifi_auto_connect_at_boot_password}\"",
220216
]
221217

222-
if (!chip_enable_matter_cli) {
223-
assert(wifi_ssid != "" && wifi_password != "",
224-
"WiFi SSID and password must be specified at build time!")
225-
}
226-
227-
if (wifi_ssid != "") {
228-
defines += [ "WIFI_SSID=\"${wifi_ssid}\"" ]
229-
}
230-
231-
if (wifi_password != "") {
232-
defines += [ "WIFI_PASSWORD=\"${wifi_password}\"" ]
233-
}
234-
235218
include_dirs += [ "${common_example_dir}/wifi_connect/include" ]
236219
sources += [ "${common_example_dir}/wifi_connect/source/WifiConnect.cpp" ]
237220
}
238221

239-
if (tcp_download) {
240-
defines += [ "CONFIG_CHIP_TCP_DOWNLOAD=1" ]
241-
defines += [
242-
"WIFI_CONNECT=1",
243-
"WIFI_SSID=\"${wifi_ssid}\"",
244-
"WIFI_PASSWORD=\"${wifi_password}\"",
245-
]
246-
247-
include_dirs += [ "${common_example_dir}/tcp_download_test/include" ]
248-
sources +=
249-
[ "${common_example_dir}/tcp_download_test/source/TcpDownload.cpp" ]
250-
}
251-
252222
# In case a dedicated assert function needs to be supported the flag sdk_fsl_assert_support should be set to false
253223
# The would add to the build a dedicated application assert implementation.
254224
if (!sdk_fsl_assert_support) {

examples/all-clusters-app/nxp/rt/rw61x/README.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ commissioning and different cluster control.
1616
- [Testing the example](#testing-the-example)
1717
- [Matter Shell](#testing-the-all-clusters-application-with-matter-cli-enabled)
1818
- [OTA Software Update](#ota-software-update)
19+
- [Thread Border Router overview](#thread-border-router-overview)
1920

2021
<hr>
2122

@@ -124,8 +125,13 @@ user@ubuntu:~/Desktop/git/connectedhomeip/examples/all-clusters-app/nxp/rt/rw61x
124125

125126
#### Building with Matter over Wifi + OpenThread Border Router configuration on RW612
126127

127-
This configuration requires enabling the Matter CLI in order to control the
128-
Thread network on the Border Router.
128+
This configuration supports the Thread Border Router management cluster to
129+
provision the Thread credentials. Enabling the Matter CLI in order to control
130+
the Thread network on the Border Router is optional but recommended for other
131+
features like the Thread credential sharing.
132+
133+
Note that the Thread Border Router management cluster is only supported on the
134+
thermostat application for now.
129135

130136
- Build Matter with Border Router configuration with BLE commissioning
131137
(ble-wifi) :
@@ -142,6 +148,13 @@ out/debug/chip-rw61x-all-cluster-example.
142148

143149
Optional GN options that can be added when building an application:
144150

151+
- To enable the
152+
[secondary network commissioning interface](../../../../../docs/guides/nxp/nxp_otbr_guide.md#using-the-secondary-network-commissioning-interface),
153+
the arguments `chip_enable_secondary_nwk_if=true` and
154+
`chip_device_config_thread_network_endpoint_id=2` must be added to the _gn
155+
gen_ command. Note that this is only supported when building the Matter over
156+
Wifi + OpenThread Border Router configuration. Note that is only supported
157+
on the on the thermostat application for now.
145158
- To enable the
146159
[matter CLI](README.md#testing-the-all-clusters-application-with-matter-cli-enabled),
147160
the argument `chip_enable_matter_cli=true` must be added to the _gn gen_
@@ -265,9 +278,11 @@ The "ble-thread" pairing method can be used in order to commission the device.
265278

266279
#### Matter over wifi with openthread border router configuration :
267280

268-
In order to create or join a Thread network on the Matter Border Router, the
269-
`otcli` commands from the matter CLI can be used. For more information about
270-
using the matter shell, follow instructions from
281+
In order to create or join a Thread network on the Matter Border Router, the TBR
282+
management cluster or the `otcli` commands from the matter CLI can be used. For
283+
more information about using the TBR management cluster follow instructions from
284+
['Using the TBR management cluster'](../../../../../docs/guides/nxp/nxp_otbr_guide.md#using-the-thread-border-router-management-cluster).
285+
For more information about using the matter shell, follow instructions from
271286
['Testing the all-clusters application with Matter CLI'](#testing-the-all-clusters-application-with-matter-cli-enabled).
272287

273288
In this configuration, the device can be commissioned over Wi-Fi with the
@@ -393,3 +408,13 @@ Over-The-Air software updates are supported with the RW61x all-clusters example.
393408
The process to follow in order to perform a software update is described in the
394409
dedicated guide
395410
['Matter Over-The-Air Software Update with NXP RW61x example applications'](../../../../../docs/guides/nxp/nxp_rw61x_ota_software_update.md).
411+
412+
<a name="thread-border-router-overview"></a>
413+
414+
## Thread Border Router overview
415+
416+
To enable Thread Border Router support see the [build](README.md#building)
417+
section.
418+
419+
The complete Border Router guide is located
420+
[here](../../../../../docs/guides/nxp/nxp_otbr_guide.md).

examples/laundry-washer-app/nxp/rt/rw61x/BUILD.gn

+12-42
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ assert(target_os == "freertos")
3535
assert(nxp_platform == "rt/rw61x")
3636

3737
declare_args() {
38-
# Allows to start the tcp download test app
39-
tcp_download = false
40-
41-
# Allows to start the wifi connect test app
42-
wifi_connect = false
43-
44-
# The 2 params below are used only if tcp_download or wifi_connect are true, otherwise they're unused.
45-
wifi_ssid = ""
46-
wifi_password = ""
38+
# Allows to connect to a predefine Wi-Fi network at boot
39+
wifi_auto_connect_at_boot = false
40+
wifi_auto_connect_at_boot_ssid = ""
41+
wifi_auto_connect_at_boot_password = ""
4742

4843
# Setup discriminator as argument
4944
setup_discriminator = 3840
@@ -53,10 +48,6 @@ example_platform_dir =
5348
"${nxp_sdk_matter_support_root}/examples/platform/${nxp_platform}"
5449
common_example_dir = "${chip_root}/examples/platform/nxp/common"
5550

56-
if (tcp_download == true && wifi_connect == true) {
57-
assert("Cannot enable tcp_download and wifi_connect at the same time!")
58-
}
59-
6051
# Use NXP custom zap files for laundry-washer device-type
6152
app_common_folder = "laundry-washer-app/nxp/zap"
6253

@@ -218,42 +209,21 @@ rt_executable("laundry-washer") {
218209
]
219210
}
220211

221-
if (wifi_connect) {
212+
if (wifi_auto_connect_at_boot) {
213+
assert(wifi_auto_connect_at_boot_ssid != "" &&
214+
wifi_auto_connect_at_boot_password != "",
215+
"WiFi SSID and password must be specified at build time!")
216+
222217
defines += [
223-
"WIFI_CONNECT_TASK=1",
224-
"WIFI_CONNECT=1",
218+
"CONFIG_CHIP_APP_WIFI_CONNECT_AT_BOOT=1",
219+
"CONFIG_CHIP_APP_WIFI_SSID=\"${wifi_auto_connect_at_boot_ssid}\"",
220+
"CONFIG_CHIP_APP_WIFI_PASSWORD=\"${wifi_auto_connect_at_boot_password}\"",
225221
]
226222

227-
if (!chip_enable_matter_cli) {
228-
assert(wifi_ssid != "" && wifi_password != "",
229-
"WiFi SSID and password must be specified at build time!")
230-
}
231-
232-
if (wifi_ssid != "") {
233-
defines += [ "WIFI_SSID=\"${wifi_ssid}\"" ]
234-
}
235-
236-
if (wifi_password != "") {
237-
defines += [ "WIFI_PASSWORD=\"${wifi_password}\"" ]
238-
}
239-
240223
include_dirs += [ "${common_example_dir}/wifi_connect/include" ]
241224
sources += [ "${common_example_dir}/wifi_connect/source/WifiConnect.cpp" ]
242225
}
243226

244-
if (tcp_download) {
245-
defines += [ "CONFIG_CHIP_TCP_DOWNLOAD=1" ]
246-
defines += [
247-
"WIFI_CONNECT=1",
248-
"WIFI_SSID=\"${wifi_ssid}\"",
249-
"WIFI_PASSWORD=\"${wifi_password}\"",
250-
]
251-
252-
include_dirs += [ "${common_example_dir}/tcp_download_test/include" ]
253-
sources +=
254-
[ "${common_example_dir}/tcp_download_test/source/TcpDownload.cpp" ]
255-
}
256-
257227
# In case a dedicated assert function needs to be supported the flag sdk_fsl_assert_support should be set to false
258228
# The would add to the build a dedicated application assert implementation.
259229
if (!sdk_fsl_assert_support) {

examples/platform/nxp/common/app_task/include/AppTaskBase.h

+11
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ class AppTaskBase
169169
*/
170170
static void InitServer(intptr_t arg);
171171

172+
#if CHIP_DEVICE_CONFIG_ENABLE_TBR
173+
/**
174+
* \brief Initialize the Thread Border Router management cluster.
175+
*
176+
* Called when the border router function is up and running. This cluster stays disabled
177+
* when the application is used as a Matter over Thread device.
178+
*
179+
*/
180+
void EnableTbrManagementCluster();
181+
#endif
182+
172183
/**
173184
* Commissioning handlers
174185
* Generic implementation is provided within this class

0 commit comments

Comments
 (0)