Skip to content

Commit

Permalink
Infineon CYW30739 - lighting-app support (project-chip#13491)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItoddchouFX authored and selissia committed Jan 28, 2022
1 parent dbff1da commit cf82b23
Show file tree
Hide file tree
Showing 91 changed files with 7,874 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ adb
AddOrUpdateThreadNetwork
AddOrUpdateWiFiNetwork
addr
AddThreadNetwork
adk
adoc
AdvAutonomous
Expand Down Expand Up @@ -252,6 +253,7 @@ customizations
cvfJ
cxx
CY
CYW
DAC
DAP
DataFrame
Expand Down Expand Up @@ -357,6 +359,7 @@ elftools
elock
emberAfExternalAttributeReadCallback
emberAfExternalAttributeWriteCallback
EnableNetwork
EnableWiFiNetwork
EndpointId
endpointName
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/examples-cyw30739.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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.

name: Build example - Infineon CYW30739

on:
push:
pull_request:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
cancel-in-progress: true

jobs:
cyw30739:
name: CYW30739
timeout-minutes: 60

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build:latest
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Set up environment for size reports
if: ${{ !env.ACT }}
env:
GH_CONTEXT: ${{ toJson(github) }}
run: scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"

- name: Bootstrap
timeout-minutes: 25
run: scripts/build/gn_bootstrap.sh
- name: Uploading bootstrap logs
uses: actions/upload-artifact@v2
if: ${{ always() }} && ${{ !env.ACT }}
with:
name: bootstrap-logs
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
- name: Build example CYW30739 Lighting App
timeout-minutes: 10
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target cyw30739-cyw930739m2evb_01-light \
build \
--copy-artifacts-to out/artifacts \
"
- name: Get light size stats
timeout-minutes: 5
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
cyw30739 cyw930739m2evb_01 light \
out/artifacts/cyw30739-cyw930739m2evb_01-light/chip-cyw30739-lighting-example.elf \
/tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
if: ${{ !env.ACT }}
with:
name: Size,CYW30739-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
path: |
/tmp/bloat_reports/
16 changes: 16 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
[submodule "third_party/openthread/ot-efr32"]
path = third_party/openthread/ot-efr32
url = https://github.com/openthread/ot-efr32.git
[submodule "third_party/openthread/ot-ifx"]
path = third_party/openthread/ot-ifx
url = https://github.com/Infineon/ot-ifx-release.git
branch = cyw30739
[submodule "third_party/mbed-os/repo"]
path = third_party/mbed-os/repo
url = https://github.com/ARMmbed/mbed-os.git
Expand Down Expand Up @@ -165,3 +169,15 @@
[submodule "third_party/jsoncpp/repo"]
path = third_party/jsoncpp/repo
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "cyw30739_sdk/30739A0"]
path = third_party/cyw30739_sdk/repos/30739A0
url = https://github.com/Infineon/30739A0.git
[submodule "cyw30739_sdk/include"]
path = third_party/cyw30739_sdk/repos/btsdk-include
url = https://github.com/Infineon/btsdk-include.git
[submodule "cyw30739_sdk/target"]
path = third_party/cyw30739_sdk/repos/CYW930739M2EVB-01
url = https://github.com/Infineon/TARGET_CYW930739M2EVB-01.git
[submodule "cyw30739_sdk/tools"]
path = third_party/cyw30739_sdk/repos/btsdk-tools
url = https://github.com/Infineon/btsdk-tools.git
19 changes: 19 additions & 0 deletions examples/build_overrides/cyw30739_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.

declare_args() {
# Root directory for CYW30739 SDK.
cyw30739_sdk_build_root =
"//third_party/connectedhomeip/third_party/cyw30739_sdk"
}
28 changes: 28 additions & 0 deletions examples/lighting-app/cyw30739/.gn
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 = "cyw30739"

import("//args.gni")
}
68 changes: 68 additions & 0 deletions examples/lighting-app/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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")
import("//build_overrides/chip.gni")
import("//build_overrides/cyw30739_sdk.gni")

import("${cyw30739_sdk_build_root}/cyw30739_executable.gni")
import("${cyw30739_sdk_build_root}/cyw30739_sdk.gni")

cyw30739_project_dir = "${chip_root}/examples/lighting-app/cyw30739"

declare_args() {
setupPinCode = 0
setupDiscriminator = 0
}

cyw30739_sdk("sdk") {
sources = [ "${cyw30739_project_dir}/include/CHIPProjectConfig.h" ]

include_dirs = [ "${cyw30739_project_dir}/include" ]

defines = [
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
]
}

cyw30739_executable("lighting_app") {
output_name = "chip-cyw30739-lighting-example.elf"

sources = [
"src/AppShellCommands.cpp",
"src/ButtonHandler.cpp",
"src/LightingManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]

deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/shell/shell_common:shell_common",
"${chip_root}/src/lib",
"${chip_root}/third_party/openthread/repo:libopenthread-ftd",
]

include_dirs = [ "include" ]
}

group("cyw30739") {
deps = [ ":lighting_app" ]
}

group("default") {
deps = [ ":cyw30739" ]
}
104 changes: 104 additions & 0 deletions examples/lighting-app/cyw30739/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Matter CYW30739 Lighting Example

An example showing the use of Matter on the Infineon CYW30739 platform.

---

## Table of Contents

- [CHIP CYW30739 Lighting Example](#matter-cyw30739-lighting-example)
- [Introduction](#introduction)
- [Building](#building)
- [Flashing the Application](#flashing-the-application)
- [Running the Complete Example](#running-the-complete-example)

---

## Introduction

The CYW30739 lighting example provides a baseline demonstration of a Light
control device, built using Matter and the Infineon Modustoolbox SDK. It can be
controlled by a Matter controller over Openthread network.

The CYW30739 device can be commissioned over Bluetooth Low Energy where the
device and the Matter controller will exchange security information with the
Rendez-vous procedure. Thread Network credentials are then provided to the
CYW30739 device which will then join the network.

## Building

- Build the example application:

```bash
$ cd ~/connectedhomeip
$ git submodule update --init
$ ./scripts/examples/gn_build_example.sh examples/lighting-app/cyw30739 out/lighting-app
```

- To delete generated executable, libraries and object files use:

```bash
$ cd ~/connectedhomeip
$ rm -rf ./out/
```

- OR use GN/Ninja directly

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ 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:

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ rm -rf out/
```

## Flashing the Application

### Enter Recovery Mode

Put the CYW30739 in to the recovery mode before running the flash script.

1. Press and hold the `RECOVERY` button on the board.
2. Press and hold the `RESET` button on the board.
3. Release the `RESET` button.
4. After one second, release the `RECOVERY` button.

### Run Flash Script

- On the command line:

```bash
$ cd ~/connectedhomeip/examples/lighting-app/cyw30739
$ python3 out/debug/chip-cyw30739-lighting-example.flash.py
```

## Running the Complete Example

- It is assumed here that you already have an OpenThread border router
configured and running. If not see the following guide
[Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md)
for more information on how to setup a border router on a raspberryPi.

- You can provision and control the Chip device using the python controller,
Chip tool standalone, Android or iOS app

[Python Controller](https://github.com/project-chip/connectedhomeip/blob/master/src/controller/python/README.md)

Here is an example with the Python controller:

```bash
$ chip-device-ctrl
chip-device-ctrl > connect -ble 3840 20202021 1234
chip-device-ctrl > zcl NetworkCommissioning AddThreadNetwork 1234 0 0 operationalDataset=hex:0e080000000000000000000300000b35060004001fffe00208dead00beef00cafe0708fddead00beef000005108e11d8ea8ffaa875713699f59e8807e0030a4f70656e5468726561640102c2980410edc641eb63b100b87e90a9980959befc0c0402a0fff8 breadcrumb=0 timeoutMs=1000
chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 1234 0 0 networkID=hex:dead00beef00cafe breadcrumb=0 timeoutMs=1000
chip-device-ctrl > close-ble
chip-device-ctrl > resolve 1234
chip-device-ctrl > zcl OnOff Toggle 1234 1 0
```
18 changes: 18 additions & 0 deletions examples/lighting-app/cyw30739/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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("${chip_root}/src/platform/CYW30739/args.gni")

cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain")
1 change: 1 addition & 0 deletions examples/lighting-app/cyw30739/build_overrides
Loading

0 comments on commit cf82b23

Please sign in to comment.