-
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.
Support lighting app, Diagnostics Clusters for Infineon P6 (#12189)
- Loading branch information
Showing
41 changed files
with
2,785 additions
and
10 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
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
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
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) 2021 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,109 @@ | ||
# Copyright (c) 2021 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/p6.gni") | ||
|
||
import("${build_root}/config/defaults.gni") | ||
import("${p6_sdk_build_root}/p6_executable.gni") | ||
import("${p6_sdk_build_root}/p6_sdk.gni") | ||
|
||
assert(current_os == "freertos") | ||
|
||
p6_project_dir = "${chip_root}/examples/lighting-app/p6" | ||
examples_plat_dir = "${chip_root}/examples/platform/p6" | ||
|
||
declare_args() { | ||
# Dump memory usage at link time. | ||
chip_print_memory_usage = false | ||
|
||
# PIN code for PASE session establishment. | ||
setup_pin_code = 20202021 | ||
|
||
# Monitor & log memory usage at runtime. | ||
enable_heap_monitoring = false | ||
} | ||
|
||
p6_sdk_sources("lighting_app_sdk_sources") { | ||
include_dirs = [ | ||
"${chip_root}/src/platform/P6", | ||
"${p6_project_dir}/include", | ||
"${examples_plat_dir}", | ||
] | ||
|
||
defines = [ | ||
"BOARD_ID=${p6_board}", | ||
"P6_LOG_ENABLED=1", | ||
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setup_pin_code}", | ||
] | ||
|
||
sources = [ "${p6_project_dir}/include/CHIPProjectConfig.h" ] | ||
|
||
public_configs = [ "${chip_root}/third_party/p6:p6_sdk_config" ] | ||
} | ||
|
||
p6_executable("lighting_app") { | ||
include_dirs = [] | ||
defines = [] | ||
output_name = "chip-p6-lighting-example.out" | ||
|
||
sources = [ | ||
"${examples_plat_dir}/LEDWidget.cpp", | ||
"${examples_plat_dir}/init_p6Platform.cpp", | ||
"src/AppTask.cpp", | ||
"src/ButtonHandler.cpp", | ||
"src/LightingManager.cpp", | ||
"src/ZclCallbacks.cpp", | ||
"src/main.cpp", | ||
] | ||
|
||
deps = [ | ||
":lighting_app_sdk_sources", | ||
"${chip_root}/examples/common/QRCode", | ||
"${chip_root}/examples/lighting-app/lighting-common", | ||
"${chip_root}/src/lib", | ||
"${chip_root}/src/setup_payload", | ||
] | ||
|
||
include_dirs += [ | ||
"include", | ||
"${examples_plat_dir}", | ||
"${p6_project_dir}/include", | ||
] | ||
|
||
defines = [] | ||
|
||
if (enable_heap_monitoring) { | ||
sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] | ||
defines += [ "HEAP_MONITORING" ] | ||
} | ||
|
||
if (chip_print_memory_usage) { | ||
ldflags += [ | ||
"-Wl,--print-memory-usage", | ||
"-fstack-usage", | ||
] | ||
} | ||
|
||
output_dir = root_out_dir | ||
} | ||
|
||
group("p6") { | ||
deps = [ ":lighting_app" ] | ||
} | ||
|
||
group("default") { | ||
deps = [ ":p6" ] | ||
} |
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,156 @@ | ||
#CHIP P6 Lighting Example | ||
|
||
An example showing the use of Matter on the Infineon CY8CKIT-062S2-43012 board. | ||
|
||
<hr> | ||
|
||
- [Matter P6 Lighting Example](#chip-p6-Lighting-example) | ||
- [Introduction](#introduction) | ||
- [Building](#building) | ||
- [Flashing the Application](#flashing-the-application) | ||
- [Commissioning and cluster control](#commissioning-and-cluster-control) | ||
- [Setting up Python Controller](#setting-up-python-controller) | ||
- [Commissioning over BLE](#commissioning-over-ble) | ||
- [Notes](#notes) | ||
- [Cluster control](#cluster-control) | ||
|
||
<hr> | ||
|
||
<a name="intro"></a> | ||
|
||
## Introduction | ||
|
||
The P6 lighting example provides a baseline demonstration of a Light control | ||
device, built using Matter and the Infineon Modustoolbox SDK. It can be | ||
controlled by Matter controller over Wi-Fi network. | ||
|
||
The P6 device can be commissioned over Bluetooth Low Energy where the device and | ||
the Matter controller will exchange security information with the Rendezvous | ||
procedure. Wi-Fi Network credentials are then provided to the P6 device which | ||
will then join the network. | ||
|
||
<a name="building"></a> | ||
|
||
## Building | ||
|
||
- [Modustoolbox Software](https://www.cypress.com/products/modustoolbox) | ||
|
||
Refer to `integrations/docker/images/chip-build-infineon/Dockerfile` or | ||
`scripts/examples/gn_p6_example.sh` for downloading the Software and related | ||
tools. | ||
|
||
- Install some additional tools (likely already present for Matter | ||
developers): \$ sudo apt install gcc g++ clang ninja-build python | ||
python3-venv libssl-dev libavahi-client-dev libglib2.0-dev git cmake | ||
python3-pip | ||
|
||
- Supported hardware: | ||
[CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012) | ||
|
||
* Build the example application: | ||
|
||
$ ./scripts/examples/gn_p6_example.sh ./examples/lighting-app/p6 out/lighting_app_p6 | ||
|
||
- To delete generated executable, libraries and object files use: | ||
|
||
$ cd ~/connectedhomeip | ||
$ rm -rf out/ | ||
|
||
<a name="flashing"></a> | ||
|
||
## Flashing the Application | ||
|
||
- Put CY8CKIT-062S2-43012 board on KitProg3 CMSIS-DAP Mode by pressing the | ||
`MODE SELECT` button. `KITPROG3 STATUS` LED is ON confirms board is in | ||
proper mode. | ||
|
||
- On the command line: | ||
|
||
$ cd ~/connectedhomeip | ||
$ python3 out/lighting_app_p6/chip-p6-lock-example.flash.py | ||
|
||
<a name="Commissioning and cluster control"></a> | ||
|
||
## Commissioning and cluster control | ||
|
||
Commissioning can be carried out using BLE. | ||
|
||
<a name="Setting up Python Controller"></a> | ||
|
||
### Setting up Python Controller | ||
|
||
Once P6 is up and running, we need to set up a device controller on Raspberry Pi | ||
4 to perform commissioning and cluster control. | ||
|
||
- Set up python controller. | ||
|
||
$ cd {path-to-connectedhomeip} | ||
$ ./scripts/build_python.sh -m platform | ||
|
||
- Execute the controller. | ||
|
||
$ source ./out/python_env/bin/activate | ||
$ chip-device-ctrl | ||
|
||
<a name="Commissioning over BLE"></a> | ||
|
||
### Commissioning over BLE | ||
|
||
- Establish the secure session over BLE. | ||
|
||
- chip-device-ctrl > ble-scan | ||
- chip-device-ctrl > connect -ble 3840 20202021 1234 | ||
|
||
Parameters: | ||
1. Discriminator: 3840 | ||
2. Setup-pin-code: 20202021 | ||
3. Node ID: Optional. | ||
If not passed in this command, then it is auto-generated by the controller and | ||
displayed in the output of connect. | ||
The same value should be used in the next commands. | ||
We have chosen a random node ID which is 1234. | ||
|
||
- Add credentials of the Wi-Fi network you want the P6 to connect to, using | ||
the `AddWiFiNetwork` command and then enable the P6 to connect to it using | ||
`EnableWiFiNetwork` command. In this example, we have used `WIFI_SSID` and | ||
`WIFI_PASSWORD` as the SSID and passphrase respectively. | ||
|
||
- chip-device-ctrl > zcl NetworkCommissioning AddWiFiNetwork 1234 0 0 ssid=str:WIFI_SSID credentials=str:WIFI_PASSWORD breadcrumb=0 timeoutMs=1000 | ||
|
||
- chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=str:WIFI_SSID breadcrumb=0 timeoutMs=1000 | ||
|
||
- Close the BLE connection to P6, as it is not required hereafter. | ||
|
||
- chip-device-ctrl > close-ble | ||
|
||
- Resolve DNS-SD name and update address of the node in the device controller. | ||
|
||
- chip-device-ctrl > resolve 0 1234 | ||
|
||
<a name="Notes"></a> | ||
|
||
#### Notes | ||
|
||
Raspberry Pi 4 BLE connection issues can be avoided by running the following | ||
commands. These power cycle the BlueTooth hardware and disable BR/EDR mode. | ||
|
||
$ sudo btmgmt -i hci0 power off | ||
$ sudo btmgmt -i hci0 bredr off | ||
$ sudo btmgmt -i hci0 power on | ||
|
||
<a name="Cluster control"></a> | ||
|
||
### Cluster control | ||
|
||
- After successful commissioning, use the OnOff cluster command to toggle | ||
device between On or Off states. | ||
|
||
`chip-device-ctrl > zcl OnOff Off 1234 1 0` | ||
|
||
`chip-device-ctrl > zcl OnOff On 1234 1 0` | ||
|
||
- Cluster OnOff can also be done using the `USER_BTN1` button on the board. | ||
This button is configured with `APP_LIGHT_BUTTON` in `include/AppConfig.h`. | ||
Press `USER_BTN1` on the board to toggle between Light ON and OFF states. | ||
Light ON and OFF can be observed with 'LED9' on the board. This LED is | ||
configured with `LIGHT_STATE_LED` in `include/AppConfig.h`. |
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,20 @@ | ||
# Copyright (c) 2021 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/P6/args.gni") | ||
|
||
p6_target_project = | ||
get_label_info(":lighting_app_sdk_sources", "label_no_toolchain") |
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.