Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASR] add more examples #26622

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/examples-asr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target asr-asr582x-all-clusters \
--target asr-asr582x-all-clusters-minimal \
--target asr-asr582x-lighting \
--target asr-asr582x-lighting-ota \
--target asr-asr582x-light-switch \
--target asr-asr582x-lock \
--target asr-asr582x-ota-requestor \
--target asr-asr582x-bridge \
--target asr-asr582x-temperature-measurement \
--target asr-asr582x-thermostat \
build \
"
23 changes: 18 additions & 5 deletions docs/guides/asr_getting_started_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ platform that uses ASR FreeRTOS SDK.
- [IP mode](#ip-mode)
- [Shell](#shell)
- [OTA](#ota)
- [Factory](#factory)

---

Expand Down Expand Up @@ -72,7 +73,8 @@ to speed up development. You can find them in the samples with `/asr` subfolder.
`--target` when build the examples.

- After building the application, `DOGO` tool is used to flash it to the
board.
board, please refer to the
[DOGO Tool User Guide](https://asriot.readthedocs.io/en/latest/ASR550X/Download-Tool/ASR_IoT_DOGO_Tool_User_Guide.html).

## Commissioning

Expand Down Expand Up @@ -128,7 +130,18 @@ There are two commissioning modes supported by ASR platform:

## OTA

To build the example with the Matter OTA Requestor functionality, exactly the
same steps as above but add argument `-ota` when using the `build_examples.py`
script. For example:
`./scripts/build/build_examples.py --target asr-$ASR_BOARD-lighting-ota build`
1. To build the example with the Matter OTA Requestor functionality, exactly the
same steps as above but add argument `-ota` when using the
`build_examples.py` script. For example:
`./scripts/build/build_examples.py --target asr-$ASR_BOARD-lighting-ota build`
2. For more usage details, please refer to the
[OTA example](../../examples/ota-requestor-app/asr/README.md)

## Factory

1. To build the example with the ASR Factory Data Provider, exactly the same
steps as above but add argument `-factory` when using the `build_examples.py`
script. For example:
`./scripts/build/build_examples.py --target asr-$ASR_BOARD-lighting-factory build`
2. For more usage details, please refer to the
[Factory Tool User Guide](https://github.com/asriot/Tools/blob/main/factory_tool/README.md)
29 changes: 29 additions & 0 deletions examples/all-clusters-app/asr/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2023 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")
}
135 changes: 135 additions & 0 deletions examples/all-clusters-app/asr/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Copyright (c) 2023 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/asr.gni")
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("${asr_sdk_build_root}/asr_sdk.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/asr/asr_executable.gni")

import("cfg.gni")

assert(current_os == "freertos")

asr_project_dir = "${chip_root}/examples/all-clusters-app/asr"
examples_plat_dir = "${chip_root}/examples/platform/asr"

declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
}

asr_sdk_sources("all_clusters_app_sdk_sources") {
include_dirs = [
"${chip_root}/src/platform/ASR",
"${asr_project_dir}/include",
"${examples_plat_dir}",
]

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

if (chip_enable_factory_data) {
defines += [
"CONFIG_ENABLE_ASR_FACTORY_DATA_PROVIDER=1",
"CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER=1",
]
}

if (chip_lwip_ip6_hook) {
defines += [
"CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
"CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT",
]
}

sources = [ "${asr_project_dir}/include/CHIPProjectConfig.h" ]

public_configs = [ "${asr_sdk_build_root}:asr_sdk_config" ]
}

asr_executable("clusters_app") {
include_dirs = []
defines = []
output_name = "chip-asr-clusters-example.out"

sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${examples_plat_dir}/CHIPDeviceManager.cpp",
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/init_Matter.cpp",
"${examples_plat_dir}/init_asrPlatform.cpp",
"${examples_plat_dir}/shell/matter_shell.cpp",
"src/AppTask.cpp",
"src/ButtonHandler.cpp",
"src/DeviceCallbacks.cpp",
"src/main.cpp",
]

if (chip_enable_ota_requestor) {
sources += [ "${examples_plat_dir}/init_OTARequestor.cpp" ]
}

deps = [
":all_clusters_app_sdk_sources",
"${chip_root}/examples/all-clusters-app/all-clusters-common",
"${chip_root}/examples/common/QRCode",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]

include_dirs += [
"include",
"${examples_plat_dir}",
"${asr_project_dir}/include",
"${chip_root}/examples/all-clusters-app/all-clusters-common/include",
"${chip_root}/src",
"${chip_root}/src/lib",
"${chip_root}/src/lib/support",
"${chip_root}/src/app/util",
]

defines = [ "ASR_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}" ]

if (chip_build_libshell) {
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
sources += [ "${examples_plat_dir}/shell/launch_shell.cpp" ]
include_dirs += [ "${examples_plat_dir}/shell" ]
}

if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
"-fstack-usage",
]
}

output_dir = root_out_dir
}

group("asr") {
deps = [ ":clusters_app" ]
}

group("default") {
deps = [ ":asr" ]
}
62 changes: 62 additions & 0 deletions examples/all-clusters-app/asr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Matter ASR All Clusters Example

A prototype application that demonstrates device commissioning and cluster
control on ASR platform.

---

- [Matter ASR All Clusters Example](#matter-asr-all-clusters-example)
- [Supported Chips](#supported-chips)
- [Building and Commissioning](#building-and-commissioning)
- [Cluster Control](#cluster-control)
- [Light switch press button and light status LED](#light-switch-press-button-and-light-status-led)

---

## Supported Chips

The Matter demo application is supported on:

- ASR582X
- ASR595X

## Building and Commissioning

Please refer
[Building and Commissioning](../../../docs/guides/asr_getting_started_guide.md#building-the-example-application)
guides to get started

```
./scripts/build/build_examples.py --target asr-$ASR_BOARD-all-clusters build
```

## Cluster Control

After successful commissioning, use `chip-tool` to control the board

For example, read sensor measured value:

```
./chip-tool temperaturemeasurement read measured-value <NODE ID> 1
./chip-tool relativehumiditymeasurement read measured-value <NODE ID> 1
./chip-tool pressuremeasurement read measured-value <NODE ID> 1
```

Or,control the OnOff Cluster attribute:

```
./chip-tool onoff read on-off <NODE ID> 1
./chip-tool onoff on <NODE ID> 1
./chip-tool onoff off <NODE ID> 1
./chip-tool onoff toggle <NODE ID> 1
```

## Light switch press button and light status LED

This demo uses button to test changing the light states and LED to show the
state of these changes.

| Name | Pin |
| :----: | :---: |
| LED | PAD6 |
| BUTTON | PAD12 |
27 changes: 27 additions & 0 deletions examples/all-clusters-app/asr/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2023 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("//cfg.gni")
import("${chip_root}/src/platform/ASR/args.gni")

asr_target_project =
get_label_info(":all_clusters_app_sdk_sources", "label_no_toolchain")

declare_args() {
# Disable lock tracking, since our FreeRTOS configuration does not set
# INCLUDE_xSemaphoreGetMutexHolder
chip_stack_lock_tracking = "none"
}
1 change: 1 addition & 0 deletions examples/all-clusters-app/asr/build_overrides
23 changes: 23 additions & 0 deletions examples/all-clusters-app/asr/cfg.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2023 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() {
chip_enable_factory_data = false

chip_lwip_ip6_hook = false

setupPinCode = 20202021

setupDiscriminator = 3840
}
Loading