From 255958875f956e6cbf43b5f2bf045ebed44cab3a Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:55:37 -0400 Subject: [PATCH] [EFR32] First draft of the thermostat app (#21245) * Initial draft of the thermostat example * generated files --- examples/thermostat/efr32/.gn | 28 + examples/thermostat/efr32/BUILD.gn | 338 +++++++++ examples/thermostat/efr32/README.md | 360 ++++++++++ examples/thermostat/efr32/args.gni | 26 + .../thermostat/efr32/build_for_wifi_args.gni | 24 + .../thermostat/efr32/build_for_wifi_gnfile.gn | 28 + examples/thermostat/efr32/build_overrides | 1 + examples/thermostat/efr32/include/AppConfig.h | 46 ++ examples/thermostat/efr32/include/AppEvent.h | 55 ++ examples/thermostat/efr32/include/AppTask.h | 222 ++++++ .../efr32/include/CHIPProjectConfig.h | 143 ++++ examples/thermostat/efr32/src/AppTask.cpp | 643 +++++++++++++++++ .../thermostat/efr32/src/ZclCallbacks.cpp | 65 ++ examples/thermostat/efr32/src/main.cpp | 84 +++ .../efr32/third_party/connectedhomeip | 1 + .../thermostat-common/thermostat.matter | 79 ++- .../thermostat-common/thermostat.zap | 659 ++++++------------ .../thermostat/zap-generated/CHIPClusters.h | 10 + .../zap-generated/IMClusterCommandHandler.cpp | 33 +- .../PluginApplicationCallbacks.h | 3 +- .../zap-generated/callback-stub.cpp | 8 + .../zap-generated/endpoint_config.h | 160 +++-- .../thermostat/zap-generated/gen_config.h | 15 +- 23 files changed, 2491 insertions(+), 540 deletions(-) create mode 100644 examples/thermostat/efr32/.gn create mode 100644 examples/thermostat/efr32/BUILD.gn create mode 100644 examples/thermostat/efr32/README.md create mode 100644 examples/thermostat/efr32/args.gni create mode 100644 examples/thermostat/efr32/build_for_wifi_args.gni create mode 100644 examples/thermostat/efr32/build_for_wifi_gnfile.gn create mode 120000 examples/thermostat/efr32/build_overrides create mode 100644 examples/thermostat/efr32/include/AppConfig.h create mode 100644 examples/thermostat/efr32/include/AppEvent.h create mode 100644 examples/thermostat/efr32/include/AppTask.h create mode 100644 examples/thermostat/efr32/include/CHIPProjectConfig.h create mode 100644 examples/thermostat/efr32/src/AppTask.cpp create mode 100644 examples/thermostat/efr32/src/ZclCallbacks.cpp create mode 100644 examples/thermostat/efr32/src/main.cpp create mode 120000 examples/thermostat/efr32/third_party/connectedhomeip diff --git a/examples/thermostat/efr32/.gn b/examples/thermostat/efr32/.gn new file mode 100644 index 00000000000000..0ff42d50e06ef0 --- /dev/null +++ b/examples/thermostat/efr32/.gn @@ -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" + chip_openthread_ftd = true + import("//args.gni") +} diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn new file mode 100644 index 00000000000000..435bf123f75764 --- /dev/null +++ b/examples/thermostat/efr32/BUILD.gn @@ -0,0 +1,338 @@ +# 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/efr32_sdk.gni") +import("//build_overrides/pigweed.gni") + +import("${build_root}/config/defaults.gni") +import("${efr32_sdk_build_root}/efr32_executable.gni") +import("${efr32_sdk_build_root}/efr32_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") + +efr32_project_dir = "${chip_root}/examples/thermostat/efr32" +examples_plat_dir = "${chip_root}/examples/platform/efr32" + +declare_args() { + # Dump memory usage at link time. + chip_print_memory_usage = false + + # PIN code for PASE session establishment. + setupPinCode = 20202021 + setupDiscriminator = 3840 + + # Monitor & log memory usage at runtime. + enable_heap_monitoring = false + + # Enable Sleepy end device + enable_sleepy_device = false + + # OTA timeout in seconds + OTA_periodic_query_timeout = 86400 + + # Wifi related stuff - they are overridden by gn -args="use_wf200=true" + use_wf200 = false + use_rs911x = false + use_rs911x_sockets = false + sl_wfx_config_softap = false + sl_wfx_config_scan = true + + # Disable LCD on supported devices + disable_lcd = false + + # Argument to Disable IPv4 for wifi(rs911) + chip_enable_wifi_ipv4 = false +} + +declare_args() { + # Enables LCD Qr Code on supported devices + show_qr_code = !disable_lcd +} + +# qr code cannot be true if lcd is disabled +assert(!(disable_lcd && show_qr_code)) + +# Sanity check +assert(!(chip_enable_wifi && chip_enable_openthread)) +assert(!(use_rs911x && chip_enable_openthread)) +assert(!(use_wf200 && chip_enable_openthread)) +if (chip_enable_wifi) { + assert(use_rs911x || use_wf200) +} + +# BRD4166A --> ThunderBoard Sense 2 (No LCD) +if (efr32_board == "BRD4166A" || efr32_board == "BRD4180A") { + show_qr_code = false + disable_lcd = true +} + +# WiFi settings +if (chip_enable_wifi) { + wifi_sdk_dir = "${chip_root}/third_party/silabs/matter_support/matter/wifi" + efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] + efr32_lwip_defs += [ + "LWIP_IPV4=1", + "LWIP_ARP=1", + "LWIP_ICMP=1", + "LWIP_DHCP=1", + "LWIP_IPV6_ND=1", + "LWIP_IGMP=1", + ] + + if (use_rs911x) { + wiseconnect_sdk_root = + "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" + import("${wifi_sdk_dir}/rs911x/rs911x.gni") + } else { + import("${wifi_sdk_dir}/wf200/wf200.gni") + } +} + +efr32_sdk("sdk") { + sources = [ + "${efr32_project_dir}/include/CHIPProjectConfig.h", + "${examples_plat_dir}/FreeRTOSConfig.h", + ] + + include_dirs = [ + "${chip_root}/src/platform/EFR32", + "${efr32_project_dir}/include", + "${examples_plat_dir}", + "${chip_root}/src/lib", + ] + + defines = [ + "BOARD_ID=${efr32_board}", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", + "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", + ] + + if (chip_enable_pw_rpc) { + defines += [ + "HAL_VCOM_ENABLE=1", + "PW_RPC_ENABLED", + ] + } + + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + defines += rs911x_defs + include_dirs += rs911x_plat_incs + } else if (use_wf200) { + defines += wf200_defs + include_dirs += wf200_plat_incs + } + + if (use_rs911x_sockets) { + include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ] + defines += rs911x_sock_defs + } else { + # Using LWIP instead of the native TCP/IP stack + defines += efr32_lwip_defs + } + + if (sl_wfx_config_softap) { + defines += [ "SL_WFX_CONFIG_SOFTAP" ] + } + if (sl_wfx_config_scan) { + defines += [ "SL_WFX_CONFIG_SCAN" ] + } + } +} + +efr32_executable("thermostat_app") { + output_name = "chip-efr32-thermostat-example.out" + include_dirs = [ "include" ] + defines = [] + + sources = [ + "${examples_plat_dir}/LEDWidget.cpp", + "${examples_plat_dir}/efr32_utils.cpp", + "${examples_plat_dir}/heap_4_silabs.c", + "${examples_plat_dir}/init_efrPlatform.cpp", + "${examples_plat_dir}/matter_config.cpp", + "src/AppTask.cpp", + "src/ZclCallbacks.cpp", + "src/main.cpp", + ] + + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli) { + sources += [ "${examples_plat_dir}/uart.cpp" ] + } + + deps = [ + ":sdk", + "${chip_root}/examples/providers:device_info_provider", + "${chip_root}/examples/thermostat/thermostat-common", + "${chip_root}/src/lib", + "${chip_root}/src/setup_payload", + ] + + # OpenThread Settings + if (chip_enable_openthread) { + deps += [ + "${chip_root}/third_party/openthread/platforms:libopenthread-platform", + "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", + "${examples_plat_dir}:efr-matter-shell", + ] + if (chip_openthread_ftd) { + deps += [ + "${chip_root}/third_party/openthread/repo:libopenthread-cli-ftd", + "${chip_root}/third_party/openthread/repo:libopenthread-ftd", + ] + } else { + deps += [ + "${chip_root}/third_party/openthread/repo:libopenthread-cli-mtd", + "${chip_root}/third_party/openthread/repo:libopenthread-mtd", + ] + } + } + + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } + + if (chip_enable_ota_requestor) { + defines += [ "EFR32_OTA_ENABLED" ] + sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] + } + + if (chip_enable_wifi_ipv4) { + defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] + } + + # WiFi Settings + if (chip_enable_wifi) { + if (use_rs911x) { + sources += rs911x_src_plat + + # All the stuff from wiseconnect + sources += rs911x_src_sapi + + # Apparently - the rsi library needs this (though we may not use use it) + sources += rs911x_src_sock + include_dirs += rs911x_inc_plat + + if (use_rs911x_sockets) { + # + # Using native sockets inside RS911x + # + include_dirs += rs911x_sock_inc + } else { + # + # We use LWIP - not built-in sockets + # + sources += rs911x_src_lwip + } + } else if (use_wf200) { + sources += wf200_plat_src + include_dirs += wf200_plat_incs + } + } + + if (!disable_lcd) { + sources += [ "${examples_plat_dir}/display/lcd.c" ] + defines += [ "DISPLAY_ENABLED" ] + if (show_qr_code) { + defines += [ "QR_CODE_ENABLED" ] + deps += [ "${chip_root}/examples/common/QRCode" ] + } + } + + if (chip_enable_pw_rpc) { + defines += [ + "PW_RPC_ENABLED", + "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BUTTON_SERVICE=1", + "PW_RPC_DESCRIPTOR_SERVICE=1", + "PW_RPC_DEVICE_SERVICE=1", + "PW_RPC_LIGHTING_SERVICE=1", + ] + + sources += [ + "${chip_root}/examples/common/pigweed/RpcService.cpp", + "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", + "${examples_plat_dir}/PigweedLogger.cpp", + "${examples_plat_dir}/Rpc.cpp", + ] + + deps += [ + "$dir_pw_hdlc:rpc_channel_output", + "$dir_pw_stream:sys_io_stream", + "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", + "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32", + ] + + deps += pw_build_LINK_DEPS + + include_dirs += [ + "${chip_root}/examples/common", + "${chip_root}/examples/common/pigweed/efr32", + ] + } + + if (enable_heap_monitoring) { + sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] + defines += [ "HEAP_MONITORING" ] + } + + ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + + inputs = [ ldscript ] + + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + + if (chip_print_memory_usage) { + ldflags += [ + "-Wl,--print-memory-usage", + "-fstack-usage", + ] + } + + # WiFi Settings + if (chip_enable_wifi) { + ldflags += [ + "-Wl,--defsym", + "-Wl,SILABS_WIFI=1", + ] + } + + output_dir = root_out_dir +} + +group("efr32") { + deps = [ ":thermostat_app" ] +} + +group("default") { + deps = [ ":efr32" ] +} diff --git a/examples/thermostat/efr32/README.md b/examples/thermostat/efr32/README.md new file mode 100644 index 00000000000000..35cbeefad50b4a --- /dev/null +++ b/examples/thermostat/efr32/README.md @@ -0,0 +1,360 @@ +# CHIP EFR32 Light Switch Example + +An example showing the use of CHIP on the Silicon Labs EFR32 MG12. + +
+ +- [CHIP EFR32 Light Switch Example](#chip-efr32-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) + - [Running RPC console](#running-rpc-console) + - [Memory settings](#memory-settings) + - [OTA Software Update](#ota-software-update) + +
+ + + +## Introduction + +The EFR32 light switch example provides a baseline demonstration of a on-off +light switch device, built using CHIP and the Silicon Labs gecko SDK. It can be +controlled by a Chip controller over Openthread network. + +The EFR32 device can be commissioned over Bluetooth Low Energy where the device +and the Chip controller will exchange security information with the Rendez-vous +procedure. Thread Network credentials are then provided to the EFR32 device +which will then join the network. + +The LCD on the Silabs WSTK shows a QR Code containing the needed commissioning +information for the BLE connection and starting the Rendez-vous procedure. + +The light switch example is intended to serve both as a means to explore the +workings of CHIP as well as a template for creating real products based on the +Silicon Labs platform. + + + +## Building + +- Download the + [Simplicity Commander](https://www.silabs.com/mcu/programming-options) + command line tool, and ensure that `commander` is your shell search path. + (For Mac OS X, `commander` is located inside + `Commander.app/Contents/MacOS/`.) + +- Download and install a suitable ARM gcc tool chain: + [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) + +- Install some additional tools(likely already present for CHIP developers): + +#### Linux + + $ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build``` + +#### Mac OS X + + $ brew install ninja + +- Supported hardware: + + MG12 boards: + + - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm + - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm + - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm + - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, + 915MHz@19dBm + - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm + + MG21 boards: Currently not supported due to RAM limitation. + + - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm + + MG24 boards : + + - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm + - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm + +* Build the example application: + + cd ~/connectedhomeip + ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32/ ./out/thermostat-app BRD4161A + +- To delete generated executable, libraries and object files use: + + $ cd ~/connectedhomeip + $ rm -rf ./out/ + + OR use GN/Ninja directly + + $ cd ~/connectedhomeip/examples/thermostat/efr32 + $ git submodule update --init + $ source third_party/connectedhomeip/scripts/activate.sh + $ export EFR32_BOARD=BRD4161A + $ gn gen out/debug + $ ninja -C out/debug + +- To delete generated executable, libraries and object files use: + + $ cd ~/connectedhomeip/examples/thermostat/efr32 + $ rm -rf out/ + +* Build the example with Matter shell + + ./scripts/examples/gn_efr32_example.sh examples/thermostat/efr32/ out/thermostat-app BRD4161A chip_build_libshell=true + +* Build the example as Sleepy End Device (SED) + + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32/ ./out/thermostat-app_SED BRD4161A --sed + + or use gn as previously mentioned but adding the following arguments: + + $ gn gen out/debug '--args=efr32_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' + +* Build the example with pigweed RCP + + $ ./scripts/examples/gn_efr32_example.sh examples/thermostat/efr32/ out/thermostat-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + + or use GN/Ninja Directly + + $ cd ~/connectedhomeip/examples/thermostat/efr32 + $ git submodule update --init + $ source third_party/connectedhomeip/scripts/activate.sh + $ export EFR32_BOARD=BRD4161A + $ gn gen out/debug --args='import("//with_pw_rpc.gni")' + $ ninja -C out/debug + + [Running Pigweed RPC console](#running-pigweed-rpc-console) + +For more build options, help is provided when running the build script without +arguments + + ./scripts/examples/gn_efr32_example.sh + + + +## Flashing the Application + +- On the command line: + + $ cd ~/connectedhomeip/examples/thermostat/efr32 + $ python3 out/debug/chip-efr32-thermostat-switch-example.flash.py + +- Or with the Ozone debugger, just load the .out file. + + + +## Viewing Logging Output + +The example application is built to use the SEGGER Real Time Transfer (RTT) +facility for log output. RTT is a feature built-in to the J-Link Interface MCU +on the WSTK development board. It allows bi-directional communication with an +embedded application without the need for a dedicated UART. + +Using the RTT facility requires downloading and installing the _SEGGER J-Link +Software and Documentation Pack_ +([web site](https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack)). + +Alternatively, SEGGER Ozone J-Link debugger can be used to view RTT logs too +after flashing the .out file. + +- Download the J-Link installer by navigating to the appropriate URL and + agreeing to the license agreement. + +- [JLink_Linux_x86_64.deb](https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb) +- [JLink_MacOSX.pkg](https://www.segger.com/downloads/jlink/JLink_MacOSX.pkg) + +* Install the J-Link software + + $ cd ~/Downloads + $ sudo dpkg -i JLink_Linux_V*_x86_64.deb + +* In Linux, grant the logged in user the ability to talk to the development + hardware via the linux tty device (/dev/ttyACMx) by adding them to the + dialout group. + + $ sudo usermod -a -G dialout ${USER} + +Once the above is complete, log output can be viewed using the JLinkExe tool in +combination with JLinkRTTClient as follows: + +- Run the JLinkExe tool with arguments to autoconnect to the WSTK board: + + For MG12 use: + + $ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1 + + For MG21 use: + + $ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1 + +- In a second terminal, run the JLinkRTTClient to view logs: + + $ JLinkRTTClient + + + +## 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. + + Take note that the RCP code is available directly through + [Simplicity Studio 5](https://www.silabs.com/products/development-tools/software/simplicity-studio/simplicity-studio-5) + under File->New->Project Wizard->Examples->Thread : ot-rcp + +- For this example to work, it is necessary to have a second efr32 device + running the + [thermostat app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/thermostat/efr32/README.md) + commissioned on the same openthread network + +- User interface : **LCD** The LCD on Silabs WSTK shows a QR Code. This QR + Code is be scanned by the CHIP Tool app For the Rendez-vous procedure over + BLE + + * On devices that do not have or support the LCD Display like the BRD4166A Thunderboard Sense 2, + a URL can be found in the RTT logs. + + [SVR] Copy/paste the below URL in a browser to see the QR Code: + [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 + + **LED 0** shows the overall state of the device and its connectivity. The + following states are possible: + + - Short Flash On (50 ms on/950 ms off): The device is in the + unprovisioned (unpaired) state and is waiting for a commissioning + application to connect. + + - Rapid Even Flashing (100 ms on/100 ms off): The device is in the + unprovisioned state and a commissioning application is connected through + Bluetooth LE. + + - Short Flash Off (950ms on/50ms off): The device is fully + provisioned, but does not yet have full Thread network or service + connectivity. + + - Solid On: The device is fully provisioned and has full Thread + network and service connectivity. + + **Push Button 0** + + - _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode + for 30 seconds. The device will then switch to a slower interval advertisement. + After 15 minutes, the advertisement stops. + + - _Pressed and hold for 6 s_ : Initiates the factory reset of the device. + Releasing the button within the 6-second window cancels the factory reset + procedure. **LEDs** blink in unison when the factory reset procedure is + initiated. + +* You can provision and control the Chip device using the python controller, + [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) + standalone, Android or iOS app + + Here is an example with the CHIPTool: + + ``` + chip-tool pairing ble-thread 1 hex: 20202021 3840 + ``` + +### 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 + +#### On Border Router: + +`$ sudo ip addr add dev 2002::2/64` + +#### On PC(Linux): + +`$ sudo ip addr add dev 2002::1/64` + +#Add Ipv6 route on PC(Linux) \$ sudo ip route add /64 +via 2002::2 + + + +## Running RPC console + +- As part of building the example with RPCs enabled the chip_rpc python + interactive console is installed into your venv. The python wheel files are + also created in the output folder: out/debug/chip_rpc_console_wheels. To + install the wheel files without rebuilding: + + `pip3 install out/debug/chip_rpc_console_wheels/*.whl` + +- To use the chip-rpc console after it has been installed run: + + `chip-console --device /dev/tty. -b 115200 -o //pw_log.out` + +- Then you can simulate a button press or release using the following command + where : idx = 0 or 1 for Button PB0 or PB1 action = 0 for PRESSED, 1 for + RELEASE Test toggling the LED with + + `rpcs.chip.rpc.Button.Event(idx=1, pushed=True)` + +## Memory settings + +While most of the RAM usage in CHIP is static, allowing easier debugging and +optimization with symbols analysis, we still need some HEAP for the crypto and +OpenThread. Size of the HEAP can be modified by changing the value of the +`configTOTAL_HEAP_SIZE` define inside of the FreeRTOSConfig.h file of this +example. Please take note that a HEAP size smaller than 13k can and will cause a +Mbedtls failure during the BLE rendez-vous or CASE session + +To track memory usage you can set `enable_heap_monitoring = true` either in the +BUILD.gn file or pass it as a build argument to gn. This will print on the RTT +console the RAM usage of each individual task and the number of Memory +allocation and Free. While this is not extensive monitoring you're welcome to +modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory +tracking code inside the `trackAlloc` and `trackFree` function + +## OTA Software Update + +For the description of Software Update process with EFR32 example applications +see +[EFR32 OTA Software Update](../../../docs/guides/silabs_efr32_software_update.md) + +## Building options + +All of Silabs's examples within the Matter repo have all the features enabled by +default, as to provide the best end user experience. However some of those +features can easily be toggled on or off. Here is a short list of options : + +### Disabling logging + +chip_progress_logging, chip_detail_logging, chip_automation_logging + + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32 ./out/thermostat-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + +### Debug build / release build + +is_debug + + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32 ./out/thermostat-app BRD4164A "is_debug=false" + +### Disabling LCD + +show_qr_code + + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32 ./out/thermostat-app BRD4164A "show_qr_code=false" + +### KVS maximum entry count + +kvs_max_entries + + Set the maximum Kvs entries that can be stored in NVM (Default 75) + Thresholds: 30 <= kvs_max_entries <= 255 + + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/efr32 ./out/thermostat-app BRD4164A kvs_max_entries=50 diff --git a/examples/thermostat/efr32/args.gni b/examples/thermostat/efr32/args.gni new file mode 100644 index 00000000000000..7df1c5e400f56f --- /dev/null +++ b/examples/thermostat/efr32/args.gni @@ -0,0 +1,26 @@ +# 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") +import("${chip_root}/src/platform/EFR32/args.gni") + +efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") + +chip_enable_ota_requestor = true + +pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" +pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" +chip_enable_openthread = true +pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" diff --git a/examples/thermostat/efr32/build_for_wifi_args.gni b/examples/thermostat/efr32/build_for_wifi_args.gni new file mode 100644 index 00000000000000..4a3bdfd804ae19 --- /dev/null +++ b/examples/thermostat/efr32/build_for_wifi_args.gni @@ -0,0 +1,24 @@ +# 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") + +efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +chip_enable_openthread = false +import("${chip_root}/src/platform/EFR32/wifi_args.gni") + +chip_enable_ota_requestor = true + +pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" +pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" diff --git a/examples/thermostat/efr32/build_for_wifi_gnfile.gn b/examples/thermostat/efr32/build_for_wifi_gnfile.gn new file mode 100644 index 00000000000000..d391814190d09f --- /dev/null +++ b/examples/thermostat/efr32/build_for_wifi_gnfile.gn @@ -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" + chip_enable_wifi = true + import("//build_for_wifi_args.gni") +} diff --git a/examples/thermostat/efr32/build_overrides b/examples/thermostat/efr32/build_overrides new file mode 120000 index 00000000000000..e578e73312ebd1 --- /dev/null +++ b/examples/thermostat/efr32/build_overrides @@ -0,0 +1 @@ +../../build_overrides \ No newline at end of file diff --git a/examples/thermostat/efr32/include/AppConfig.h b/examples/thermostat/efr32/include/AppConfig.h new file mode 100644 index 00000000000000..91501d889a6234 --- /dev/null +++ b/examples/thermostat/efr32/include/AppConfig.h @@ -0,0 +1,46 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * 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. + */ + +#pragma once + +// ---- Lighting Example App Config ---- + +#define APP_TASK_NAME "Lit" + +// Time it takes in ms for the simulated actuator to move from one +// state to another. +#define ACTUATOR_MOVEMENT_PERIOS_MS 10 + +// EFR Logging +#ifdef __cplusplus +extern "C" { +#endif + +void efr32LogInit(void); + +void efr32Log(const char * aFormat, ...); +#define EFR32_LOG(...) efr32Log(__VA_ARGS__); +void appError(int err); + +#ifdef __cplusplus +} + +#include +void appError(CHIP_ERROR error); +#endif diff --git a/examples/thermostat/efr32/include/AppEvent.h b/examples/thermostat/efr32/include/AppEvent.h new file mode 100644 index 00000000000000..7a19b719edad25 --- /dev/null +++ b/examples/thermostat/efr32/include/AppEvent.h @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * All rights reserved. + * + * 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. + */ + +#pragma once + +struct AppEvent; +typedef void (*EventHandler)(AppEvent *); + +struct AppEvent +{ + enum AppEventTypes + { + kEventType_Button = 0, + kEventType_Timer, + kEventType_Light, + kEventType_Install, + }; + + uint16_t Type; + + union + { + struct + { + uint8_t Action; + } ButtonEvent; + struct + { + void * Context; + } TimerEvent; + struct + { + uint8_t Action; + int32_t Actor; + } LightEvent; + }; + + EventHandler Handler; +}; diff --git a/examples/thermostat/efr32/include/AppTask.h b/examples/thermostat/efr32/include/AppTask.h new file mode 100644 index 00000000000000..357d2d97c4584a --- /dev/null +++ b/examples/thermostat/efr32/include/AppTask.h @@ -0,0 +1,222 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * 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. + */ + +#pragma once + +/********************************************************** + * Includes + *********************************************************/ + +#include +#include + +#include "AppEvent.h" +#include "FreeRTOS.h" +#include "sl_simple_button_instances.h" +#include "timers.h" // provides FreeRTOS timer support +#include +#include +#include +#include + +/********************************************************** + * Defines + *********************************************************/ + +// Application-defined error codes in the CHIP_ERROR space. +#define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) +#define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) +#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) +#define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) +#define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) +#define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) + +/********************************************************** + * AppTask Declaration + *********************************************************/ + +class AppTask +{ + +public: + /********************************************************** + * Public Function Declaration + *********************************************************/ + + /** + * @brief Create AppTask task and Event Queue + * If an error occurs during creation, application will hang after printing out error code + * + * @return CHIP_ERROR CHIP_NO_ERROR if no errors + */ + CHIP_ERROR StartAppTask(); + + /** + * @brief AppTask task main loop function + * + * @param pvParameter FreeRTOS task parameter + */ + static void AppTaskMain(void * pvParameter); + + /** + * @brief PostEvent function that add event to AppTask queue for processing + * + * @param event AppEvent to post + */ + void PostEvent(const AppEvent * event); + + /** + * @brief Event handler when a button is pressed + * Function posts an event for button processing + * + * @param buttonHandle APP_LIGHT_SWITCH or APP_FUNCTION_BUTTON + * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED, + * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED + */ + void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction); + + /** + * @brief Callback called by the identify-server when an identify command is received + * + * @param identify identify structure the command applies on + */ + static void OnIdentifyStart(Identify * identify); + + /** + * @brief Callback called by the identify-server when an identify command is stopped or finished + * + * @param identify identify structure the command applies on + */ + static void OnIdentifyStop(Identify * identify); + + /** + * @brief Function called to start the LED light timer + */ + void StartLightTimer(void); + + /** + * @brief Function to stop LED light timer + * Turns off Status LED before stopping timer + */ + void CancelLightTimer(void); + +private: + /********************************************************** + * Private Function Declaration + *********************************************************/ + + friend AppTask & GetAppTask(void); + + /** + * @brief AppTask initialisation function + * + * @return CHIP_ERROR + */ + CHIP_ERROR Init(); + + /** + * @brief Function called to start the function timer + * + * @param aTimeoutMs timer duration in ms + */ + void StartFunctionTimer(uint32_t aTimeoutMs); + + /** + * @brief Function to stop function timer + */ + void CancelFunctionTimer(void); + + /** + * @brief Function call event callback function for processing + * + * @param event triggered event to be processed + */ + void DispatchEvent(AppEvent * event); + + /** + * @brief Function Timer finished callback function + * Post an FunctionEventHandler event + * + * @param xTimer timer that finished + */ + static void FunctionTimerEventHandler(TimerHandle_t xTimer); + + /** + * @brief Timer Event processing function + * Trigger factory if Press and Hold duration is respected + * + * @param aEvent post event being processed + */ + static void FunctionEventHandler(AppEvent * aEvent); + + /** + * @brief PB0 Button event processing function + * Press and hold will trigger a factory reset timer start + * Press and release will restart BLEAdvertising if not commisionned + * + * @param aEvent button event being processed + */ + static void ButtonHandler(AppEvent * aEvent); + + /** + * @brief PB1 Button event processing function + * Function triggers a thermostat action sent to the CHIP task + * + * @param aEvent button event being processed + */ + static void ThermostatActionEventHandler(AppEvent * aEvent); + + /** + * @brief Light Timer finished callback function + * Calls LED processing function + * + * @param xTimer timer that finished + */ + static void LightTimerEventHandler(TimerHandle_t xTimer); + + /** + * @brief Updates device LEDs + */ + static void LightEventHandler(); + + /********************************************************** + * Private Attributes declaration + *********************************************************/ + + enum Function_t + { + kFunction_NoneSelected = 0, + kFunction_SoftwareUpdate = 0, + kFunction_StartBleAdv = 1, + kFunction_FactoryReset = 2, + + kFunction_Invalid + } Function; + + Function_t mFunction; + bool mFunctionTimerActive; + bool mSyncClusterToButtonAction; + + static AppTask sAppTask; +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} diff --git a/examples/thermostat/efr32/include/CHIPProjectConfig.h b/examples/thermostat/efr32/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..5904b776cd601d --- /dev/null +++ b/examples/thermostat/efr32/include/CHIPProjectConfig.h @@ -0,0 +1,143 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * 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. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +// Use a default pairing code if one hasn't been provisioned in flash. +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#endif + +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif + +// For convenience, Chip Security Test Mode can be enabled and the +// requirement for authentication in various protocols can be disabled. +// +// WARNING: These options make it possible to circumvent basic Chip security functionality, +// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. +// +#define CHIP_CONFIG_SECURITY_TEST_MODE 0 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * + * 0xFFF1: Test vendor + */ +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID + * + * 0x8005: example lighting app + */ +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8004 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * + * A string identifying the software version running on the device. + * CHIP service currently expects the software version to be in the format + * {MAJOR_VERSION}.0d{MINOR_VERSION} + */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" +#endif + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + * + * A uint32_t identifying the software version running on the device. + */ +/* The SoftwareVersion attribute of the Basic cluster. */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001 +#endif + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + * + * Enable support for Chip-over-BLE (CHIPoBLE). + */ +#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 1 + +/** + * CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC + * + * Enables synchronizing the device's real time clock with a remote Chip Time service + * using the Chip Time Sync protocol. + */ +#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0 + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in Chip NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +/** + * CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS + * + * Enable recording UTC timestamps. + */ +#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1 + +/** + * CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE + * + * A size, in bytes, of the individual debug event logging buffer. + */ +#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) + +/** + * @def CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL + * + * @brief + * Active retransmit interval, or time to wait before retransmission after + * subsequent failures in milliseconds. + * + * This is the default value, that might be adjusted by end device depending on its + * needs (e.g. sleeping period) using Service Discovery TXT record CRA key. + * + */ +#define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (2000_ms32) + +#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 diff --git a/examples/thermostat/efr32/src/AppTask.cpp b/examples/thermostat/efr32/src/AppTask.cpp new file mode 100644 index 00000000000000..e972594d078d2d --- /dev/null +++ b/examples/thermostat/efr32/src/AppTask.cpp @@ -0,0 +1,643 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * 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. + */ + +/********************************************************** + * Includes + *********************************************************/ + +#include "AppTask.h" +#include "AppConfig.h" +#include "AppEvent.h" +#include "LEDWidget.h" +#include "sl_simple_led_instances.h" + +#ifdef DISPLAY_ENABLED +#include "lcd.h" +#ifdef QR_CODE_ENABLED +#include "qrcodegen.h" +#endif // QR_CODE_ENABLED +#endif // DISPLAY_ENABLED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if CHIP_ENABLE_OPENTHREAD +#include +#include +#include +#endif // CHIP_ENABLE_OPENTHREAD + +#ifdef SL_WIFI +#include "wfx_host_events.h" +#include +#include +#endif // SL_WIFI + +/********************************************************** + * Defines and Constants + *********************************************************/ + +#define FACTORY_RESET_TRIGGER_TIMEOUT 3000 +#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 +#define APP_TASK_STACK_SIZE (4096) +#define APP_TASK_PRIORITY 2 +#define APP_EVENT_QUEUE_SIZE 10 +#define EXAMPLE_VENDOR_ID 0xcafe + +#define SYSTEM_STATE_LED &sl_led_led0 + +#define APP_FUNCTION_BUTTON &sl_button_btn0 +#define APP_THERMOSTAT &sl_button_btn1 + +using namespace chip; +using namespace ::chip::DeviceLayer; + +namespace { + +/********************************************************** + * Variable declarations + *********************************************************/ + +TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. +TimerHandle_t sLightTimer; + +TaskHandle_t sAppTaskHandle; +QueueHandle_t sAppEventQueue; + +LEDWidget sStatusLED; + +#ifdef SL_WIFI +app::Clusters::NetworkCommissioning::Instance + sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::SlWiFiDriver::GetInstance())); +#endif /* SL_WIFI */ + +#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) + +bool sIsProvisioned = false; +bool sIsEnabled = false; +bool sIsAttached = false; +bool sHaveBLEConnections = false; + +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED + +EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; + +uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)]; +StaticQueue_t sAppEventQueueStruct; + +StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; +StaticTask_t appTaskStruct; + +/********************************************************** + * Identify Callbacks + *********************************************************/ + +namespace { +void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState) +{ + ChipLogProgress(Zcl, "Trigger Identify Complete"); + sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + GetAppTask().CancelLightTimer(); +#endif +} +} // namespace + +void OnTriggerIdentifyEffect(Identify * identify) +{ + ChipLogProgress(Zcl, "Trigger Identify Effect"); + sIdentifyEffect = identify->mCurrentEffectIdentifier; + + if (identify->mCurrentEffectIdentifier == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) + { + ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect varriant %d", + identify->mEffectVariant); + sIdentifyEffect = static_cast(identify->mEffectVariant); + } + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + GetAppTask().StartLightTimer(); +#endif + + switch (sIdentifyEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted, + identify); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); + (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted, + identify); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); + sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + } +} + +Identify gIdentify = { + chip::EndpointId{ 1 }, GetAppTask().OnIdentifyStart, + GetAppTask().OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnTriggerIdentifyEffect, +}; + +} // namespace + +using namespace chip::TLV; +using namespace ::chip::DeviceLayer; + +/********************************************************** + * AppTask Definitions + *********************************************************/ + +AppTask AppTask::sAppTask; + +CHIP_ERROR AppTask::StartAppTask() +{ + sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct); + if (sAppEventQueue == NULL) + { + EFR32_LOG("Failed to allocate app event queue"); + appError(APP_ERROR_EVENT_QUEUE_FAILED); + } + + // Start App task. + sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct); + if (sAppTaskHandle == nullptr) + { + EFR32_LOG("Failed to create app task"); + appError(APP_ERROR_CREATE_TASK_FAILED); + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR AppTask::Init() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + +#ifdef SL_WIFI + /* + * Wait for the WiFi to be initialized + */ + EFR32_LOG("APP: Wait WiFi Init"); + while (!wfx_hw_ready()) + { + vTaskDelay(10); + } + EFR32_LOG("APP: Done WiFi Init"); + /* We will init server when we get IP */ + + sWiFiNetworkCommissioningInstance.Init(); +#endif + + // Create FreeRTOS sw timer for Function Selection. + sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel + 1, // == default timer period (mS) + false, // no timer reload (==one-shot) + (void *) this, // init timer id = app task obj context + FunctionTimerEventHandler // timer callback handler + ); + if (sFunctionTimer == NULL) + { + EFR32_LOG("funct timer create failed"); + appError(APP_ERROR_CREATE_TIMER_FAILED); + } + + // Create FreeRTOS sw timer for LED Management. + sLightTimer = xTimerCreate("LightTmr", // Text Name + 10, // Default timer period (mS) + true, // reload timer + (void *) this, // Timer Id + LightTimerEventHandler // Timer callback handler + ); + if (sLightTimer == NULL) + { + EFR32_LOG("Light Timer create failed"); + appError(APP_ERROR_CREATE_TIMER_FAILED); + } + + EFR32_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + + LEDWidget::InitGpio(); + sStatusLED.Init(SYSTEM_STATE_LED); + + ConfigurationMgr().LogDeviceConfig(); + +// Print setup info on LCD if available +#ifdef QR_CODE_ENABLED + // Create buffer for QR code that can fit max size and null terminator. + char qrCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; + chip::MutableCharSpan QRCode(qrCodeBuffer); + + if (GetQRCode(QRCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR) + { + LCDWriteQRCode((uint8_t *) QRCode.data()); + } + else + { + EFR32_LOG("Getting QR code failed!"); + } +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#endif // QR_CODE_ENABLED + + return err; +} + +void AppTask::AppTaskMain(void * pvParameter) +{ + AppEvent event; + + CHIP_ERROR err = sAppTask.Init(); + if (err != CHIP_NO_ERROR) + { + EFR32_LOG("AppTask.Init() failed"); + appError(err); + } + +#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) + sAppTask.StartLightTimer(); +#endif + + EFR32_LOG("App Task started"); + while (true) + { + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY); + while (eventReceived == pdTRUE) + { + sAppTask.DispatchEvent(&event); + eventReceived = xQueueReceive(sAppEventQueue, &event, 0); + } + } +} + +void AppTask::OnIdentifyStart(Identify * identify) +{ + ChipLogProgress(Zcl, "onIdentifyStart"); + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + sAppTask.StartLightTimer(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED +} + +void AppTask::OnIdentifyStop(Identify * identify) +{ + ChipLogProgress(Zcl, "onIdentifyStop"); + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + sAppTask.CancelLightTimer(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED +} + +void AppTask::ThermostatActionEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_Button) + { + EFR32_LOG("App Button was pressed!"); + // TODO: Implement button functionnality + } +} + +void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) +{ + if (buttonHandle == NULL) + { + return; + } + + AppEvent button_event = {}; + button_event.Type = AppEvent::kEventType_Button; + button_event.ButtonEvent.Action = btnAction; + + if (buttonHandle == APP_THERMOSTAT && btnAction == SL_SIMPLE_BUTTON_PRESSED) + { + button_event.Handler = ThermostatActionEventHandler; + sAppTask.PostEvent(&button_event); + } + else if (buttonHandle == APP_FUNCTION_BUTTON) + { + button_event.Handler = ButtonHandler; + sAppTask.PostEvent(&button_event); + } +} + +void AppTask::FunctionTimerEventHandler(TimerHandle_t xTimer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.TimerEvent.Context = (void *) xTimer; + event.Handler = FunctionEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::LightTimerEventHandler(TimerHandle_t xTimer) +{ + sAppTask.LightEventHandler(); +} + +void AppTask::FunctionEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT, + // initiate factory reset + if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv) + { + EFR32_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); + + // Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to + // cancel, if required. + sAppTask.StartFunctionTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + sAppTask.StartLightTimer(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED + + sAppTask.mFunction = kFunction_FactoryReset; + + // Turn off all LEDs before starting blink to make sure blink is + // co-ordinated. + sStatusLED.Set(false); + sStatusLED.Blink(500); + } + else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset) + { + // Actually trigger Factory Reset + sAppTask.mFunction = kFunction_NoneSelected; + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + sAppTask.CancelLightTimer(); +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED + + chip::Server::GetInstance().ScheduleFactoryReset(); + } +} + +void AppTask::LightEventHandler() +{ + // Collect connectivity and configuration state from the CHIP stack. Because + // the CHIP event loop is being run in a separate task, the stack must be + // locked while these values are queried. However we use a non-blocking + // lock request (TryLockCHIPStack()) to avoid blocking other UI activities + // when the CHIP task is busy (e.g. with a long crypto operation). +#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) + if (PlatformMgr().TryLockChipStack()) + { +#ifdef SL_WIFI + sIsProvisioned = ConnectivityMgr().IsWiFiStationProvisioned(); + sIsEnabled = ConnectivityMgr().IsWiFiStationEnabled(); + sIsAttached = ConnectivityMgr().IsWiFiStationConnected(); +#endif /* SL_WIFI */ +#if CHIP_ENABLE_OPENTHREAD + sIsProvisioned = ConnectivityMgr().IsThreadProvisioned(); + sIsEnabled = ConnectivityMgr().IsThreadEnabled(); + sIsAttached = ConnectivityMgr().IsThreadAttached(); +#endif /* CHIP_ENABLE_OPENTHREAD */ + sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); + PlatformMgr().UnlockChipStack(); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED + + // Update the status LED if factory reset has not been initiated. + // + // If system has "full connectivity", keep the LED On constantly. + // + // If thread and service provisioned, but not attached to the thread network + // yet OR no connectivity to the service OR subscriptions are not fully + // established THEN blink the LED Off for a short period of time. + // + // If the system has ble connection(s) uptill the stage above, THEN blink + // the LEDs at an even rate of 100ms. + // + // Otherwise, blink the LED ON for a very short time. + if (sAppTask.mFunction != kFunction_FactoryReset) + { + if (gIdentify.mActive) + { + sStatusLED.Blink(250, 250); + } + else if (sIdentifyEffect != EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) + { + if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) + { + sStatusLED.Blink(50, 50); + } + if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) + { + sStatusLED.Blink(1000, 1000); + } + if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) + { + sStatusLED.Blink(300, 700); + } + } +#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) + else if (sIsProvisioned && sIsEnabled) + { + if (sIsAttached) + { + sStatusLED.Set(true); + } + else + { + sStatusLED.Blink(950, 50); + } + } + else if (sHaveBLEConnections) + { + sStatusLED.Blink(100, 100); + } + else + { + sStatusLED.Blink(50, 950); + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED + } + + sStatusLED.Animate(); +} + +void AppTask::ButtonHandler(AppEvent * aEvent) +{ + // To trigger software update: press the APP_FUNCTION_BUTTON button briefly (< + // FACTORY_RESET_TRIGGER_TIMEOUT) To initiate factory reset: press the + // APP_FUNCTION_BUTTON for FACTORY_RESET_TRIGGER_TIMEOUT + + // FACTORY_RESET_CANCEL_WINDOW_TIMEOUT All LEDs start blinking after + // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. + // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs + // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT + if (aEvent->ButtonEvent.Action == SL_SIMPLE_BUTTON_PRESSED) + { + if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected) + { + sAppTask.StartFunctionTimer(FACTORY_RESET_TRIGGER_TIMEOUT); + sAppTask.mFunction = kFunction_StartBleAdv; + } + } + else + { + // If the button was released before factory reset got initiated, start BLE advertissement in fast mode + if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv) + { + sAppTask.CancelFunctionTimer(); + sAppTask.mFunction = kFunction_NoneSelected; + +#ifdef SL_WIFI + if (!ConnectivityMgr().IsWiFiStationProvisioned()) +#else + if (!ConnectivityMgr().IsThreadProvisioned()) +#endif /* !SL_WIFI */ + { + // Enable BLE advertisements + ConnectivityMgr().SetBLEAdvertisingEnabled(true); + ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising); + } + else { EFR32_LOG("Network is already provisioned, Ble advertissement not enabled"); } + } + else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset) + { + sAppTask.CancelFunctionTimer(); + +#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 + sAppTask.CancelLightTimer(); +#endif + + // Change the function to none selected since factory reset has been + // canceled. + sAppTask.mFunction = kFunction_NoneSelected; + EFR32_LOG("Factory Reset has been Canceled"); + } + } +} + +void AppTask::CancelFunctionTimer() +{ + if (xTimerStop(sFunctionTimer, 0) == pdFAIL) + { + EFR32_LOG("app timer stop() failed"); + appError(APP_ERROR_STOP_TIMER_FAILED); + } + + mFunctionTimerActive = false; +} + +void AppTask::CancelLightTimer() +{ + sStatusLED.Set(false); + if (xTimerStop(sLightTimer, 100) != pdPASS) + { + EFR32_LOG("Light Time start failed"); + appError(APP_ERROR_START_TIMER_FAILED); + } +} + +void AppTask::StartFunctionTimer(uint32_t aTimeoutInMs) +{ + if (xTimerIsTimerActive(sFunctionTimer)) + { + EFR32_LOG("app timer already started!"); + CancelFunctionTimer(); + } + + // timer is not active, change its period to required value (== restart). + // FreeRTOS- Block for a maximum of 100 ticks if the change period command + // cannot immediately be sent to the timer command queue. + if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS) + { + EFR32_LOG("app timer start() failed"); + appError(APP_ERROR_START_TIMER_FAILED); + } + + mFunctionTimerActive = true; +} + +void AppTask::StartLightTimer() +{ + if (pdPASS != xTimerStart(sLightTimer, 0)) + { + EFR32_LOG("Light Time start failed"); + appError(APP_ERROR_START_TIMER_FAILED); + } +} + +void AppTask::PostEvent(const AppEvent * aEvent) +{ + if (sAppEventQueue != NULL) + { + BaseType_t status; + if (xPortIsInsideInterrupt()) + { + BaseType_t higherPrioTaskWoken = pdFALSE; + status = xQueueSendFromISR(sAppEventQueue, aEvent, &higherPrioTaskWoken); + +#ifdef portYIELD_FROM_ISR + portYIELD_FROM_ISR(higherPrioTaskWoken); +#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR + portEND_SWITCHING_ISR(higherPrioTaskWoken); +#else // portYIELD_FROM_ISR or portEND_SWITCHING_ISR +#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" +#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR + } + else + { + status = xQueueSend(sAppEventQueue, aEvent, 1); + } + + if (!status) + { + EFR32_LOG("Failed to post event to app task event queue"); + } + } + else + { + EFR32_LOG("Event Queue is NULL should never happen"); + } +} + +void AppTask::DispatchEvent(AppEvent * aEvent) +{ + if (aEvent->Handler) + { + aEvent->Handler(aEvent); + } + else + { + EFR32_LOG("Event received with no handler. Dropping event."); + } +} diff --git a/examples/thermostat/efr32/src/ZclCallbacks.cpp b/examples/thermostat/efr32/src/ZclCallbacks.cpp new file mode 100644 index 00000000000000..f89d4aaa8cd581 --- /dev/null +++ b/examples/thermostat/efr32/src/ZclCallbacks.cpp @@ -0,0 +1,65 @@ +/* + * + * 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. + */ + +/** + * @file + * This file implements the handler for data model messages. + */ + +#include "AppConfig.h" + +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == Identify::Id) + { + ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", + ChipLogValueMEI(attributeId), type, *value, size); + } +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // TODO: implement any additional Cluster Server init actions +} diff --git a/examples/thermostat/efr32/src/main.cpp b/examples/thermostat/efr32/src/main.cpp new file mode 100644 index 00000000000000..e06d3c4a520416 --- /dev/null +++ b/examples/thermostat/efr32/src/main.cpp @@ -0,0 +1,84 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * All rights reserved. + * + * 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. + */ + +#include + +#include "AppConfig.h" +#include "init_efrPlatform.h" +#include "sl_simple_button_instances.h" +#include "sl_system_kernel.h" +#include +#include +#include +#include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif + +#define BLE_DEV_NAME "SiLabs-Thermostat" +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; + +#define UNUSED_PARAMETER(a) (a = a) + +volatile int apperror_cnt; +static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; + +// ================================================================================ +// Main Code +// ================================================================================ +int main(void) +{ + init_efrPlatform(); + if (EFR32MatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) + appError(CHIP_ERROR_INTERNAL); + + gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + + chip::DeviceLayer::PlatformMgr().LockChipStack(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + + EFR32_LOG("Starting App Task"); + if (GetAppTask().StartAppTask() != CHIP_NO_ERROR) + appError(CHIP_ERROR_INTERNAL); + + EFR32_LOG("Starting FreeRTOS scheduler"); + sl_system_kernel_start(); + + // Should never get here. + chip::Platform::MemoryShutdown(); + EFR32_LOG("vTaskStartScheduler() failed"); + appError(CHIP_ERROR_INTERNAL); +} + +void sl_button_on_change(const sl_button_t * handle) +{ + GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); +} diff --git a/examples/thermostat/efr32/third_party/connectedhomeip b/examples/thermostat/efr32/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/thermostat/efr32/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index d7c8994b4e1177..0057c256956e49 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -382,7 +382,7 @@ server cluster Basic = 40 { readonly attribute int16u clusterRevision = 65533; } -server cluster OtaSoftwareUpdateProvider = 41 { +client cluster OtaSoftwareUpdateProvider = 41 { enum OTAApplyUpdateAction : ENUM8 { kProceed = 0; kAwaitNextAction = 1; @@ -448,6 +448,76 @@ server cluster OtaSoftwareUpdateProvider = 41 { command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; } +server cluster OtaSoftwareUpdateRequestor = 42 { + enum OTAAnnouncementReason : ENUM8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum OTAChangeReasonEnum : ENUM8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum OTAUpdateStateEnum : ENUM8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + OTAUpdateStateEnum previousState = 0; + OTAUpdateStateEnum newState = 1; + OTAChangeReasonEnum reason = 2; + nullable INT32U targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + INT32U softwareVersion = 0; + INT16U productID = 1; + } + + info event DownloadError = 2 { + INT32U softwareVersion = 0; + INT64U bytesDownloaded = 1; + nullable INT8U progressPercent = 2; + nullable INT64S platformCode = 3; + } + + attribute ProviderLocation defaultOtaProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute OTAUpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOtaProviderRequest { + node_id providerNodeId = 0; + vendor_id vendorId = 1; + OTAAnnouncementReason announcementReason = 2; + optional OCTET_STRING metadataForNode = 3; + endpoint_no endpoint = 4; + } + + command AnnounceOtaProvider(AnnounceOtaProviderRequest): DefaultSuccess = 0; +} + server cluster LocalizationConfiguration = 43 { attribute char_string<35> activeLocale = 0; readonly attribute CHAR_STRING supportedLocales[] = 1; @@ -1384,6 +1454,7 @@ server cluster Thermostat = 513 { endpoint 0 { device type rootdevice = 22; + binding cluster OtaSoftwareUpdateProvider; server cluster Identify { ram attribute identifyTime; @@ -1442,7 +1513,11 @@ endpoint 0 { ram attribute clusterRevision default = 1; } - server cluster OtaSoftwareUpdateProvider { + server cluster OtaSoftwareUpdateRequestor { + callback attribute defaultOtaProviders; + ram attribute updatePossible default = 1; + ram attribute updateState; + ram attribute updateStateProgress; ram attribute featureMap; ram attribute clusterRevision default = 1; } diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index 9edc45595ef358..fb63b21736f0c1 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -1,5 +1,5 @@ { - "featureLevel": 71, + "featureLevel": 76, "creator": "zap", "keyValuePairs": [ { @@ -19,14 +19,16 @@ { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl.json", - "version": "ZCL Test Data", - "type": "zcl-properties" + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/app-templates.json", - "version": "chip-v1", - "type": "gen-templates-json" + "type": "gen-templates-json", + "version": "chip-v1" } ], "endpointTypes": [ @@ -79,7 +81,6 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "identify time", @@ -582,7 +583,6 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "OnOff", @@ -717,7 +717,6 @@ "define": "LEVEL_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "current level", @@ -760,7 +759,6 @@ "define": "DESCRIPTOR_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -787,7 +785,6 @@ "define": "DESCRIPTOR_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "device list", @@ -894,7 +891,6 @@ "define": "BINDING_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -921,7 +917,6 @@ "define": "BINDING_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "Binding", @@ -979,9 +974,7 @@ "mfgCode": null, "define": "ACCESS_CONTROL_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "Access Control", @@ -990,7 +983,6 @@ "define": "ACCESS_CONTROL_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "ACL", @@ -1129,7 +1121,6 @@ "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -1156,7 +1147,6 @@ "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "DataModelRevision", @@ -1518,7 +1508,7 @@ "mfgCode": null, "define": "OTA_PROVIDER_CLUSTER", "side": "client", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "QueryImage", @@ -1542,7 +1532,7 @@ "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 + "outgoing": 1 } ], "attributes": [ @@ -1570,14 +1560,14 @@ "mfgCode": null, "define": "OTA_PROVIDER_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "QueryImageResponse", "code": 1, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -1624,15 +1614,219 @@ } ] }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AnnounceOtaProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "OTAUpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Localization Configuration", "code": 43, "mfgCode": null, "define": "LOCALIZATION_CONFIGURATION_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "Localization Configuration", @@ -1641,7 +1835,6 @@ "define": "LOCALIZATION_CONFIGURATION_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "ActiveLocale", @@ -1715,9 +1908,7 @@ "mfgCode": null, "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "Time Format Localization", @@ -1726,7 +1917,6 @@ "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "HourFormat", @@ -1816,9 +2006,7 @@ "mfgCode": null, "define": "UNIT_LOCALIZATION_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "Unit Localization", @@ -1827,7 +2015,6 @@ "define": "UNIT_LOCALIZATION_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "TemperatureUnit", @@ -2410,7 +2597,6 @@ "define": "GENERAL_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -2669,7 +2855,6 @@ "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "ThreadMetrics", @@ -2776,7 +2961,6 @@ "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "channel", @@ -3827,7 +4011,6 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -3854,7 +4037,6 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "bssid", @@ -4141,7 +4323,6 @@ "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "PHYRate", @@ -4328,7 +4509,6 @@ "define": "SWITCH_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -4355,7 +4535,6 @@ "define": "SWITCH_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "number of positions", @@ -4482,7 +4661,6 @@ "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "WindowStatus", @@ -4837,7 +5015,6 @@ "define": "GROUP_KEY_MANAGEMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -4864,7 +5041,6 @@ "define": "GROUP_KEY_MANAGEMENT_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "GroupKeyMap", @@ -4938,9 +5114,7 @@ "mfgCode": null, "define": "FIXED_LABEL_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "Fixed Label", @@ -4949,7 +5123,6 @@ "define": "FIXED_LABEL_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "label list", @@ -5007,9 +5180,7 @@ "mfgCode": null, "define": "USER_LABEL_CLUSTER", "side": "client", - "enabled": 0, - "commands": [], - "attributes": [] + "enabled": 0 }, { "name": "User Label", @@ -5018,7 +5189,6 @@ "define": "USER_LABEL_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "label list", @@ -5201,7 +5371,6 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "LockState", @@ -5560,7 +5729,6 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "barrier moving state", @@ -5791,7 +5959,6 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "CurrentHue", @@ -6618,7 +6785,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -6645,7 +6811,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MeasuredValue", @@ -6736,7 +6901,6 @@ "define": "RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -6763,7 +6927,6 @@ "define": "RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "measured value", @@ -6847,166 +7010,6 @@ } ] }, - { - "name": "IAS Zone", - "code": 1280, - "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ZoneEnrollResponse", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "IAS Zone", - "code": 1280, - "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "ZoneStatusChangeNotification", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ZoneEnrollRequest", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "zone state", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "enum8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "zone type", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "enum16", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "zone status", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "bitmap16", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "IAS CIE address", - "code": 16, - "mfgCode": null, - "side": "server", - "type": "node_id", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Zone ID", - "code": 17, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xff", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Test Cluster", "code": 4294048773, @@ -7450,7 +7453,6 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "identify time", @@ -8001,7 +8003,6 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "OnOff", @@ -8216,7 +8217,6 @@ "define": "LEVEL_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "current level", @@ -8467,7 +8467,6 @@ "define": "BINARY_INPUT_BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -8494,7 +8493,6 @@ "define": "BINARY_INPUT_BASIC_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "out of service", @@ -8569,7 +8567,6 @@ "define": "DESCRIPTOR_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -8596,7 +8593,6 @@ "define": "DESCRIPTOR_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "device list", @@ -8687,7 +8683,6 @@ "define": "BINDING_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -8714,7 +8709,6 @@ "define": "BINDING_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "Binding", @@ -8757,7 +8751,6 @@ "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -8784,7 +8777,6 @@ "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "DataModelRevision", @@ -9227,7 +9219,6 @@ "define": "OTA_REQUESTOR_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -9254,7 +9245,6 @@ "define": "OTA_REQUESTOR_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -9537,7 +9527,6 @@ "define": "SWITCH_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -9564,7 +9553,6 @@ "define": "SWITCH_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "number of positions", @@ -9639,7 +9627,6 @@ "define": "GROUP_KEY_MANAGEMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -9666,7 +9653,6 @@ "define": "GROUP_KEY_MANAGEMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "GroupKeyMap", @@ -9725,7 +9711,6 @@ "define": "FIXED_LABEL_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -9752,7 +9737,6 @@ "define": "FIXED_LABEL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "label list", @@ -9919,7 +9903,6 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "LockState", @@ -10318,7 +10301,6 @@ "define": "WINDOW_COVERING_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "Type", @@ -10421,7 +10403,7 @@ "code": 10, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "OperationalStatus", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -10597,7 +10579,7 @@ "code": 26, "mfgCode": null, "side": "server", - "type": "bitmap16", + "type": "SafetyStatus", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -10677,7 +10659,6 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "barrier moving state", @@ -10768,7 +10749,6 @@ "define": "PUMP_CONFIG_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -10795,7 +10775,6 @@ "define": "PUMP_CONFIG_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MaxPressure", @@ -11506,7 +11485,6 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "CurrentHue", @@ -12333,7 +12311,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -12360,7 +12337,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MeasuredValue", @@ -12451,7 +12427,6 @@ "define": "PRESSURE_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -12478,7 +12453,6 @@ "define": "PRESSURE_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MeasuredValue", @@ -12601,7 +12575,6 @@ "define": "FLOW_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -12628,7 +12601,6 @@ "define": "FLOW_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MeasuredValue", @@ -12703,7 +12675,6 @@ "define": "RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -12730,7 +12701,6 @@ "define": "RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "measured value", @@ -12814,166 +12784,6 @@ } ] }, - { - "name": "IAS Zone", - "code": 1280, - "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ZoneEnrollResponse", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "IAS Zone", - "code": 1280, - "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "ZoneStatusChangeNotification", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ZoneEnrollRequest", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "zone state", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "enum8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "zone type", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "enum16", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "zone status", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "bitmap16", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "IAS CIE address", - "code": 16, - "mfgCode": null, - "side": "server", - "type": "node_id", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Zone ID", - "code": 17, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xff", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Wake on LAN", "code": 1283, @@ -12981,7 +12791,6 @@ "define": "WAKE_ON_LAN_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -13008,7 +12817,6 @@ "define": "WAKE_ON_LAN_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "MACAddress", @@ -13095,7 +12903,6 @@ "define": "CHANNEL_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ChannelList", @@ -13206,7 +13013,6 @@ "define": "TARGET_NAVIGATOR_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "TargetList", @@ -13357,7 +13163,6 @@ "define": "MEDIA_PLAYBACK_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -13444,7 +13249,6 @@ "define": "MEDIA_INPUT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "InputList", @@ -13523,7 +13327,6 @@ "define": "LOW_POWER_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -13586,7 +13389,6 @@ "define": "KEYPAD_INPUT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -13657,7 +13459,6 @@ "define": "CONTENT_LAUNCH_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "AcceptHeader", @@ -13760,7 +13561,6 @@ "define": "AUDIO_OUTPUT_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "OutputList", @@ -13839,7 +13639,6 @@ "define": "APPLICATION_LAUNCHER_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "CatalogList", @@ -13882,7 +13681,6 @@ "define": "APPLICATION_BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -13909,7 +13707,6 @@ "define": "APPLICATION_BASIC_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "VendorName", @@ -14068,7 +13865,6 @@ "define": "ACCOUNT_LOGIN_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "ClusterRevision", @@ -14510,5 +14306,6 @@ "endpointVersion": 1, "deviceIdentifier": 769 } - ] -} + ], + "log": [] +} \ No newline at end of file diff --git a/zzz_generated/thermostat/zap-generated/CHIPClusters.h b/zzz_generated/thermostat/zap-generated/CHIPClusters.h index e91d09cd512a65..508098f8d0ddbb 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClusters.h +++ b/zzz_generated/thermostat/zap-generated/CHIPClusters.h @@ -39,5 +39,15 @@ class DLL_EXPORT IdentifyCluster : public ClusterBase ~IdentifyCluster() {} }; +class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase +{ +public: + OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, + EndpointId endpoint) : + ClusterBase(exchangeManager, session, app::Clusters::OtaSoftwareUpdateProvider::Id, endpoint) + {} + ~OtaSoftwareUpdateProviderCluster() {} +}; + } // namespace Controller } // namespace chip diff --git a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp index 3e268d6de55364..b78b0406165309 100644 --- a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp @@ -432,7 +432,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace NetworkCommissioning -namespace OtaSoftwareUpdateProvider { +namespace OtaSoftwareUpdateRequestor { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { @@ -441,32 +441,13 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP { switch (aCommandPath.mCommandId) { - case Commands::QueryImage::Id: { - Commands::QueryImage::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::ApplyUpdateRequest::Id: { - Commands::ApplyUpdateRequest::DecodableType commandData; - TLVError = DataModel::Decode(aDataTlv, commandData); - if (TLVError == CHIP_NO_ERROR) - { - wasHandled = - emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback(apCommandObj, aCommandPath, commandData); - } - break; - } - case Commands::NotifyUpdateApplied::Id: { - Commands::NotifyUpdateApplied::DecodableType commandData; + case Commands::AnnounceOtaProvider::Id: { + Commands::AnnounceOtaProvider::DecodableType commandData; TLVError = DataModel::Decode(aDataTlv, commandData); if (TLVError == CHIP_NO_ERROR) { wasHandled = - emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback(apCommandObj, aCommandPath, commandData); + emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback(apCommandObj, aCommandPath, commandData); } break; } @@ -487,7 +468,7 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } } -} // namespace OtaSoftwareUpdateProvider +} // namespace OtaSoftwareUpdateRequestor namespace OperationalCredentials { @@ -776,8 +757,8 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: case Clusters::NetworkCommissioning::Id: Clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + case Clusters::OtaSoftwareUpdateRequestor::Id: + Clusters::OtaSoftwareUpdateRequestor::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; case Clusters::OperationalCredentials::Id: Clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandPath, aReader); diff --git a/zzz_generated/thermostat/zap-generated/PluginApplicationCallbacks.h b/zzz_generated/thermostat/zap-generated/PluginApplicationCallbacks.h index 2b513eb1c033c0..fc1f15a7696df2 100644 --- a/zzz_generated/thermostat/zap-generated/PluginApplicationCallbacks.h +++ b/zzz_generated/thermostat/zap-generated/PluginApplicationCallbacks.h @@ -30,7 +30,8 @@ MatterBindingPluginServerInitCallback(); \ MatterAccessControlPluginServerInitCallback(); \ MatterBasicPluginServerInitCallback(); \ - MatterOtaSoftwareUpdateProviderPluginServerInitCallback(); \ + MatterOtaSoftwareUpdateProviderPluginClientInitCallback(); \ + MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(); \ MatterLocalizationConfigurationPluginServerInitCallback(); \ MatterTimeFormatLocalizationPluginServerInitCallback(); \ MatterUnitLocalizationPluginServerInitCallback(); \ diff --git a/zzz_generated/thermostat/zap-generated/callback-stub.cpp b/zzz_generated/thermostat/zap-generated/callback-stub.cpp index bbce02b0dbd3a7..46ed91ffbe0fef 100644 --- a/zzz_generated/thermostat/zap-generated/callback-stub.cpp +++ b/zzz_generated/thermostat/zap-generated/callback-stub.cpp @@ -77,6 +77,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_OTA_PROVIDER_CLUSTER_ID: emberAfOtaSoftwareUpdateProviderClusterInitCallback(endpoint); break; + case ZCL_OTA_REQUESTOR_CLUSTER_ID: + emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint); + break; case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID: emberAfOperationalCredentialsClusterInitCallback(endpoint); break; @@ -190,6 +193,11 @@ void __attribute__((weak)) emberAfOtaSoftwareUpdateProviderClusterInitCallback(E // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfOtaSoftwareUpdateRequestorClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOperationalCredentialsClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/zzz_generated/thermostat/zap-generated/endpoint_config.h b/zzz_generated/thermostat/zap-generated/endpoint_config.h index 9a7871ad6eaeb8..90fa07b92048fe 100644 --- a/zzz_generated/thermostat/zap-generated/endpoint_config.h +++ b/zzz_generated/thermostat/zap-generated/endpoint_config.h @@ -104,7 +104,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 260 +#define GENERATED_ATTRIBUTE_COUNT 264 #define GENERATED_ATTRIBUTES \ { \ \ @@ -186,9 +186,14 @@ { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ \ - /* Endpoint: 0, Cluster: OTA Software Update Provider (server) */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* DefaultOtaProviders */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* UpdatePossible */ \ + { 0x00000002, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0) }, /* UpdateState */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0) }, /* UpdateStateProgress */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Localization Configuration (server) */ \ { 0x00000000, ZAP_TYPE(CHAR_STRING), 36, ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ @@ -588,29 +593,23 @@ /* AcceptedCommandList (index=0) */ \ 0x00000000 /* Identify */, \ chip::kInvalidCommandId /* end of list */, \ - /* Endpoint: 0, Cluster: OTA Software Update Provider (server) */\ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */\ /* AcceptedCommandList (index=2) */ \ - 0x00000000 /* QueryImage */, \ - 0x00000002 /* ApplyUpdateRequest */, \ - 0x00000004 /* NotifyUpdateApplied */, \ - chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=6)*/ \ - 0x00000001 /* QueryImageResponse */, \ - 0x00000003 /* ApplyUpdateResponse */, \ + 0x00000000 /* AnnounceOtaProvider */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: General Commissioning (server) */\ - /* AcceptedCommandList (index=9) */ \ + /* AcceptedCommandList (index=4) */ \ 0x00000000 /* ArmFailSafe */, \ 0x00000002 /* SetRegulatoryConfig */, \ 0x00000004 /* CommissioningComplete */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=13)*/ \ + /* GeneratedCommandList (index=8)*/ \ 0x00000001 /* ArmFailSafeResponse */, \ 0x00000003 /* SetRegulatoryConfigResponse */, \ 0x00000005 /* CommissioningCompleteResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: Network Commissioning (server) */\ - /* AcceptedCommandList (index=17) */ \ + /* AcceptedCommandList (index=12) */ \ 0x00000000 /* ScanNetworks */, \ 0x00000002 /* AddOrUpdateWiFiNetwork */, \ 0x00000003 /* AddOrUpdateThreadNetwork */, \ @@ -618,30 +617,30 @@ 0x00000006 /* ConnectNetwork */, \ 0x00000008 /* ReorderNetwork */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=24)*/ \ + /* GeneratedCommandList (index=19)*/ \ 0x00000001 /* ScanNetworksResponse */, \ 0x00000005 /* NetworkConfigResponse */, \ 0x00000007 /* ConnectNetworkResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: Diagnostic Logs (server) */\ - /* AcceptedCommandList (index=28) */ \ + /* AcceptedCommandList (index=23) */ \ 0x00000000 /* RetrieveLogsRequest */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=30)*/ \ + /* GeneratedCommandList (index=25)*/ \ 0x00000001 /* RetrieveLogsResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: General Diagnostics (server) */\ - /* AcceptedCommandList (index=32) */ \ + /* AcceptedCommandList (index=27) */ \ 0x00000000 /* TestEventTrigger */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */\ - /* AcceptedCommandList (index=34) */ \ + /* AcceptedCommandList (index=29) */ \ 0x00000000 /* OpenCommissioningWindow */, \ 0x00000001 /* OpenBasicCommissioningWindow */, \ 0x00000002 /* RevokeCommissioning */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 0, Cluster: Operational Credentials (server) */\ - /* AcceptedCommandList (index=38) */ \ + /* AcceptedCommandList (index=33) */ \ 0x00000000 /* AttestationRequest */, \ 0x00000002 /* CertificateChainRequest */, \ 0x00000004 /* CSRRequest */, \ @@ -651,18 +650,18 @@ 0x0000000A /* RemoveFabric */, \ 0x0000000B /* AddTrustedRootCertificate */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=47)*/ \ + /* GeneratedCommandList (index=42)*/ \ 0x00000001 /* AttestationResponse */, \ 0x00000003 /* CertificateChainResponse */, \ 0x00000005 /* CSRResponse */, \ 0x00000008 /* NOCResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: Identify (server) */\ - /* AcceptedCommandList (index=52) */ \ + /* AcceptedCommandList (index=47) */ \ 0x00000000 /* Identify */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: Groups (server) */\ - /* AcceptedCommandList (index=54) */ \ + /* AcceptedCommandList (index=49) */ \ 0x00000000 /* AddGroup */, \ 0x00000001 /* ViewGroup */, \ 0x00000002 /* GetGroupMembership */, \ @@ -670,14 +669,14 @@ 0x00000004 /* RemoveAllGroups */, \ 0x00000005 /* AddGroupIfIdentifying */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=61)*/ \ + /* GeneratedCommandList (index=56)*/ \ 0x00000000 /* AddGroupResponse */, \ 0x00000001 /* ViewGroupResponse */, \ 0x00000002 /* GetGroupMembershipResponse */, \ 0x00000003 /* RemoveGroupResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: Scenes (server) */\ - /* AcceptedCommandList (index=66) */ \ + /* AcceptedCommandList (index=61) */ \ 0x00000000 /* AddScene */, \ 0x00000001 /* ViewScene */, \ 0x00000002 /* RemoveScene */, \ @@ -686,7 +685,7 @@ 0x00000005 /* RecallScene */, \ 0x00000006 /* GetSceneMembership */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=74)*/ \ + /* GeneratedCommandList (index=69)*/ \ 0x00000000 /* AddSceneResponse */, \ 0x00000001 /* ViewSceneResponse */, \ 0x00000002 /* RemoveSceneResponse */, \ @@ -695,13 +694,13 @@ 0x00000006 /* GetSceneMembershipResponse */, \ chip::kInvalidCommandId /* end of list */, \ /* Endpoint: 1, Cluster: Thermostat (server) */\ - /* AcceptedCommandList (index=81) */ \ + /* AcceptedCommandList (index=76) */ \ 0x00000000 /* SetpointRaiseLower */, \ 0x00000001 /* SetWeeklySchedule */, \ 0x00000002 /* GetWeeklySchedule */, \ 0x00000003 /* ClearWeeklySchedule */, \ chip::kInvalidCommandId /* end of list */, \ - /* GeneratedCommandList (index=86)*/ \ + /* GeneratedCommandList (index=81)*/ \ 0x00000000 /* GetWeeklyScheduleResponse */, \ chip::kInvalidCommandId /* end of list */, \ } @@ -709,7 +708,7 @@ // clang-format on #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 28 +#define GENERATED_CLUSTER_COUNT 29 // clang-format off #define GENERATED_CLUSTERS { \ @@ -769,20 +768,31 @@ .generatedCommandList = nullptr ,\ },\ { \ - /* Endpoint: 0, Cluster: OTA Software Update Provider (server) */ \ + /* Endpoint: 0, Cluster: OTA Software Update Provider (client) */ \ .clusterId = 0x00000029, \ .attributes = ZAP_ATTRIBUTE_INDEX(41), \ - .attributeCount = 2, \ - .clusterSize = 6, \ + .attributeCount = 0, \ + .clusterSize = 0, \ + .mask = ZAP_CLUSTER_MASK(CLIENT), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + .clusterId = 0x0000002A, \ + .attributes = ZAP_ATTRIBUTE_INDEX(41), \ + .attributeCount = 6, \ + .clusterSize = 9, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 2 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 6 ) ,\ + .generatedCommandList = nullptr ,\ },\ { \ /* Endpoint: 0, Cluster: Localization Configuration (server) */ \ .clusterId = 0x0000002B, \ - .attributes = ZAP_ATTRIBUTE_INDEX(43), \ + .attributes = ZAP_ATTRIBUTE_INDEX(47), \ .attributeCount = 4, \ .clusterSize = 42, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ @@ -793,7 +803,7 @@ { \ /* Endpoint: 0, Cluster: Time Format Localization (server) */ \ .clusterId = 0x0000002C, \ - .attributes = ZAP_ATTRIBUTE_INDEX(47), \ + .attributes = ZAP_ATTRIBUTE_INDEX(51), \ .attributeCount = 5, \ .clusterSize = 8, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ @@ -804,7 +814,7 @@ { \ /* Endpoint: 0, Cluster: Unit Localization (server) */ \ .clusterId = 0x0000002D, \ - .attributes = ZAP_ATTRIBUTE_INDEX(52), \ + .attributes = ZAP_ATTRIBUTE_INDEX(56), \ .attributeCount = 3, \ .clusterSize = 7, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -815,51 +825,51 @@ { \ /* Endpoint: 0, Cluster: General Commissioning (server) */ \ .clusterId = 0x00000030, \ - .attributes = ZAP_ATTRIBUTE_INDEX(55), \ + .attributes = ZAP_ATTRIBUTE_INDEX(59), \ .attributeCount = 7, \ .clusterSize = 14, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 9 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 13 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 4 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 8 ) ,\ },\ { \ /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ .clusterId = 0x00000031, \ - .attributes = ZAP_ATTRIBUTE_INDEX(62), \ + .attributes = ZAP_ATTRIBUTE_INDEX(66), \ .attributeCount = 10, \ .clusterSize = 48, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 17 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 24 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 12 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 19 ) ,\ },\ { \ /* Endpoint: 0, Cluster: Diagnostic Logs (server) */ \ .clusterId = 0x00000032, \ - .attributes = ZAP_ATTRIBUTE_INDEX(72), \ + .attributes = ZAP_ATTRIBUTE_INDEX(76), \ .attributeCount = 2, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 28 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 30 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 23 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 25 ) ,\ },\ { \ /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ .clusterId = 0x00000033, \ - .attributes = ZAP_ATTRIBUTE_INDEX(74), \ + .attributes = ZAP_ATTRIBUTE_INDEX(78), \ .attributeCount = 11, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 32 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 27 ) ,\ .generatedCommandList = nullptr ,\ },\ { \ /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ .clusterId = 0x00000034, \ - .attributes = ZAP_ATTRIBUTE_INDEX(85), \ + .attributes = ZAP_ATTRIBUTE_INDEX(89), \ .attributeCount = 6, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -870,7 +880,7 @@ { \ /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ .clusterId = 0x00000035, \ - .attributes = ZAP_ATTRIBUTE_INDEX(91), \ + .attributes = ZAP_ATTRIBUTE_INDEX(95), \ .attributeCount = 65, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -881,7 +891,7 @@ { \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ .clusterId = 0x00000036, \ - .attributes = ZAP_ATTRIBUTE_INDEX(156), \ + .attributes = ZAP_ATTRIBUTE_INDEX(160), \ .attributeCount = 15, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -892,7 +902,7 @@ { \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ .clusterId = 0x00000037, \ - .attributes = ZAP_ATTRIBUTE_INDEX(171), \ + .attributes = ZAP_ATTRIBUTE_INDEX(175), \ .attributeCount = 11, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -903,29 +913,29 @@ { \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ .clusterId = 0x0000003C, \ - .attributes = ZAP_ATTRIBUTE_INDEX(182), \ + .attributes = ZAP_ATTRIBUTE_INDEX(186), \ .attributeCount = 5, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 34 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 29 ) ,\ .generatedCommandList = nullptr ,\ },\ { \ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ .clusterId = 0x0000003E, \ - .attributes = ZAP_ATTRIBUTE_INDEX(187), \ + .attributes = ZAP_ATTRIBUTE_INDEX(191), \ .attributeCount = 8, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 38 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 47 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 33 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 42 ) ,\ },\ { \ /* Endpoint: 0, Cluster: Group Key Management (server) */ \ .clusterId = 0x0000003F, \ - .attributes = ZAP_ATTRIBUTE_INDEX(195), \ + .attributes = ZAP_ATTRIBUTE_INDEX(199), \ .attributeCount = 4, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -936,7 +946,7 @@ { \ /* Endpoint: 0, Cluster: Fixed Label (server) */ \ .clusterId = 0x00000040, \ - .attributes = ZAP_ATTRIBUTE_INDEX(199), \ + .attributes = ZAP_ATTRIBUTE_INDEX(203), \ .attributeCount = 3, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -947,7 +957,7 @@ { \ /* Endpoint: 0, Cluster: User Label (server) */ \ .clusterId = 0x00000041, \ - .attributes = ZAP_ATTRIBUTE_INDEX(202), \ + .attributes = ZAP_ATTRIBUTE_INDEX(206), \ .attributeCount = 3, \ .clusterSize = 6, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ @@ -958,7 +968,7 @@ { \ /* Endpoint: 1, Cluster: Identify (client) */ \ .clusterId = 0x00000003, \ - .attributes = ZAP_ATTRIBUTE_INDEX(205), \ + .attributes = ZAP_ATTRIBUTE_INDEX(209), \ .attributeCount = 0, \ .clusterSize = 0, \ .mask = ZAP_CLUSTER_MASK(CLIENT), \ @@ -969,40 +979,40 @@ { \ /* Endpoint: 1, Cluster: Identify (server) */ \ .clusterId = 0x00000003, \ - .attributes = ZAP_ATTRIBUTE_INDEX(205), \ + .attributes = ZAP_ATTRIBUTE_INDEX(209), \ .attributeCount = 4, \ .clusterSize = 9, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ .functions = chipFuncArrayIdentifyServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 52 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 47 ) ,\ .generatedCommandList = nullptr ,\ },\ { \ /* Endpoint: 1, Cluster: Groups (server) */ \ .clusterId = 0x00000004, \ - .attributes = ZAP_ATTRIBUTE_INDEX(209), \ + .attributes = ZAP_ATTRIBUTE_INDEX(213), \ .attributeCount = 3, \ .clusterSize = 7, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayGroupsServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 54 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 61 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 49 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 56 ) ,\ },\ { \ /* Endpoint: 1, Cluster: Scenes (server) */ \ .clusterId = 0x00000005, \ - .attributes = ZAP_ATTRIBUTE_INDEX(212), \ + .attributes = ZAP_ATTRIBUTE_INDEX(216), \ .attributeCount = 7, \ .clusterSize = 12, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ .functions = chipFuncArrayScenesServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 66 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 74 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 61 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 69 ) ,\ },\ { \ /* Endpoint: 1, Cluster: Basic (server) */ \ .clusterId = 0x00000028, \ - .attributes = ZAP_ATTRIBUTE_INDEX(219), \ + .attributes = ZAP_ATTRIBUTE_INDEX(223), \ .attributeCount = 22, \ .clusterSize = 41, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -1013,13 +1023,13 @@ { \ /* Endpoint: 1, Cluster: Thermostat (server) */ \ .clusterId = 0x00000201, \ - .attributes = ZAP_ATTRIBUTE_INDEX(241), \ + .attributes = ZAP_ATTRIBUTE_INDEX(245), \ .attributeCount = 19, \ .clusterSize = 34, \ .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ .functions = chipFuncArrayThermostatServer, \ - .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 81 ) ,\ - .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 86 ) ,\ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 76 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 81 ) ,\ },\ } @@ -1032,7 +1042,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 22, 256 }, { ZAP_CLUSTER_INDEX(22), 6, 103 }, \ + { ZAP_CLUSTER_INDEX(0), 23, 259 }, { ZAP_CLUSTER_INDEX(23), 6, 103 }, \ } // Largest attribute size is needed for various buffers @@ -1044,7 +1054,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (74) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (359) +#define ATTRIBUTE_MAX_SIZE (362) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) diff --git a/zzz_generated/thermostat/zap-generated/gen_config.h b/zzz_generated/thermostat/zap-generated/gen_config.h index 7313ea3a5b143b..35f4e7dd8ef7de 100644 --- a/zzz_generated/thermostat/zap-generated/gen_config.h +++ b/zzz_generated/thermostat/zap-generated/gen_config.h @@ -37,7 +37,8 @@ #define EMBER_AF_BINDING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ACCESS_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (2) -#define EMBER_AF_OTA_PROVIDER_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_REQUESTOR_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_LOCALIZATION_CONFIGURATION_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_TIME_FORMAT_LOCALIZATION_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_UNIT_LOCALIZATION_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -109,10 +110,14 @@ #define EMBER_AF_PLUGIN_BASIC_SERVER #define EMBER_AF_PLUGIN_BASIC -// Use this macro to check if the server side of the OTA Software Update Provider cluster is included -#define ZCL_USING_OTA_PROVIDER_CLUSTER_SERVER -#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_SERVER -#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER +// Use this macro to check if the client side of the OTA Software Update Provider cluster is included +#define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT + +// Use this macro to check if the server side of the OTA Software Update Requestor cluster is included +#define ZCL_USING_OTA_REQUESTOR_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR // Use this macro to check if the server side of the Localization Configuration cluster is included #define ZCL_USING_LOCALIZATION_CONFIGURATION_CLUSTER_SERVER