-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[genio] supports more examples and bug fixes. (#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 <[email protected]> Co-authored-by: mtk23169 <[email protected]> Co-authored-by: Eason Lai <[email protected]>
- Loading branch information
Showing
115 changed files
with
11,916 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
|
||
# The location of the build configuration file. | ||
buildconfig = "${build_root}/config/BUILDCONFIG.gn" | ||
|
||
# CHIP uses angle bracket includes. | ||
check_system_includes = true | ||
|
||
default_args = { | ||
target_cpu = "arm" | ||
target_os = "freertos" | ||
import("//args.gni") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Copyright (c) 2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/mt793x_sdk.gni") | ||
import("//build_overrides/pigweed.gni") | ||
|
||
import("${build_root}/config/defaults.gni") | ||
import("${mt793x_sdk_build_root}/mt793x_executable.gni") | ||
import("${mt793x_sdk_build_root}/mt793x_sdk.gni") | ||
|
||
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") | ||
import("${chip_root}/src/platform/device.gni") | ||
|
||
if (chip_enable_pw_rpc) { | ||
import("//build_overrides/pigweed.gni") | ||
import("$dir_pw_build/target_types.gni") | ||
} | ||
|
||
assert(current_os == "freertos") | ||
|
||
mt793x_project_dir = "${chip_root}/examples/light-switch-app/genio" | ||
mt793x_examples_plat_dir = "${chip_root}/examples/platform/mt793x" | ||
|
||
declare_args() { | ||
# Dump memory usage at link time. | ||
chip_print_memory_usage = true | ||
|
||
# PIN code for PASE session establishment. | ||
setupPinCode = 20202021 | ||
setupDiscriminator = 3840 | ||
} | ||
|
||
mt793x_sdk("sdk") { | ||
sources = [ | ||
"${mt793x_project_dir}/include/CHIPProjectConfig.h", | ||
"${mt793x_project_dir}/include/FreeRTOSConfig.h", | ||
] | ||
|
||
include_dirs = [ | ||
"${chip_root}/src/platform/mt793x", | ||
"${mt793x_project_dir}/include", | ||
"${mt793x_examples_plat_dir}", | ||
"${chip_root}/src/lib", | ||
] | ||
|
||
defines = [ "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE" ] | ||
|
||
defines += [ | ||
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", | ||
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", | ||
] | ||
} | ||
|
||
mt793x_executable("light_switch_app") { | ||
output_name = "chip-mt793x-light-switch-app-example.out" | ||
include_dirs = [ "include" ] | ||
defines = [] | ||
|
||
sources = [ | ||
"src/AppTask.cpp", | ||
"src/BindingHandler.cpp", | ||
"src/LEDWidget.cpp", | ||
"src/ZclCallbacks.cpp", | ||
"src/main.cpp", | ||
] | ||
|
||
deps = [ | ||
":sdk", | ||
"${chip_root}/examples/common/QRCode", | ||
"${chip_root}/examples/light-switch-app/light-switch-common", | ||
"${chip_root}/examples/providers:device_info_provider", | ||
"${chip_root}/src/lib", | ||
"${chip_root}/src/setup_payload", | ||
"${mt793x_examples_plat_dir}:genio-matter-shell", | ||
] | ||
|
||
if (chip_enable_ota_requestor) { | ||
defines += [ "MT793X_OTA_ENABLED" ] | ||
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] | ||
} | ||
|
||
ldscript = "mt793x_xip.ld" | ||
|
||
inputs = [ ldscript ] | ||
|
||
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] | ||
|
||
if (chip_print_memory_usage) { | ||
ldflags += [ | ||
"-Wl,--print-memory-usage", | ||
"-fstack-usage", | ||
] | ||
} | ||
|
||
output_dir = root_out_dir | ||
} | ||
|
||
group("mt793x") { | ||
deps = [ ":light_switch_app" ] | ||
} | ||
|
||
group("default") { | ||
deps = [ ":mt793x" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#Matter `Genio` Light Switch Example | ||
|
||
An example showing the use of Matter on the MediaTek `Genio` MT793X. | ||
|
||
<hr> | ||
|
||
- [Matter Genio Light Switch Example](#chip-genio-light-switch-example) | ||
- [Introduction](#introduction) | ||
- [Building](#building) | ||
- [Note](#note) | ||
- [Flashing the Application](#flashing-the-application) | ||
- [Viewing Logging Output](#viewing-logging-output) | ||
- [Running the Complete Example](#running-the-complete-example) | ||
- [Notes](#notes) | ||
|
||
<hr> | ||
|
||
<a name="intro"></a> | ||
|
||
## Introduction | ||
|
||
The `Genio` (MT793X) light switch example provides a baseline demonstration of a | ||
on-off light switch device, built using Matter and the MediaTek `Genio` SDK. It | ||
can be controlled by a Chip controller over Wi-Fi network.. | ||
|
||
The `Genio` device can be commissioned over Bluetooth Low Energy where the | ||
device and the Chip controller will exchange security information with the | ||
Rendez-vous procedure. Network credentials are then provided to the `Genio` | ||
device which will then join the network. | ||
|
||
The light switch example is intended to serve both as a means to explore the | ||
workings of Matter as well as a template for creating real products based on the | ||
MediaTek platform. | ||
|
||
<a name="building"></a> | ||
|
||
## Building | ||
|
||
- Following the Linux related descriptions in | ||
[Build Matter](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/BUILDING.md) | ||
to prepare the build environment. | ||
|
||
- Supported hardware: | ||
|
||
`Genio` 130A (MT7931) board: | ||
|
||
- `EK-AI7931LD KIT` | ||
|
||
* Build the example application: | ||
|
||
`cd ~/connectedhomeip` | ||
`./scripts/examples/gn_genio_example.sh ./examples/light-switch-app/genio` `./out/light-switch-app` | ||
|
||
- To delete generated executable, libraries and object files use: | ||
|
||
`$ cd ~/connectedhomeip` | ||
`$ rm -rf ./out/` | ||
|
||
OR use GN/Ninja directly | ||
|
||
`$ cd ~/connectedhomeip/examples/light-switch-app/genio` | ||
`$ git submodule update --init` | ||
`$ source third_party/connectedhomeip/scripts/activate.sh` | ||
`$ gn gen out/debug` | ||
`$ ninja -C out/debug` | ||
|
||
- To delete generated executable, libraries and object files use: | ||
|
||
`$ cd ~/connectedhomeip/examples/light-switch-app/genio` | ||
`$ rm -rf out/` | ||
|
||
## Flashing the Application | ||
|
||
- Copy the GUI based | ||
[Flash Tool](https://github.com/MediaTek-Labs/genio-matter-bsp/tree/main/flash_tool/FlashBurningTool_V2.83). | ||
from the Linux Host that the example was build to a Windows PC. | ||
|
||
Flash Tool can be found in this source tree under this directory | ||
|
||
`third_party/mt793x_sdk/filogic/flash_tool` | ||
|
||
- On the Windows PC, run the Flash Tool | ||
|
||
1. Select the scatter.ini file in the `./out/light-switch-app` directory. | ||
2. Follow the instruction that comes with `EK-AI7931LD KIT` to switch the | ||
kit to download mode. | ||
3. Click `Download` on FLASH TOOL. | ||
|
||
## Running the Complete Example | ||
|
||
- This example needs one lighting-app device and one light-switch-app device. | ||
|
||
- You can provision and control the Chip device using the python controller, | ||
Chip tool standalone, Android or iOS app | ||
|
||
[CHIP | ||
Tool]](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/chip_tool_guide.md) | ||
|
||
- First of all, you have to commission with the light-switch-app (nodeID 1) | ||
and the lighting-app (nodeID 2) with the CHIP tool by following commands. | ||
|
||
``` | ||
chip-tool pairing ble-wifi 1 my-ap myappassword 20202021 3840 | ||
chip-tool pairing ble-wifi 2 my-ap myappassword 20202021 3840 | ||
``` | ||
- Next, you have to configure the ACL in the lighting-app device to allow | ||
access from switch device and chip-tool, and binding the lighting-app device | ||
to the light-switch-app device by following commands. | ||
``` | ||
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 | ||
chip-tool binding write binding '[{"fabricIndex": 1, "node":2, "endpoint":1, "cluster":6}]' 1 1 | ||
``` | ||
- Once all setup successfully, you can control the lighting-app device through | ||
the Matter Shell on the light-switch-app device. | ||
``` | ||
> switch onoff on | ||
> switch onoff off | ||
``` | ||
### Notes | ||
- Depending on your network settings your router might not provide native ipv6 | ||
addresses to your devices (Border router / PC). If this is the case, you | ||
need to add a static ipv6 addresses on both device and then an ipv6 route to | ||
the border router on your PC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/pigweed.gni") | ||
import("${chip_root}/src/platform/mt793x/args.gni") | ||
|
||
mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain") | ||
|
||
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" | ||
pw_assert_BACKEND = "$dir_pw_assert_log" | ||
|
||
chip_enable_ble = true | ||
|
||
declare_args() { | ||
chip_enable_ota_requestor = false | ||
|
||
# Disable lock tracking, since our FreeRTOS configuration does not set | ||
# INCLUDE_xSemaphoreGetMutexHolder | ||
chip_stack_lock_tracking = "none" | ||
|
||
chip_config_network_layer_ble = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/pigweed.gni") | ||
|
||
mt793x_sdk_target = get_label_info(":sdk", "label_no_toolchain") | ||
chip_enable_openthread = false | ||
import("${chip_root}/src/platform/MT793X/wifi_args.gni") | ||
|
||
pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" | ||
pw_assert_BACKEND = "$dir_pw_assert_log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
|
||
# The location of the build configuration file. | ||
buildconfig = "${build_root}/config/BUILDCONFIG.gn" | ||
|
||
# CHIP uses angle bracket includes. | ||
check_system_includes = true | ||
|
||
default_args = { | ||
target_cpu = "arm" | ||
target_os = "freertos" | ||
use_thread = false | ||
import("//build_for_wifi_args.gni") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build_overrides |
Oops, something went wrong.