Skip to content

Commit e1c575f

Browse files
paklsrestyled-commitsmtk23169Eason-Mtk
authored andcommitted
[genio] supports more examples and bug fixes. (project-chip#23396)
* [genio] supports more examples and bug fixes. * add support of ota example * add support of thermostat example * add support of lock example * add support of light switch example * add support of color in lighting example * fix factory reset button * fix ipv4 and ipv6 event logic * [genio] skip platform folder check * [genio] SDK submodule update * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * [genio] lock-app example readme corrections * [genio] remove *.bak * [Genio] Update README.md * [Genio] fix title name in README.md * [Genio] fix mispelling in README.md * [genio] sync LED control logic from lighting-app * [genio] fix lock-app feature map and set the supported number of credentials and users * Restyled by clang-format * Restyled by prettier-markdown * [genio] replace 'CHIP' with 'Matter' Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: mtk23169 <Peng-ren.Lai@mediatek.com> Co-authored-by: Eason Lai <Eason.Lai@mediatek.com>
1 parent 243109a commit e1c575f

File tree

115 files changed

+11916
-195
lines changed

Some content is hidden

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

115 files changed

+11916
-195
lines changed

examples/light-switch-app/genio/.gn

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "arm"
25+
target_os = "freertos"
26+
import("//args.gni")
27+
}
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Copyright (c) 2022 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
import("//build_overrides/mt793x_sdk.gni")
18+
import("//build_overrides/pigweed.gni")
19+
20+
import("${build_root}/config/defaults.gni")
21+
import("${mt793x_sdk_build_root}/mt793x_executable.gni")
22+
import("${mt793x_sdk_build_root}/mt793x_sdk.gni")
23+
24+
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
25+
import("${chip_root}/src/platform/device.gni")
26+
27+
if (chip_enable_pw_rpc) {
28+
import("//build_overrides/pigweed.gni")
29+
import("$dir_pw_build/target_types.gni")
30+
}
31+
32+
assert(current_os == "freertos")
33+
34+
mt793x_project_dir = "${chip_root}/examples/light-switch-app/genio"
35+
mt793x_examples_plat_dir = "${chip_root}/examples/platform/mt793x"
36+
37+
declare_args() {
38+
# Dump memory usage at link time.
39+
chip_print_memory_usage = true
40+
41+
# PIN code for PASE session establishment.
42+
setupPinCode = 20202021
43+
setupDiscriminator = 3840
44+
}
45+
46+
mt793x_sdk("sdk") {
47+
sources = [
48+
"${mt793x_project_dir}/include/CHIPProjectConfig.h",
49+
"${mt793x_project_dir}/include/FreeRTOSConfig.h",
50+
]
51+
52+
include_dirs = [
53+
"${chip_root}/src/platform/mt793x",
54+
"${mt793x_project_dir}/include",
55+
"${mt793x_examples_plat_dir}",
56+
"${chip_root}/src/lib",
57+
]
58+
59+
defines = [ "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE" ]
60+
61+
defines += [
62+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
63+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
64+
]
65+
}
66+
67+
mt793x_executable("light_switch_app") {
68+
output_name = "chip-mt793x-light-switch-app-example.out"
69+
include_dirs = [ "include" ]
70+
defines = []
71+
72+
sources = [
73+
"src/AppTask.cpp",
74+
"src/BindingHandler.cpp",
75+
"src/LEDWidget.cpp",
76+
"src/ZclCallbacks.cpp",
77+
"src/main.cpp",
78+
]
79+
80+
deps = [
81+
":sdk",
82+
"${chip_root}/examples/common/QRCode",
83+
"${chip_root}/examples/light-switch-app/light-switch-common",
84+
"${chip_root}/examples/providers:device_info_provider",
85+
"${chip_root}/src/lib",
86+
"${chip_root}/src/setup_payload",
87+
"${mt793x_examples_plat_dir}:genio-matter-shell",
88+
]
89+
90+
if (chip_enable_ota_requestor) {
91+
defines += [ "MT793X_OTA_ENABLED" ]
92+
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
93+
}
94+
95+
ldscript = "mt793x_xip.ld"
96+
97+
inputs = [ ldscript ]
98+
99+
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
100+
101+
if (chip_print_memory_usage) {
102+
ldflags += [
103+
"-Wl,--print-memory-usage",
104+
"-fstack-usage",
105+
]
106+
}
107+
108+
output_dir = root_out_dir
109+
}
110+
111+
group("mt793x") {
112+
deps = [ ":light_switch_app" ]
113+
}
114+
115+
group("default") {
116+
deps = [ ":mt793x" ]
117+
}
+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#Matter `Genio` Light Switch Example
2+
3+
An example showing the use of Matter on the MediaTek `Genio` MT793X.
4+
5+
<hr>
6+
7+
- [Matter Genio Light Switch Example](#chip-genio-light-switch-example)
8+
- [Introduction](#introduction)
9+
- [Building](#building)
10+
- [Note](#note)
11+
- [Flashing the Application](#flashing-the-application)
12+
- [Viewing Logging Output](#viewing-logging-output)
13+
- [Running the Complete Example](#running-the-complete-example)
14+
- [Notes](#notes)
15+
16+
<hr>
17+
18+
<a name="intro"></a>
19+
20+
## Introduction
21+
22+
The `Genio` (MT793X) light switch example provides a baseline demonstration of a
23+
on-off light switch device, built using Matter and the MediaTek `Genio` SDK. It
24+
can be controlled by a Chip controller over Wi-Fi network..
25+
26+
The `Genio` device can be commissioned over Bluetooth Low Energy where the
27+
device and the Chip controller will exchange security information with the
28+
Rendez-vous procedure. Network credentials are then provided to the `Genio`
29+
device which will then join the network.
30+
31+
The light switch example is intended to serve both as a means to explore the
32+
workings of Matter as well as a template for creating real products based on the
33+
MediaTek platform.
34+
35+
<a name="building"></a>
36+
37+
## Building
38+
39+
- Following the Linux related descriptions in
40+
[Build Matter](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md)
41+
to prepare the build environment.
42+
43+
- Supported hardware:
44+
45+
`Genio` 130A (MT7931) board:
46+
47+
- `EK-AI7931LD KIT`
48+
49+
* Build the example application:
50+
51+
`cd ~/connectedhomeip`
52+
`./scripts/examples/gn_genio_example.sh ./examples/light-switch-app/genio` `./out/light-switch-app`
53+
54+
- To delete generated executable, libraries and object files use:
55+
56+
`$ cd ~/connectedhomeip`
57+
`$ rm -rf ./out/`
58+
59+
OR use GN/Ninja directly
60+
61+
`$ cd ~/connectedhomeip/examples/light-switch-app/genio`
62+
`$ git submodule update --init`
63+
`$ source third_party/connectedhomeip/scripts/activate.sh`
64+
`$ gn gen out/debug`
65+
`$ ninja -C out/debug`
66+
67+
- To delete generated executable, libraries and object files use:
68+
69+
`$ cd ~/connectedhomeip/examples/light-switch-app/genio`
70+
`$ rm -rf out/`
71+
72+
## Flashing the Application
73+
74+
- Copy the GUI based
75+
[Flash Tool](https://github.com/MediaTek-Labs/genio-matter-bsp/tree/main/flash_tool/FlashBurningTool_V2.83).
76+
from the Linux Host that the example was build to a Windows PC.
77+
78+
Flash Tool can be found in this source tree under this directory
79+
80+
`third_party/mt793x_sdk/filogic/flash_tool`
81+
82+
- On the Windows PC, run the Flash Tool
83+
84+
1. Select the scatter.ini file in the `./out/light-switch-app` directory.
85+
2. Follow the instruction that comes with `EK-AI7931LD KIT` to switch the
86+
kit to download mode.
87+
3. Click `Download` on FLASH TOOL.
88+
89+
## Running the Complete Example
90+
91+
- This example needs one lighting-app device and one light-switch-app device.
92+
93+
- You can provision and control the Chip device using the python controller,
94+
Chip tool standalone, Android or iOS app
95+
96+
[CHIP
97+
Tool]](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/chip_tool_guide.md)
98+
99+
- First of all, you have to commission with the light-switch-app (nodeID 1)
100+
and the lighting-app (nodeID 2) with the CHIP tool by following commands.
101+
102+
```
103+
chip-tool pairing ble-wifi 1 my-ap myappassword 20202021 3840
104+
105+
chip-tool pairing ble-wifi 2 my-ap myappassword 20202021 3840
106+
```
107+
108+
- Next, you have to configure the ACL in the lighting-app device to allow
109+
access from switch device and chip-tool, and binding the lighting-app device
110+
to the light-switch-app device by following commands.
111+
112+
```
113+
chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null },{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [1], "targets": null }]' 2 0
114+
115+
chip-tool binding write binding '[{"fabricIndex": 1, "node":2, "endpoint":1, "cluster":6}]' 1 1
116+
117+
```
118+
119+
- Once all setup successfully, you can control the lighting-app device through
120+
the Matter Shell on the light-switch-app device.
121+
122+
```
123+
> switch onoff on
124+
> switch onoff off
125+
```
126+
127+
### Notes
128+
129+
- Depending on your network settings your router might not provide native ipv6
130+
addresses to your devices (Border router / PC). If this is the case, you
131+
need to add a static ipv6 addresses on both device and then an ipv6 route to
132+
the border router on your PC
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2022 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("//build_overrides/pigweed.gni")
17+
import("${chip_root}/src/platform/mt793x/args.gni")
18+
19+
mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
20+
21+
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
22+
pw_assert_BACKEND = "$dir_pw_assert_log"
23+
24+
chip_enable_ble = true
25+
26+
declare_args() {
27+
chip_enable_ota_requestor = false
28+
29+
# Disable lock tracking, since our FreeRTOS configuration does not set
30+
# INCLUDE_xSemaphoreGetMutexHolder
31+
chip_stack_lock_tracking = "none"
32+
33+
chip_config_network_layer_ble = true
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import("//build_overrides/chip.gni")
15+
import("//build_overrides/pigweed.gni")
16+
17+
mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain")
18+
chip_enable_openthread = false
19+
import("${chip_root}/src/platform/MT793X/wifi_args.gni")
20+
21+
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip"
22+
pw_assert_BACKEND = "$dir_pw_assert_log"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2020 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
target_cpu = "arm"
25+
target_os = "freertos"
26+
use_thread = false
27+
import("//build_for_wifi_args.gni")
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build_overrides

0 commit comments

Comments
 (0)