diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 33fd567bc2846c..ab08643d534dc9 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -113,7 +113,7 @@ jobs: - name: Build example EFR32+WF200 WiFi Lock app for BRD4161A timeout-minutes: 15 run: | - scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ out/lock_app_wifi_wf200 BRD4161A is_debug=false --wifi wf200 + scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_wifi_wf200 BRD4161A is_debug=false --wifi wf200 .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+wf200 lock-app \ out/lock_app_wifi_wf200/BRD4161A/chip-efr32-lock-example.out /tmp/bloat_reports/ - name: Clean out build output diff --git a/examples/light-switch-app/efr32/.gn b/examples/light-switch-app/efr32/.gn deleted file mode 100644 index 4c078f6acefdcc..00000000000000 --- a/examples/light-switch-app/efr32/.gn +++ /dev/null @@ -1,29 +0,0 @@ -# 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/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn deleted file mode 100644 index 5c03b769dc964c..00000000000000 --- a/examples/light-switch-app/efr32/BUILD.gn +++ /dev/null @@ -1,367 +0,0 @@ -# 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/light-switch-app/efr32" -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -examples_common_plat_dir = "${chip_root}/examples/platform/silabs" - -declare_args() { - # Dump memory usage at link time. - chip_print_memory_usage = false - - # 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 - - # Argument to force enable WPA3 security - rs91x_wpa3_only = 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) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -# WiFi settings -if (chip_enable_wifi) { - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_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/silabs/EFR32", - "${efr32_project_dir}/include", - "${examples_plat_dir}", - "${chip_root}/src/lib", - "${examples_common_plat_dir}", - ] - - defines = [ - "BOARD_ID=${silabs_board}", - "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("light_switch_app") { - output_name = "chip-efr32-light-switch-example.out" - public_configs = [ "${efr32_sdk_build_root}:silabs_config" ] - include_dirs = [ "include" ] - defines = [] - - sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", - "src/AppTask.cpp", - "src/ZclCallbacks.cpp", - "src/binding-handler.cpp", - "src/main.cpp", - ] - - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - - deps = [ - ":sdk", - "${chip_root}/examples/light-switch-app/light-switch-common", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", - ] - - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # 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 (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_SWITCH=1", - ] - 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_common_plat_dir}/PigweedLogger.cpp", - "${examples_common_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_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - - ldscript = "${examples_plat_dir}/ldscripts/${silabs_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 = [ ":light_switch_app" ] -} - -group("default") { - deps = [ ":efr32" ] -} diff --git a/examples/light-switch-app/efr32/README.md b/examples/light-switch-app/efr32/README.md deleted file mode 100644 index 3a72765e663796..00000000000000 --- a/examples/light-switch-app/efr32/README.md +++ /dev/null @@ -1,468 +0,0 @@ -# Matter EFR32 Light Switch Example - -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - -
- -- [Matter EFR32 Light Switch Example](#matter-efr32-light-switch-example) - - [Introduction](#introduction) - - [Building](#building) - - [Linux](#linux) - - [Mac OS X](#mac-os-x) - - [Flashing the Application](#flashing-the-application) - - [Viewing Logging Output](#viewing-logging-output) - - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) - - [On Border Router:](#on-border-router) - - [On PC(Linux):](#on-pclinux) - - [Running RPC console](#running-rpc-console) - - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - - [Building options](#building-options) - - [Disabling logging](#disabling-logging) - - [Debug build / release build](#debug-build--release-build) - - [Disabling LCD](#disabling-lcd) - - [KVS maximum entry count](#kvs-maximum-entry-count) - -
- -> **NOTE:** Silicon Laboratories now maintains a public matter GitHub repo with -> frequent releases thoroughly tested and validated. Developers looking to -> develop matter products with silabs hardware are encouraged to use our latest -> release with added tools and documentation. -> [Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) - - - -## Introduction - -The EFR32 light switch example provides a baseline demonstration of a on-off -light switch device, built using Matter and the Silicon Labs gecko SDK. It can -be controlled by a Chip controller over an Openthread or Wifi 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. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the network. - -If the LCD is enabled, 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 Matter 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 ninja-build - -#### Mac OS X - - $ brew install ninja - -- Supported hardware: - - - > For the latest supported hardware please refer to the - > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) - > in the Silicon Labs Matter Github Repo - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - -* Build the example application: - - cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app BRD4161A - -- To delete generated executable, libraries and object files use: - - $ cd ~/connectedhomeip - $ rm -rf ./out/ - - OR use GN/Ninja directly - - $ cd ~/connectedhomeip/examples/light-switch-app/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/light-switch-app/efr32 - $ rm -rf out/ - -* Build the example with Matter shell - - ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true - -* Build the example as Sleepy End Device (SED) - - $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app_SED BRD4161A --sed - - or use gn as previously mentioned but adding the following arguments: - - $ gn gen out/debug '--args=silabs_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/light-switch-app/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - - or use GN/Ninja Directly - - $ cd ~/connectedhomeip/examples/light-switch-app/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/lighting-app/efr32 - $ python3 out/debug/chip-efr32-light-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 - [lighting app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/lighting-app/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. - - **Push Button 1** - - - Sends a Toggle command to bound light app - - **Matter shell** - - **_OnOff Cluster_** - - - 'switch onoff on' : Sends unicast On command to bound device - - 'switch onoff off' : Sends unicast Off command to bound device - - 'switch onoff toggle' : Sends unicast Toggle command to bound device - - - 'switch groups onoff on' : Sends On group command to bound group - - 'switch groups onoff off' : Sends On group command to bound group - - 'switch groups onoff toggle' : Sends On group command to bound group - - **_Binding Cluster_** - - - 'switch binding unicast ' : Creates a unicast binding - - 'switch binding group ' : Creates a group binding - -* 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 for unicast commands only: - - ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 - - chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [], "targets": null }{"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [1], "targets": null }]' 0 - - chip-tool binding write binding '[{"fabricIndex": 1, "node": , "endpoint": 1, "cluster":6}]' 1 1 - ``` - - Here is an example with the CHIPTool for groups commands only: - - ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 - - chip-tool tests TestGroupDemoConfig --nodeId 1 - - chip-tool tests TestGroupDemoConfig --nodeId - - chip-tool binding write binding '[{"fabricIndex": 1, "group": 257}]' 1 1 - ``` - - To run the example with unicast and groups commands, run the group - configuration commands and replace the last one with binding this command - - ``` - chip-tool binding write binding '[{"fabricIndex": 1, "group": 257},{"fabricIndex": 1, "node": , "endpoint": 1, "cluster":6} ]' 1 1 - ``` - - To acquire the chip-tool node id, read the acl table right after - commissioning - - ``` - ./connectedhomeip/out/chip-tool/chip-tool accesscontrol read acl 0 - ``` - -### 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)` - -- You can also Get and Set the light directly using the RPCs: - - `rpcs.chip.rpc.Lighting.Get()` - - `rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5))` - -## 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/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" - -### Disabling LCD - -show_qr_code - - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 diff --git a/examples/light-switch-app/efr32/args.gni b/examples/light-switch-app/efr32/args.gni deleted file mode 100644 index f75911d38c37a8..00000000000000 --- a/examples/light-switch-app/efr32/args.gni +++ /dev/null @@ -1,29 +0,0 @@ -# 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}/config/standalone/args.gni") -import("${chip_root}/src/platform/silabs/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" -openthread_external_platform = - "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/light-switch-app/efr32/build_for_wifi_args.gni b/examples/light-switch-app/efr32/build_for_wifi_args.gni deleted file mode 100644 index 363d2be9e6f362..00000000000000 --- a/examples/light-switch-app/efr32/build_for_wifi_args.gni +++ /dev/null @@ -1,25 +0,0 @@ -# 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}/config/standalone/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") -chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/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/light-switch-app/efr32/build_for_wifi_gnfile.gn b/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn deleted file mode 100644 index d391814190d09f..00000000000000 --- a/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn +++ /dev/null @@ -1,28 +0,0 @@ -# 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/light-switch-app/efr32/build_overrides b/examples/light-switch-app/efr32/build_overrides deleted file mode 120000 index e578e73312ebd1..00000000000000 --- a/examples/light-switch-app/efr32/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../build_overrides \ No newline at end of file diff --git a/examples/light-switch-app/efr32/include/AppConfig.h b/examples/light-switch-app/efr32/include/AppConfig.h deleted file mode 100644 index a936fe1d8abaeb..00000000000000 --- a/examples/light-switch-app/efr32/include/AppConfig.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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 silabsInitLog(void); - -void efr32Log(const char * aFormat, ...); -#define SILABS_LOG(...) efr32Log(__VA_ARGS__); -void appError(int err); - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/light-switch-app/efr32/include/AppEvent.h b/examples/light-switch-app/efr32/include/AppEvent.h deleted file mode 100644 index 7a19b719edad25..00000000000000 --- a/examples/light-switch-app/efr32/include/AppEvent.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * 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/light-switch-app/efr32/include/AppTask.h b/examples/light-switch-app/efr32/include/AppTask.h deleted file mode 100644 index a8e186083c23f6..00000000000000 --- a/examples/light-switch-app/efr32/include/AppTask.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * 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 "BaseApplication.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 BaseApplication -{ - -public: - AppTask() = default; - - static AppTask & GetAppTask() { return sAppTask; } - - /** - * @brief AppTask task main loop function - * - * @param pvParameter FreeRTOS task parameter - */ - static void AppTaskMain(void * pvParameter); - - CHIP_ERROR StartAppTask(); - - /** - * @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) override; - - /** - * @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); - -private: - static AppTask sAppTask; - - /** - * @brief AppTask initialisation function - * - * @return CHIP_ERROR - */ - CHIP_ERROR Init(); - - /** - * @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 switch action sent to the CHIP task - * - * @param aEvent button event being processed - */ - static void SwitchActionEventHandler(AppEvent * aEvent); -}; diff --git a/examples/light-switch-app/efr32/include/CHIPProjectConfig.h b/examples/light-switch-app/efr32/include/CHIPProjectConfig.h deleted file mode 100644 index 1b74c802fd4f09..00000000000000 --- a/examples/light-switch-app/efr32/include/CHIPProjectConfig.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * 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 - * - * 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_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/light-switch-app/efr32/include/binding-handler.h b/examples/light-switch-app/efr32/include/binding-handler.h deleted file mode 100644 index aed08be25eb5bc..00000000000000 --- a/examples/light-switch-app/efr32/include/binding-handler.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * 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. - */ -#pragma once - -#include "app-common/zap-generated/ids/Clusters.h" -#include "app-common/zap-generated/ids/Commands.h" -#include "lib/core/CHIPError.h" - -CHIP_ERROR InitBindingHandler(); -void SwitchWorkerFunction(intptr_t context); -void BindingWorkerFunction(intptr_t context); - -struct BindingCommandData -{ - chip::EndpointId localEndpointId = 1; - chip::CommandId commandId; - chip::ClusterId clusterId; - bool isGroup = false; -}; diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp deleted file mode 100644 index e1bbc8d782c888..00000000000000 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/* - * - * 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 "binding-handler.h" - -#ifdef ENABLE_WSTK_LEDS -#include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS - -#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 - -/********************************************************** - * Defines and Constants - *********************************************************/ - -#define SYSTEM_STATE_LED &sl_led_led0 - -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_LIGHT_SWITCH &sl_button_btn1 - -using namespace chip; -using namespace ::chip::DeviceLayer; - -namespace { - -/********************************************************** - * Variable declarations - *********************************************************/ - -EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; - -bool mCurrentButtonState = false; - -/********************************************************** - * 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 - AppTask::GetAppTask().StopStatusLEDTimer(); -#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 - AppTask::GetAppTask().StartStatusLEDTimer(); -#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 }, - AppTask::GetAppTask().OnIdentifyStart, - AppTask::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::Init() -{ - CHIP_ERROR err = CHIP_NO_ERROR; -#ifdef DISPLAY_ENABLED - GetLCD().Init((uint8_t *) "Light Switch"); -#endif - - err = BaseApplication::Init(&gIdentify); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("BaseApplication::Init() failed"); - appError(err); - } - - // Configure Bindings - TODO ERROR PROCESSING - err = InitBindingHandler(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("InitBindingHandler() failed"); - appError(err); - } - - return err; -} - -CHIP_ERROR AppTask::StartAppTask() -{ - return BaseApplication::StartAppTask(AppTaskMain); -} - -void AppTask::AppTaskMain(void * pvParameter) -{ - AppEvent event; - QueueHandle_t sAppEventQueue = *(static_cast(pvParameter)); - - CHIP_ERROR err = sAppTask.Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("AppTask.Init() failed"); - appError(err); - } - -#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) - sAppTask.StartStatusLEDTimer(); -#endif - - SILABS_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.StartStatusLEDTimer(); -#endif -} - -void AppTask::OnIdentifyStop(Identify * identify) -{ - ChipLogProgress(Zcl, "onIdentifyStop"); - -#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 - sAppTask.StopStatusLEDTimer(); -#endif -} - -void AppTask::SwitchActionEventHandler(AppEvent * aEvent) -{ - if (aEvent->Type == AppEvent::kEventType_Button) - { - BindingCommandData * data = Platform::New(); - data->clusterId = chip::app::Clusters::OnOff::Id; - - if (mCurrentButtonState) - { - mCurrentButtonState = false; - data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id; - } - else - { - data->commandId = chip::app::Clusters::OnOff::Commands::On::Id; - mCurrentButtonState = true; - } - -#ifdef DISPLAY_ENABLED - sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState); -#endif - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - } -} - -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_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) - { - button_event.Handler = SwitchActionEventHandler; - sAppTask.PostEvent(&button_event); - } - else if (buttonHandle == APP_FUNCTION_BUTTON) - { - button_event.Handler = BaseApplication::ButtonHandler; - sAppTask.PostEvent(&button_event); - } -} diff --git a/examples/light-switch-app/efr32/src/ZclCallbacks.cpp b/examples/light-switch-app/efr32/src/ZclCallbacks.cpp deleted file mode 100644 index 52542ca88fb390..00000000000000 --- a/examples/light-switch-app/efr32/src/ZclCallbacks.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * 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 == OnOffSwitchConfiguration::Id) - { - ChipLogProgress(Zcl, "OnOff Switch Configuration attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", - ChipLogValueMEI(attributeId), type, *value, size); - - // WIP Apply attribute change to Light - } - else 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/light-switch-app/efr32/src/binding-handler.cpp b/examples/light-switch-app/efr32/src/binding-handler.cpp deleted file mode 100644 index 90a2463a088e33..00000000000000 --- a/examples/light-switch-app/efr32/src/binding-handler.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* - * - * 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. - */ - -#include "binding-handler.h" - -#include "AppConfig.h" -#include "app/CommandSender.h" -#include "app/clusters/bindings/BindingManager.h" -#include "app/server/Server.h" -#include "controller/InvokeInteraction.h" -#include "platform/CHIPDeviceLayer.h" -#include -#include - -#if defined(ENABLE_CHIP_SHELL) -#include "lib/shell/Engine.h" -#include "lib/shell/commands/Help.h" -#endif // ENABLE_CHIP_SHELL - -using namespace chip; -using namespace chip::app; - -#if defined(ENABLE_CHIP_SHELL) -using Shell::Engine; -using Shell::shell_command_t; -using Shell::streamer_get; -using Shell::streamer_printf; - -Engine sShellSwitchSubCommands; -Engine sShellSwitchOnOffSubCommands; - -Engine sShellSwitchGroupsSubCommands; -Engine sShellSwitchGroupsOnOffSubCommands; - -Engine sShellSwitchBindingSubCommands; -#endif // defined(ENABLE_CHIP_SHELL) - -namespace { - -void ProcessOnOffUnicastBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding, - Messaging::ExchangeManager * exchangeMgr, const SessionHandle & sessionHandle) -{ - auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { - ChipLogProgress(NotSpecified, "OnOff command succeeds"); - }; - - auto onFailure = [](CHIP_ERROR error) { - ChipLogError(NotSpecified, "OnOff command failed: %" CHIP_ERROR_FORMAT, error.Format()); - }; - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, onCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, offCommand, onSuccess, onFailure); - break; - } -} - -void ProcessOnOffGroupBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding) -{ - Messaging::ExchangeManager & exchangeMgr = Server::GetInstance().GetExchangeManager(); - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, onCommand); - - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, offCommand); - break; - } -} - -void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, OperationalDeviceProxy * peer_device, void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "OnDeviceConnectedFn: context is null")); - BindingCommandData * data = static_cast(context); - - if (binding.type == EMBER_MULTICAST_BINDING && data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - ProcessOnOffGroupBindingCommand(data->commandId, binding); - break; - } - } - else if (binding.type == EMBER_UNICAST_BINDING && !data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - VerifyOrDie(peer_device != nullptr && peer_device->ConnectionReady()); - ProcessOnOffUnicastBindingCommand(data->commandId, binding, peer_device->GetExchangeManager(), - peer_device->GetSecureSession().Value()); - break; - } - } -} - -void LightSwitchContextReleaseHandler(void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "LightSwitchContextReleaseHandler: context is null")); - - Platform::Delete(static_cast(context)); -} - -#ifdef ENABLE_CHIP_SHELL - -/******************************************************** - * Switch shell functions - *********************************************************/ - -CHIP_ERROR SwitchHelpHandler(int argc, char ** argv) -{ - sShellSwitchSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR SwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return SwitchHelpHandler(argc, argv); - } - - return sShellSwitchSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * OnOff switch shell functions - *********************************************************/ - -CHIP_ERROR OnOffHelpHandler(int argc, char ** argv) -{ - sShellSwitchOnOffSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR OnOffSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return OnOffHelpHandler(argc, argv); - } - - return sShellSwitchOnOffSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR OnSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::On::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR OffSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Off::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR ToggleSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Toggle::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -/******************************************************** - * bind switch shell functions - *********************************************************/ - -CHIP_ERROR BindingHelpHandler(int argc, char ** argv) -{ - sShellSwitchBindingSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR BindingSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return BindingHelpHandler(argc, argv); - } - - return sShellSwitchBindingSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR BindingGroupBindCommandHandler(int argc, char ** argv) -{ - VerifyOrReturnError(argc == 2, CHIP_ERROR_INVALID_ARGUMENT); - - EmberBindingTableEntry * entry = Platform::New(); - entry->type = EMBER_MULTICAST_BINDING; - entry->fabricIndex = atoi(argv[0]); - entry->groupId = atoi(argv[1]); - entry->local = 1; // Hardcoded to endpoint 1 for now - entry->clusterId.SetValue(6); // Hardcoded to OnOff cluster for now - - DeviceLayer::PlatformMgr().ScheduleWork(BindingWorkerFunction, reinterpret_cast(entry)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR BindingUnicastBindCommandHandler(int argc, char ** argv) -{ - VerifyOrReturnError(argc == 3, CHIP_ERROR_INVALID_ARGUMENT); - - EmberBindingTableEntry * entry = Platform::New(); - entry->type = EMBER_UNICAST_BINDING; - entry->fabricIndex = atoi(argv[0]); - entry->nodeId = atoi(argv[1]); - entry->local = 1; // Hardcoded to endpoint 1 for now - entry->remote = atoi(argv[2]); - entry->clusterId.SetValue(6); // Hardcode to OnOff cluster for now - - DeviceLayer::PlatformMgr().ScheduleWork(BindingWorkerFunction, reinterpret_cast(entry)); - return CHIP_NO_ERROR; -} - -/******************************************************** - * Groups switch shell functions - *********************************************************/ - -CHIP_ERROR GroupsHelpHandler(int argc, char ** argv) -{ - sShellSwitchGroupsSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupsSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return GroupsHelpHandler(argc, argv); - } - - return sShellSwitchGroupsSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * Groups OnOff switch shell functions - *********************************************************/ - -CHIP_ERROR GroupsOnOffHelpHandler(int argc, char ** argv) -{ - sShellSwitchGroupsOnOffSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupsOnOffSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return GroupsOnOffHelpHandler(argc, argv); - } - - return sShellSwitchGroupsOnOffSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR GroupOnSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::On::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupOffSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Off::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupToggleSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Toggle::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -/** - * @brief configures switch matter shell - * - */ -static void RegisterSwitchCommands() -{ - static const shell_command_t sSwitchSubCommands[] = { - { &SwitchHelpHandler, "help", "Usage: switch " }, - { &OnOffSwitchCommandHandler, "onoff", " Usage: switch onoff " }, - { &GroupsSwitchCommandHandler, "groups", "Usage: switch groups " }, - { &BindingSwitchCommandHandler, "binding", "Usage: switch binding " } - }; - - static const shell_command_t sSwitchOnOffSubCommands[] = { - { &OnOffHelpHandler, "help", "Usage : switch ononff " }, - { &OnSwitchCommandHandler, "on", "Sends on command to bound lighting app" }, - { &OffSwitchCommandHandler, "off", "Sends off command to bound lighting app" }, - { &ToggleSwitchCommandHandler, "toggle", "Sends toggle command to bound lighting app" } - }; - - static const shell_command_t sSwitchGroupsSubCommands[] = { { &GroupsHelpHandler, "help", "Usage: switch groups " }, - { &GroupsOnOffSwitchCommandHandler, "onoff", - "Usage: switch groups onoff " } }; - - static const shell_command_t sSwitchGroupsOnOffSubCommands[] = { - { &GroupsOnOffHelpHandler, "help", "Usage: switch groups onoff " }, - { &GroupOnSwitchCommandHandler, "on", "Sends on command to bound group" }, - { &GroupOffSwitchCommandHandler, "off", "Sends off command to bound group" }, - { &GroupToggleSwitchCommandHandler, "toggle", "Sends toggle command to group" } - }; - - static const shell_command_t sSwitchBindingSubCommands[] = { - { &BindingHelpHandler, "help", "Usage: switch binding " }, - { &BindingGroupBindCommandHandler, "group", "Usage: switch binding group " }, - { &BindingUnicastBindCommandHandler, "unicast", "Usage: switch binding group " } - }; - - static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", - "Light-switch commands. Usage: switch " }; - - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); - - Engine::Root().RegisterCommands(&sSwitchCommand, 1); -} -#endif // ENABLE_CHIP_SHELL - -void InitBindingHandlerInternal(intptr_t arg) -{ - auto & server = chip::Server::GetInstance(); - chip::BindingManager::GetInstance().Init( - { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); - chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); - chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); -} - -} // namespace - -/******************************************************** - * Switch functions - *********************************************************/ - -void SwitchWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "SwitchWorkerFunction - Invalid work data")); - - BindingCommandData * data = reinterpret_cast(context); - BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); -} - -void BindingWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "BindingWorkerFunction - Invalid work data")); - - EmberBindingTableEntry * entry = reinterpret_cast(context); - AddBindingEntry(*entry); - - Platform::Delete(entry); -} - -CHIP_ERROR InitBindingHandler() -{ - // The initialization of binding manager will try establishing connection with unicast peers - // so it requires the Server instance to be correctly initialized. Post the init function to - // the event queue so that everything is ready when initialization is conducted. - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitBindingHandlerInternal); -#if defined(ENABLE_CHIP_SHELL) - RegisterSwitchCommands(); -#endif - return CHIP_NO_ERROR; -} diff --git a/examples/light-switch-app/efr32/src/main.cpp b/examples/light-switch-app/efr32/src/main.cpp deleted file mode 100644 index 0b0211fdbfe61c..00000000000000 --- a/examples/light-switch-app/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * 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-Light-Switch" -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(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/light-switch-app/efr32/third_party/connectedhomeip b/examples/light-switch-app/efr32/third_party/connectedhomeip deleted file mode 120000 index c866b86874994d..00000000000000 --- a/examples/light-switch-app/efr32/third_party/connectedhomeip +++ /dev/null @@ -1 +0,0 @@ -../../../.. \ No newline at end of file diff --git a/examples/light-switch-app/silabs/efr32/build_overrides b/examples/light-switch-app/silabs/efr32/build_overrides index e578e73312ebd1..995884e6163eb5 120000 --- a/examples/light-switch-app/silabs/efr32/build_overrides +++ b/examples/light-switch-app/silabs/efr32/build_overrides @@ -1 +1 @@ -../../build_overrides \ No newline at end of file +../../../build_overrides \ No newline at end of file diff --git a/examples/light-switch-app/silabs/efr32/third_party/connectedhomeip b/examples/light-switch-app/silabs/efr32/third_party/connectedhomeip index c866b86874994d..59307833b4fee9 120000 --- a/examples/light-switch-app/silabs/efr32/third_party/connectedhomeip +++ b/examples/light-switch-app/silabs/efr32/third_party/connectedhomeip @@ -1 +1 @@ -../../../.. \ No newline at end of file +../../../../.. \ No newline at end of file diff --git a/examples/lock-app/efr32/.gn b/examples/lock-app/efr32/.gn deleted file mode 100644 index 4c078f6acefdcc..00000000000000 --- a/examples/lock-app/efr32/.gn +++ /dev/null @@ -1,29 +0,0 @@ -# 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/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn deleted file mode 100644 index 88983a2f058284..00000000000000 --- a/examples/lock-app/efr32/BUILD.gn +++ /dev/null @@ -1,376 +0,0 @@ -# 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/lock-app/efr32" -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -examples_common_plat_dir = "${chip_root}/examples/platform/silabs" - -declare_args() { - # Dump memory usage at link time. - chip_print_memory_usage = false - - # 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 - - # Argument to force enable WPA3 security - rs91x_wpa3_only = 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) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -# WiFi settings -if (chip_enable_wifi) { - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_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/silabs/EFR32", - "${efr32_project_dir}/include", - "${examples_plat_dir}", - "${chip_root}/src/lib", - "${examples_common_plat_dir}", - ] - - defines = [ - "BOARD_ID=${silabs_board}", - "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("lock_app") { - output_name = "chip-efr32-lock-example.out" - public_configs = [ "${efr32_sdk_build_root}:silabs_config" ] - include_dirs = [ "include" ] - defines = [] - - sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", - "src/AppTask.cpp", - "src/LockManager.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] - - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - - if (chip_build_libshell) { - sources += [ "src/EventHandlerLibShell.cpp" ] - } - - deps = [ - ":sdk", - "${chip_root}/examples/lock-app/lock-common", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", - "${examples_plat_dir}:efr-matter-shell", - ] - - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # 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 (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_LOCK=1", - ] - 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_LOCKING_SERVICE=1", - "PW_RPC_OTCLI_SERVICE=1", - "PW_RPC_THREAD_SERVICE=1", - ] - - sources += [ - "${chip_root}/examples/common/pigweed/RpcService.cpp", - "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", - "${examples_common_plat_dir}/PigweedLogger.cpp", - "${examples_common_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:locking_service.nanopb_rpc", - "${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc", - "${chip_root}/examples/common/pigweed:thread_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_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - - ldscript = "${examples_plat_dir}/ldscripts/${silabs_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", - ] - } - - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - - output_dir = root_out_dir -} -group("efr32") { - deps = [ ":lock_app" ] -} - -group("default") { - deps = [ ":efr32" ] -} diff --git a/examples/lock-app/efr32/README.md b/examples/lock-app/efr32/README.md deleted file mode 100644 index a681df76cc6d45..00000000000000 --- a/examples/lock-app/efr32/README.md +++ /dev/null @@ -1,457 +0,0 @@ -# Matter EFR32 Lock Example - -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - -
- -- [Matter EFR32 Lock Example](#matter-efr32-lock-example) - - [Introduction](#introduction) - - [Building](#building) - - [Flashing the Application](#flashing-the-application) - - [Viewing Logging Output](#viewing-logging-output) - - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) - - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - - [Building options](#building-options) - - [Disabling logging](#disabling-logging) - - [Debug build / release build](#debug-build--release-build) - - [Disabling LCD](#disabling-lcd) - - [KVS maximum entry count](#kvs-maximum-entry-count) - -
- -> **NOTE:** Silicon Laboratories now maintains a public matter GitHub repo with -> frequent releases thoroughly tested and validated. Developers looking to -> develop matter products with silabs hardware are encouraged to use our latest -> release with added tools and documentation. -> [Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) - - - -## Introduction - -The EFR32 lock example provides a baseline demonstration of a door lock control -device, built using Matter and the Silicon Labs gecko SDK. It can be controlled -by a Chip controller over an Openthread or Wifi 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. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the Thread network. - -If the LCD is enabled, 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 lighting example is intended to serve both as a means to explore the -workings of Matter as well as a template for creating real products based on the -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 ninja-build - -Mac OS X - - brew install ninja - -- Supported hardware: - - - > For the latest supported hardware please refer to the - > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) - > in the Silicon Labs Matter Github Repo - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - -* Build the example application: - - ``` - cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/efr32/ ./out/lock_app BRD4161A - ``` - -- To delete generated executable, libraries and object files use: - - ``` - $ cd ~/connectedhomeip - $ rm -rf ./out/ - ``` - - OR use GN/Ninja directly - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\"" - $ ninja -C out/debug - ``` - -- To delete generated executable, libraries and object files use: - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ rm -rf out/ - ``` - -* Build the example as Sleepy End Device (SED) - - ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app_SED BRD4161A --sed - ``` - - or use gn as previously mentioned but adding the following arguments: - - ``` - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' - ``` - -* Build the example with pigweed RCP - - ``` - $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - ``` - - or use GN/Ninja Directly - - ``` - $ cd ~/connectedhomeip/examples/lock-app/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/lock-app/efr32 - $ python3 out/debug/chip-efr32-lock-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 - -- 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. - - **LED 1** Simulates the Lock The following states are possible: - - - _Solid On_ ; Bolt is unlocked - - _Blinking_ ; Bolt is moving to the desired state - - _Off_ ; Bolt is locked - - **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. - - **Push Button 1** Toggles the bolt state On/Off - -- You can provision and control the Chip device using the python controller, - Chip tool standalone, Android or iOS app - - [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - -Here is some CHIPTool examples: - - Pairing with chip-tool: - ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 - ``` - - Set a user: - ``` - ./out/chip-tool doorlock set-user OperationType UserIndex UserName UserUniqueId UserStatus UserType CredentialRule node-id/group-id - ./out/chip-tool doorlock set-user 0 1 "mike" 5 1 0 0 1 1 --timedInteractionTimeoutMs 1000 - ``` - - Set a credential: - ``` - ./out/chip-tool doorlock set-credential OperationType Credential CredentialData UserIndex UserStatus UserType node-id/group-id - ./out/chip-tool doorlock set-credential 0 '{ "credentialType": 1, "credentialIndex": 1 }' "123456" 1 null null 1 1 --timedInteractionTimeoutMs 1000 - ``` - - Changing a credential: - ``` - ./out/chip-tool doorlock set-credential OperationType Credential CredentialData UserIndex UserStatus UserType node-id/group-id - ./out/chip-tool doorlock set-credential 2 '{ "credentialType": 1, "credentialIndex": 1 }' "123457" 1 null null 1 1 --timedInteractionTimeoutMs 1000 - ``` - - Get a user: - ``` - ./out/chip-tool doorlock get-user UserIndex node-id/group-id - ./out/chip-tool doorlock get-user 1 1 1 - ``` - - Unlock door: - ``` - ./out/chip-tool doorlock unlock-door node-id/group-id - ./out/chip-tool doorlock unlock-door 1 1 --timedInteractionTimeoutMs 1000 - ``` - - Lock door: - ``` - ./out/chip-tool doorlock lock-door node-id/group-id - ./out/chip-tool doorlock lock-door 1 1 --timedInteractionTimeoutMs 1000 - ``` - -### 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 - -## 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/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" - ``` - -### Disabling LCD - -`show_qr_code` - - ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 - ``` diff --git a/examples/lock-app/efr32/args.gni b/examples/lock-app/efr32/args.gni deleted file mode 100644 index 23f22fbb83d459..00000000000000 --- a/examples/lock-app/efr32/args.gni +++ /dev/null @@ -1,29 +0,0 @@ -# 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}/config/standalone/args.gni") -import("${chip_root}/src/platform/silabs/EFR32/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") - -chip_enable_ota_requestor = true - -chip_enable_openthread = true -pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" -pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" -pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" -openthread_external_platform = - "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/lock-app/efr32/build_for_wifi_args.gni b/examples/lock-app/efr32/build_for_wifi_args.gni deleted file mode 100644 index 363d2be9e6f362..00000000000000 --- a/examples/lock-app/efr32/build_for_wifi_args.gni +++ /dev/null @@ -1,25 +0,0 @@ -# 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}/config/standalone/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") -chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/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/lock-app/efr32/build_for_wifi_gnfile.gn b/examples/lock-app/efr32/build_for_wifi_gnfile.gn deleted file mode 100644 index d391814190d09f..00000000000000 --- a/examples/lock-app/efr32/build_for_wifi_gnfile.gn +++ /dev/null @@ -1,28 +0,0 @@ -# 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/lock-app/efr32/build_overrides b/examples/lock-app/efr32/build_overrides deleted file mode 120000 index e578e73312ebd1..00000000000000 --- a/examples/lock-app/efr32/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../build_overrides \ No newline at end of file diff --git a/examples/lock-app/efr32/include/AppConfig.h b/examples/lock-app/efr32/include/AppConfig.h deleted file mode 100644 index 3014c5be66479c..00000000000000 --- a/examples/lock-app/efr32/include/AppConfig.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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 - -// ---- Door lock Example App Config ---- - -#define APP_TASK_NAME "Lock" - -// 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 silabsInitLog(void); - -void efr32Log(const char * aFormat, ...); -#define SILABS_LOG(...) efr32Log(__VA_ARGS__); -void appError(int err); - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/lock-app/efr32/include/AppEvent.h b/examples/lock-app/efr32/include/AppEvent.h deleted file mode 100644 index 7724687d3ef96c..00000000000000 --- a/examples/lock-app/efr32/include/AppEvent.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * 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_Lock, - kEventType_Install, - }; - - uint16_t Type; - - union - { - struct - { - uint8_t Action; - } ButtonEvent; - struct - { - void * Context; - } TimerEvent; - struct - { - uint8_t Action; - int32_t Actor; - } LockEvent; - }; - - EventHandler Handler; -}; diff --git a/examples/lock-app/efr32/include/AppTask.h b/examples/lock-app/efr32/include/AppTask.h deleted file mode 100644 index 0c7723475772be..00000000000000 --- a/examples/lock-app/efr32/include/AppTask.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * - * 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 "BaseApplication.h" -#include "FreeRTOS.h" -#include "LockManager.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) -#define APP_ERROR_ALLOCATION_FAILED CHIP_APPLICATION_ERROR(0x07) -#if defined(ENABLE_CHIP_SHELL) -#define APP_ERROR_TOO_MANY_SHELL_ARGUMENTS CHIP_APPLICATION_ERROR(0x08) -#endif // ENABLE_CHIP_SHELL - -/********************************************************** - * AppTask Declaration - *********************************************************/ - -class AppTask : public BaseApplication -{ - -public: - AppTask() = default; - - static AppTask & GetAppTask() { return sAppTask; } - - /** - * @brief AppTask task main loop function - * - * @param pvParameter FreeRTOS task parameter - */ - static void AppTaskMain(void * pvParameter); - - CHIP_ERROR StartAppTask(); - - void ActionRequest(int32_t aActor, LockManager::Action_t aAction); - static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(LockManager::Action_t aAction); - - /** - * @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) override; - - /** - * @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); - -private: - static AppTask sAppTask; - - /** - * @brief AppTask initialisation function - * - * @return CHIP_ERROR - */ - CHIP_ERROR Init(); - - /** - * @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 switch action sent to the CHIP task - * - * @param aEvent button event being processed - */ - static void SwitchActionEventHandler(AppEvent * aEvent); - - /** - * @brief Update Cluster State - * - * @param context current context - */ - static void UpdateClusterState(intptr_t context); - - /** - * @brief Handle lock update event - * - * @param aEvent event received - */ - static void LockActionEventHandler(AppEvent * aEvent); -}; diff --git a/examples/lock-app/efr32/include/CHIPProjectConfig.h b/examples/lock-app/efr32/include/CHIPProjectConfig.h deleted file mode 100644 index 9793e98ac9bc0a..00000000000000 --- a/examples/lock-app/efr32/include/CHIPProjectConfig.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * 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 -#define CHIP_CONFIG_REQUIRE_AUTH 1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID - * - * 0xFFF1: Test vendor - */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * - * 0x8006: example lock app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 - -/** - * 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 - * - * 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_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) diff --git a/examples/lock-app/efr32/include/EventHandlerLibShell.h b/examples/lock-app/efr32/include/EventHandlerLibShell.h deleted file mode 100644 index 3ad9f11cbf2fdc..00000000000000 --- a/examples/lock-app/efr32/include/EventHandlerLibShell.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * 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. - */ -#pragma once - -#include - -class EventData -{ -public: - chip::EventId eventId; -}; - -class AlarmEventData : public EventData -{ -public: - DlAlarmCode alarmCode; -}; - -class DoorStateEventData : public EventData -{ -public: - DlDoorState doorState; -}; - -CHIP_ERROR RegisterLockEvents(); -void EventWorkerFunction(intptr_t context); diff --git a/examples/lock-app/efr32/include/LockManager.h b/examples/lock-app/efr32/include/LockManager.h deleted file mode 100644 index e2a6b7f586978d..00000000000000 --- a/examples/lock-app/efr32/include/LockManager.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * - * 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 -#include - -#include -#include - -#include "AppEvent.h" - -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support - -#include - -struct WeekDaysScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockWeekDaySchedule schedule; -}; - -struct YearDayScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockYearDaySchedule schedule; -}; - -struct HolidayScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockHolidaySchedule schedule; -}; - -namespace EFR32DoorLock { -namespace ResourceRanges { -// Used to size arrays -static constexpr uint16_t kMaxUsers = 10; -static constexpr uint8_t kMaxCredentialsPerUser = 10; -static constexpr uint8_t kMaxWeekdaySchedulesPerUser = 10; -static constexpr uint8_t kMaxYeardaySchedulesPerUser = 10; -static constexpr uint8_t kMaxHolidaySchedules = 10; -static constexpr uint8_t kMaxCredentialSize = 8; - -static constexpr uint8_t kMaxCredentials = kMaxUsers * kMaxCredentialsPerUser; -} // namespace ResourceRanges - -namespace LockInitParams { - -struct LockParam -{ - // Read from zap attributes - uint16_t numberOfUsers = 0; - uint8_t numberOfCredentialsPerUser = 0; - uint8_t numberOfWeekdaySchedulesPerUser = 0; - uint8_t numberOfYeardaySchedulesPerUser = 0; - uint8_t numberOfHolidaySchedules = 0; -}; - -class ParamBuilder -{ -public: - ParamBuilder & SetNumberOfUsers(uint16_t numberOfUsers) - { - lockParam_.numberOfUsers = numberOfUsers; - return *this; - } - ParamBuilder & SetNumberOfCredentialsPerUser(uint8_t numberOfCredentialsPerUser) - { - lockParam_.numberOfCredentialsPerUser = numberOfCredentialsPerUser; - return *this; - } - ParamBuilder & SetNumberOfWeekdaySchedulesPerUser(uint8_t numberOfWeekdaySchedulesPerUser) - { - lockParam_.numberOfWeekdaySchedulesPerUser = numberOfWeekdaySchedulesPerUser; - return *this; - } - ParamBuilder & SetNumberOfYeardaySchedulesPerUser(uint8_t numberOfYeardaySchedulesPerUser) - { - lockParam_.numberOfYeardaySchedulesPerUser = numberOfYeardaySchedulesPerUser; - return *this; - } - ParamBuilder & SetNumberOfHolidaySchedules(uint8_t numberOfHolidaySchedules) - { - lockParam_.numberOfHolidaySchedules = numberOfHolidaySchedules; - return *this; - } - LockParam GetLockParam() { return lockParam_; } - -private: - LockParam lockParam_; -}; - -} // namespace LockInitParams -} // namespace EFR32DoorLock - -using namespace ::chip; -using namespace EFR32DoorLock::ResourceRanges; - -class LockManager -{ -public: - enum Action_t - { - LOCK_ACTION = 0, - UNLOCK_ACTION, - - INVALID_ACTION - } Action; - - enum State_t - { - kState_LockInitiated = 0, - kState_LockCompleted, - kState_UnlockInitiated, - kState_UnlockCompleted, - } State; - - CHIP_ERROR Init(chip::app::DataModel::Nullable state, - EFR32DoorLock::LockInitParams::LockParam lockParam); - bool NextState(); - bool IsActionInProgress(); - bool InitiateAction(int32_t aActor, Action_t aAction); - - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); - void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - - bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); - bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); - - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, - EmberAfPluginDoorLockCredentialInfo & credential); - - bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); - - DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule); - - DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - - DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule); - - DlStatus SetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime); - - DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); - - DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); - - bool IsValidUserIndex(uint16_t userIndex); - bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); - bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); - bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); - bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); - - bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err); - const char * lockStateToString(DlLockState lockState) const; - - bool ReadConfigValues(); - -private: - friend LockManager & LockMgr(); - State_t mState; - - Callback_fn_initiated mActionInitiated_CB; - Callback_fn_completed mActionCompleted_CB; - - void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); - - static void TimerEventHandler(TimerHandle_t xTimer); - static void AutoLockTimerEventHandler(AppEvent * aEvent); - static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - - EmberAfPluginDoorLockUserInfo mLockUsers[kMaxUsers]; - EmberAfPluginDoorLockCredentialInfo mLockCredentials[kMaxCredentials]; - WeekDaysScheduleInfo mWeekdaySchedule[kMaxUsers][kMaxWeekdaySchedulesPerUser]; - YearDayScheduleInfo mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; - HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; - - char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; - uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; - DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; - - static LockManager sLock; - EFR32DoorLock::LockInitParams::LockParam LockParams; -}; - -inline LockManager & LockMgr() -{ - return LockManager::sLock; -} diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp deleted file mode 100644 index 8cd16f2a5a52cd..00000000000000 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/* - * - * 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 "AppTask.h" -#include "AppConfig.h" -#include "AppEvent.h" -#if defined(ENABLE_CHIP_SHELL) -#include "EventHandlerLibShell.h" -#endif // ENABLE_CHIP_SHELL - -#ifdef ENABLE_WSTK_LEDS -#include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS - -#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 -#include - -#include - -#include - -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#define LOCK_STATE_LED &sl_led_led1 -#endif // ENABLE_WSTK_LEDS - -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_LOCK_SWITCH &sl_button_btn1 - -using chip::app::Clusters::DoorLock::DlLockState; -using chip::app::Clusters::DoorLock::DlOperationError; -using chip::app::Clusters::DoorLock::DlOperationSource; - -using namespace chip; -using namespace ::chip::DeviceLayer; -using namespace ::chip::DeviceLayer::Internal; -using namespace EFR32DoorLock::LockInitParams; - -namespace { -#ifdef ENABLE_WSTK_LEDS -LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS - -EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; -} // namespace -/********************************************************** - * 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 - AppTask::GetAppTask().StopStatusLEDTimer(); -#endif -} - -void OnTriggerIdentifyEffect(Identify * identify) -{ - 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 - AppTask::GetAppTask().StartStatusLEDTimer(); -#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 }, - AppTask::GetAppTask().OnIdentifyStart, - AppTask::GetAppTask().OnIdentifyStop, - EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, - OnTriggerIdentifyEffect, -}; - -} // namespace - -using namespace chip::TLV; -using namespace ::chip::DeviceLayer; - -AppTask AppTask::sAppTask; - -CHIP_ERROR AppTask::Init() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - -#ifdef DISPLAY_ENABLED - GetLCD().Init((uint8_t *) "Lock-App", true); -#endif - - err = BaseApplication::Init(&gIdentify); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("BaseApplication::Init() failed"); - appError(err); - } - -#if defined(ENABLE_CHIP_SHELL) - err = RegisterLockEvents(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("RegisterLockEvents() failed"); - appError(err); - } -#endif // ENABLE_CHIP_SHELL - - // Initial lock state - chip::app::DataModel::Nullable state; - chip::EndpointId endpointId{ 1 }; - chip::DeviceLayer::PlatformMgr().LockChipStack(); - chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state); - - uint8_t numberOfCredentialsPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 " - "[endpointId=%d]", - endpointId); - numberOfCredentialsPerUser = 5; - } - - uint16_t numberOfUsers = 0; - if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfUsers)) - { - ChipLogError(Zcl, - "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfUsers = 10; - } - - uint8_t numberOfWeekdaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekdaySchedulesPerUser)) - { - ChipLogError( - Zcl, - "Unable to get number of supported weekday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfWeekdaySchedulesPerUser = 10; - } - - uint8_t numberOfYeardaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYeardaySchedulesPerUser)) - { - ChipLogError( - Zcl, - "Unable to get number of supported yearday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfYeardaySchedulesPerUser = 10; - } - - uint8_t numberOfHolidaySchedules = 0; - if (!DoorLockServer::Instance().GetNumberOfHolidaySchedulesSupported(endpointId, numberOfHolidaySchedules)) - { - ChipLogError( - Zcl, - "Unable to get number of supported holiday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfHolidaySchedules = 10; - } - - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - err = LockMgr().Init(state, - ParamBuilder() - .SetNumberOfUsers(numberOfUsers) - .SetNumberOfCredentialsPerUser(numberOfCredentialsPerUser) - .SetNumberOfWeekdaySchedulesPerUser(numberOfWeekdaySchedulesPerUser) - .SetNumberOfYeardaySchedulesPerUser(numberOfYeardaySchedulesPerUser) - .SetNumberOfHolidaySchedules(numberOfHolidaySchedules) - .GetLockParam()); - - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("LockMgr().Init() failed"); - appError(err); - } - - LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); - -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs - sLockLED.Init(LOCK_STATE_LED); - sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS - - chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); - - ConfigurationMgr().LogDeviceConfig(); - - return err; -} - -CHIP_ERROR AppTask::StartAppTask() -{ - return BaseApplication::StartAppTask(AppTaskMain); -} - -void AppTask::AppTaskMain(void * pvParameter) -{ - AppEvent event; - QueueHandle_t sAppEventQueue = *(static_cast(pvParameter)); - - CHIP_ERROR err = sAppTask.Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("AppTask.Init() failed"); - appError(err); - } - -#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) - sAppTask.StartStatusLEDTimer(); -#endif - - SILABS_LOG("App Task started"); - - // Users and credentials should be checked once from nvm flash on boot - LockMgr().ReadConfigValues(); - - 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.StartStatusLEDTimer(); -#endif -} - -void AppTask::OnIdentifyStop(Identify * identify) -{ - ChipLogProgress(Zcl, "onIdentifyStop"); - -#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 - sAppTask.StopStatusLEDTimer(); -#endif -} - -void AppTask::LockActionEventHandler(AppEvent * aEvent) -{ - bool initiated = false; - LockManager::Action_t action; - int32_t actor; - CHIP_ERROR err = CHIP_NO_ERROR; - - if (aEvent->Type == AppEvent::kEventType_Lock) - { - action = static_cast(aEvent->LockEvent.Action); - actor = aEvent->LockEvent.Actor; - } - else if (aEvent->Type == AppEvent::kEventType_Button) - { - if (LockMgr().NextState() == true) - { - action = LockManager::LOCK_ACTION; - } - else - { - action = LockManager::UNLOCK_ACTION; - } - actor = AppEvent::kEventType_Button; - } - else - { - err = APP_ERROR_UNHANDLED_EVENT; - } - - if (err == CHIP_NO_ERROR) - { - initiated = LockMgr().InitiateAction(actor, action); - - if (!initiated) - { - SILABS_LOG("Action is already in progress or active."); - } - } -} - -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_LOCK_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) - { - button_event.Handler = LockActionEventHandler; - sAppTask.PostEvent(&button_event); - } - else if (buttonHandle == APP_FUNCTION_BUTTON) - { - button_event.Handler = BaseApplication::ButtonHandler; - sAppTask.PostEvent(&button_event); - } -} - -void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) -{ - if (aAction == LockManager::UNLOCK_ACTION || aAction == LockManager::LOCK_ACTION) - { - bool locked = (aAction == LockManager::LOCK_ACTION); - SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS - sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS - -#ifdef DISPLAY_ENABLED - sAppTask.GetLCD().WriteDemoUI(locked); -#endif // DISPLAY_ENABLED - } - - if (aActor == AppEvent::kEventType_Button) - { - sAppTask.mSyncClusterToButtonAction = true; - } -} - -void AppTask::ActionCompleted(LockManager::Action_t aAction) -{ - // if the action has been completed by the lock, update the lock trait. - // Turn off the lock LED if in a LOCKED state OR - // Turn on the lock LED if in an UNLOCKED state. - if (aAction == LockManager::LOCK_ACTION) - { - SILABS_LOG("Lock Action has been completed") - } - else if (aAction == LockManager::UNLOCK_ACTION) - { - SILABS_LOG("Unlock Action has been completed") - } - - if (sAppTask.mSyncClusterToButtonAction) - { - chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); - sAppTask.mSyncClusterToButtonAction = false; - } -} - -void AppTask::ActionRequest(int32_t aActor, LockManager::Action_t aAction) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Lock; - event.LockEvent.Actor = aActor; - event.LockEvent.Action = aAction; - event.Handler = LockActionEventHandler; - PostEvent(&event); -} - -void AppTask::UpdateClusterState(intptr_t context) -{ - bool unlocked = LockMgr().NextState(); - DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked; - - DlOperationSource source = DlOperationSource::kUnspecified; - - // write the new lock value - EmberAfStatus status = - DoorLockServer::Instance().SetLockState(1, newState, source) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - SILABS_LOG("ERR: updating lock state %x", status); - } -} diff --git a/examples/lock-app/efr32/src/EventHandlerLibShell.cpp b/examples/lock-app/efr32/src/EventHandlerLibShell.cpp deleted file mode 100644 index 02979f56238a23..00000000000000 --- a/examples/lock-app/efr32/src/EventHandlerLibShell.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * 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. - */ - -#include "EventHandlerLibShell.h" -#include "AppTask.h" -#include "lib/shell/Engine.h" -#include "lib/shell/commands/Help.h" - -#include "app/server/Server.h" -#include "platform/CHIPDeviceLayer.h" -#include - -constexpr uint8_t lockEndpoint = 1; - -using namespace chip; -using namespace chip::app; -using namespace Clusters::DoorLock; -using Shell::Engine; -using Shell::shell_command_t; -using Shell::streamer_get; -using Shell::streamer_printf; - -Engine sShellDoorlockSubCommands; -Engine sShellDoorlockEventSubCommands; -Engine sShellDoorlockEventAlarmSubCommands; -Engine sShellDoorlockEventDoorStateSubCommands; - -/******************************************************** - * Doorlock shell functions - *********************************************************/ - -CHIP_ERROR DoorlockHelpHandler(int argc, char ** argv) -{ - sShellDoorlockSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DoorlockCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return DoorlockHelpHandler(argc, argv); - } - - return sShellDoorlockSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * Event shell functions - *********************************************************/ - -CHIP_ERROR EventHelpHandler(int argc, char ** argv) -{ - sShellDoorlockEventSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR EventDoorlockCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return EventHelpHandler(argc, argv); - } - - return sShellDoorlockEventSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * Alarm shell functions - *********************************************************/ - -CHIP_ERROR AlarmHelpHandler(int argc, char ** argv) -{ - sShellDoorlockEventAlarmSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR AlarmEventHandler(int argc, char ** argv) -{ - - if (argc == 0) - { - return AlarmHelpHandler(argc, argv); - } - if (argc >= 2) - { - ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); - return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; - } - - AlarmEventData * data = Platform::New(); - data->eventId = Events::DoorLockAlarm::Id; - data->alarmCode = static_cast(atoi(argv[0])); - - DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); - - return CHIP_NO_ERROR; -} - -/******************************************************** - * Door state shell functions - *********************************************************/ - -CHIP_ERROR DoorStateHelpHandler(int argc, char ** argv) -{ - sShellDoorlockEventDoorStateSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR DoorStateEventHandler(int argc, char ** argv) -{ - - if (argc == 0) - { - return DoorStateHelpHandler(argc, argv); - } - if (argc >= 2) - { - ChipLogError(Zcl, "Too many arguments provided to function %s, line %d", __func__, __LINE__); - return APP_ERROR_TOO_MANY_SHELL_ARGUMENTS; - } - - DoorStateEventData * data = Platform::New(); - data->eventId = Events::DoorStateChange::Id; - data->doorState = static_cast(atoi(argv[0])); - - DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); - - return CHIP_NO_ERROR; -} - -/** - * @brief configures lock matter shell - * - */ - -CHIP_ERROR RegisterLockEvents() -{ - static const shell_command_t sDoorlockSubCommands[] = { { &DoorlockHelpHandler, "help", "Usage: doorlock " }, - { &EventDoorlockCommandHandler, "event", - " Usage: doorlock event " } }; - - static const shell_command_t sDoorlockEventSubCommands[] = { - { &EventHelpHandler, "help", "Usage : doorlock event " }, - { &AlarmEventHandler, "lock-alarm", "Sends lock alarm event to lock app" }, - { &DoorStateEventHandler, "door-state-change", "Sends door state change event to lock app" } - }; - - static const shell_command_t sDoorlockEventAlarmSubCommands[] = { { &AlarmHelpHandler, "help", - "Usage : doorlock event lock-alarm AlarmCode" } }; - - static const shell_command_t sDoorlockEventDoorStateSubCommands[] = { - { &DoorStateHelpHandler, "help", "Usage : doorlock event door-state-change DoorState" } - }; - - static const shell_command_t sDoorLockCommand = { &DoorlockCommandHandler, "doorlock", - "doorlock commands. Usage: doorlock " }; - - sShellDoorlockEventAlarmSubCommands.RegisterCommands(sDoorlockEventAlarmSubCommands, ArraySize(sDoorlockEventAlarmSubCommands)); - - sShellDoorlockEventDoorStateSubCommands.RegisterCommands(sDoorlockEventDoorStateSubCommands, - ArraySize(sDoorlockEventDoorStateSubCommands)); - - sShellDoorlockEventSubCommands.RegisterCommands(sDoorlockEventSubCommands, ArraySize(sDoorlockEventSubCommands)); - sShellDoorlockSubCommands.RegisterCommands(sDoorlockSubCommands, ArraySize(sDoorlockSubCommands)); - - Engine::Root().RegisterCommands(&sDoorLockCommand, 1); - - return CHIP_NO_ERROR; -} - -void EventWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "EventWorkerFunction - Invalid work data")); - - EventData * data = reinterpret_cast(context); - - switch (data->eventId) - { - case Events::DoorLockAlarm::Id: { - AlarmEventData * alarmData = reinterpret_cast(context); - DoorLockServer::Instance().SendLockAlarmEvent(lockEndpoint, alarmData->alarmCode); - break; - } - - case Events::DoorStateChange::Id: { - DoorStateEventData * doorStateData = reinterpret_cast(context); - DoorLockServer::Instance().SetDoorState(lockEndpoint, doorStateData->doorState); - break; - } - - default: { - ChipLogError(Zcl, "Invalid Event Id %s, line %d", __func__, __LINE__); - break; - } - } -} diff --git a/examples/lock-app/efr32/src/LockManager.cpp b/examples/lock-app/efr32/src/LockManager.cpp deleted file mode 100644 index abc7b4513e2f71..00000000000000 --- a/examples/lock-app/efr32/src/LockManager.cpp +++ /dev/null @@ -1,709 +0,0 @@ -/* - * - * 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 "LockManager.h" - -#include "AppConfig.h" -#include "AppTask.h" -#include -#include -#include -#include - -LockManager LockManager::sLock; - -TimerHandle_t sLockTimer; - -using namespace ::chip::DeviceLayer::Internal; -using namespace EFR32DoorLock::LockInitParams; - -CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable state, LockParam lockParam) -{ - - LockParams = lockParam; - - if (LockParams.numberOfUsers > kMaxUsers) - { - SILABS_LOG("Max number of users is greater than %d, the maximum amount of users currently supported on this platform", - kMaxUsers); - return APP_ERROR_ALLOCATION_FAILED; - } - - if (LockParams.numberOfCredentialsPerUser > kMaxCredentialsPerUser) - { - SILABS_LOG("Max number of credentials per user is greater than %d, the maximum amount of users currently supported on this " - "platform", - kMaxCredentialsPerUser); - return APP_ERROR_ALLOCATION_FAILED; - } - - if (LockParams.numberOfWeekdaySchedulesPerUser > kMaxWeekdaySchedulesPerUser) - { - SILABS_LOG( - "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", - kMaxWeekdaySchedulesPerUser); - return APP_ERROR_ALLOCATION_FAILED; - } - - if (LockParams.numberOfYeardaySchedulesPerUser > kMaxYeardaySchedulesPerUser) - { - SILABS_LOG( - "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", - kMaxYeardaySchedulesPerUser); - return APP_ERROR_ALLOCATION_FAILED; - } - - if (LockParams.numberOfHolidaySchedules > kMaxHolidaySchedules) - { - SILABS_LOG( - "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", - kMaxHolidaySchedules); - return APP_ERROR_ALLOCATION_FAILED; - } - - // Create FreeRTOS sw timer for lock timer. - sLockTimer = xTimerCreate("lockTmr", // 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 = lock obj context - TimerEventHandler // timer callback handler - ); - - if (sLockTimer == NULL) - { - SILABS_LOG("sLockTimer timer create failed"); - return APP_ERROR_CREATE_TIMER_FAILED; - } - - if (state.Value() == DlLockState::kUnlocked) - mState = kState_UnlockCompleted; - else - mState = kState_LockCompleted; - - return CHIP_NO_ERROR; -} - -bool LockManager::IsValidUserIndex(uint16_t userIndex) -{ - return (userIndex < kMaxUsers); -} - -bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type) -{ - if (DlCredentialType::kProgrammingPIN == type) - { - return (0 == credentialIndex); // 0 is required index for Programming PIN - } - return (credentialIndex < kMaxCredentialsPerUser); -} - -bool LockManager::IsValidWeekdayScheduleIndex(uint8_t scheduleIndex) -{ - return (scheduleIndex < kMaxWeekdaySchedulesPerUser); -} - -bool LockManager::IsValidYeardayScheduleIndex(uint8_t scheduleIndex) -{ - return (scheduleIndex < kMaxYeardaySchedulesPerUser); -} - -bool LockManager::IsValidHolidayScheduleIndex(uint8_t scheduleIndex) -{ - return (scheduleIndex < kMaxHolidaySchedules); -} - -bool LockManager::ReadConfigValues() -{ - size_t outLen; - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_LockUserName, reinterpret_cast(mUserNames), - sizeof(mUserNames), outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_CredentialData, reinterpret_cast(mCredentialData), - sizeof(mCredentialData), outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, - outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), - sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * - LockParams.numberOfUsers, - outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), - sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * - LockParams.numberOfUsers, - outLen); - - SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_HolidaySchedules, reinterpret_cast(&(mHolidaySchedule)), - sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules, outLen); - - return true; -} - -void LockManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB) -{ - mActionInitiated_CB = aActionInitiated_CB; - mActionCompleted_CB = aActionCompleted_CB; -} - -bool LockManager::IsActionInProgress() -{ - return (mState == kState_LockInitiated || mState == kState_UnlockInitiated); -} - -bool LockManager::NextState() -{ - return (mState == kState_UnlockCompleted); -} - -bool LockManager::InitiateAction(int32_t aActor, Action_t aAction) -{ - bool action_initiated = false; - State_t new_state; - - // Initiate Turn Lock/Unlock Action only when the previous one is complete. - if (mState == kState_LockCompleted && aAction == UNLOCK_ACTION) - { - action_initiated = true; - - new_state = kState_UnlockInitiated; - } - else if (mState == kState_UnlockCompleted && aAction == LOCK_ACTION) - { - action_initiated = true; - - new_state = kState_LockInitiated; - } - - if (action_initiated) - { - - StartTimer(ACTUATOR_MOVEMENT_PERIOS_MS); - - // Since the timer started successfully, update the state and trigger callback - mState = new_state; - - if (mActionInitiated_CB) - { - mActionInitiated_CB(aAction, aActor); - } - } - - return action_initiated; -} - -void LockManager::StartTimer(uint32_t aTimeoutMs) -{ - if (xTimerIsTimerActive(sLockTimer)) - { - SILABS_LOG("app timer already started!"); - CancelTimer(); - } - - // 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(sLockTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS) - { - SILABS_LOG("sLockTimer timer start() failed"); - appError(APP_ERROR_START_TIMER_FAILED); - } -} - -void LockManager::CancelTimer(void) -{ - if (xTimerStop(sLockTimer, 0) == pdFAIL) - { - SILABS_LOG("sLockTimer stop() failed"); - appError(APP_ERROR_STOP_TIMER_FAILED); - } -} - -void LockManager::TimerEventHandler(TimerHandle_t xTimer) -{ - // Get lock obj context from timer id. - LockManager * lock = static_cast(pvTimerGetTimerID(xTimer)); - - // The timer event handler will be called in the context of the timer task - // once sLockTimer expires. Post an event to apptask queue with the actual handler - // so that the event can be handled in the context of the apptask. - AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.TimerEvent.Context = lock; - event.Handler = ActuatorMovementTimerEventHandler; - AppTask::GetAppTask().PostEvent(&event); -} - -void LockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) -{ - Action_t actionCompleted = INVALID_ACTION; - - LockManager * lock = static_cast(aEvent->TimerEvent.Context); - - if (lock->mState == kState_LockInitiated) - { - lock->mState = kState_LockCompleted; - actionCompleted = LOCK_ACTION; - } - else if (lock->mState == kState_UnlockInitiated) - { - lock->mState = kState_UnlockCompleted; - actionCompleted = UNLOCK_ACTION; - } - - if (actionCompleted != INVALID_ACTION) - { - if (lock->mActionCompleted_CB) - { - lock->mActionCompleted_CB(actionCompleted); - } - } -} - -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) -{ - return setLockState(endpointId, DlLockState::kLocked, pin, err); -} - -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) -{ - return setLockState(endpointId, DlLockState::kUnlocked, pin, err); -} - -bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed - - userIndex--; - - VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - - ChipLogProgress(Zcl, "Door Lock App: LockManager::GetUser [endpoint=%d,userIndex=%hu]", endpointId, userIndex); - - const auto & userInDb = mLockUsers[userIndex]; - - user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) - { - ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", endpointId); - return true; - } - - user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); - user.userUniqueId = userInDb.userUniqueId; - user.userType = userInDb.userType; - user.credentialRule = userInDb.credentialRule; - // So far there's no way to actually create the credential outside Matter, so here we always set the creation/modification - // source to Matter - user.creationSource = DlAssetSource::kMatterIM; - user.createdBy = userInDb.createdBy; - user.modificationSource = DlAssetSource::kMatterIM; - user.lastModifiedBy = userInDb.lastModifiedBy; - - ChipLogDetail(Zcl, - "Found occupied user " - "[endpoint=%d,name=\"%.*s\",credentialsCount=%u,uniqueId=%lx,type=%u,credentialRule=%u," - "createdBy=%d,lastModifiedBy=%d]", - endpointId, static_cast(user.userName.size()), user.userName.data(), user.credentials.size(), - user.userUniqueId, to_underlying(user.userType), to_underlying(user.credentialRule), user.createdBy, - user.lastModifiedBy); - - return true; -} - -bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) -{ - ChipLogProgress(Zcl, - "Door Lock App: LockManager::SetUser " - "[endpoint=%d,userIndex=%d,creator=%d,modifier=%d,userName=%s,uniqueId=%ld " - "userStatus=%u,userType=%u,credentialRule=%u,credentials=%p,totalCredentials=%u]", - endpointId, userIndex, creator, modifier, userName.data(), uniqueId, to_underlying(userStatus), - to_underlying(usertype), to_underlying(credentialRule), credentials, totalCredentials); - - VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed - - userIndex--; - - VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - - auto & userInStorage = mLockUsers[userIndex]; - - if (userName.size() > DOOR_LOCK_MAX_USER_NAME_SIZE) - { - ChipLogError(Zcl, "Cannot set user - user name is too long [endpoint=%d,index=%d]", endpointId, userIndex); - return false; - } - - if (totalCredentials > LockParams.numberOfCredentialsPerUser) - { - ChipLogError(Zcl, "Cannot set user - total number of credentials is too big [endpoint=%d,index=%d,totalCredentials=%u]", - endpointId, userIndex, totalCredentials); - return false; - } - - chip::Platform::CopyString(mUserNames[userIndex], userName); - userInStorage.userName = chip::CharSpan(mUserNames[userIndex], userName.size()); - userInStorage.userUniqueId = uniqueId; - userInStorage.userStatus = userStatus; - userInStorage.userType = usertype; - userInStorage.credentialRule = credentialRule; - userInStorage.lastModifiedBy = modifier; - userInStorage.createdBy = creator; - - for (size_t i = 0; i < totalCredentials; ++i) - { - mCredentials[userIndex][i] = credentials[i]; - mCredentials[userIndex][i].CredentialType = 1; - mCredentials[userIndex][i].CredentialIndex = i + 1; - } - - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); - - // Save user information in NVM flash - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), - sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); - - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); - - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_LockUserName, reinterpret_cast(mUserNames), - sizeof(mUserNames)); - - ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d]", endpointId, userIndex); - - return true; -} - -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - - if (DlCredentialType::kProgrammingPIN == credentialType) - { - VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), - false); // programming pin index is only index allowed to contain 0 - } - else - { - VerifyOrReturnValue(IsValidCredentialIndex(--credentialIndex, credentialType), false); // otherwise, indices are one-indexed - } - - ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", - to_underlying(credentialType), credentialIndex); - - const auto & credentialInStorage = mLockCredentials[credentialIndex]; - - credential.status = credentialInStorage.status; - ChipLogDetail(Zcl, "CredentialStatus: %d, CredentialIndex: %d ", (int) credential.status, credentialIndex); - - if (DlCredentialStatus::kAvailable == credential.status) - { - ChipLogDetail(Zcl, "Found unoccupied credential "); - return true; - } - credential.credentialType = credentialInStorage.credentialType; - credential.credentialData = credentialInStorage.credentialData; - credential.createdBy = credentialInStorage.createdBy; - credential.lastModifiedBy = credentialInStorage.lastModifiedBy; - // So far there's no way to actually create the credential outside Matter, so here we always set the creation/modification - // source to Matter - credential.creationSource = DlAssetSource::kMatterIM; - credential.modificationSource = DlAssetSource::kMatterIM; - - ChipLogDetail(Zcl, "Found occupied credential [type=%u,dataSize=%u]", to_underlying(credential.credentialType), - credential.credentialData.size()); - - return true; -} - -bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, - const chip::ByteSpan & credentialData) -{ - - if (DlCredentialType::kProgrammingPIN == credentialType) - { - VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), - false); // programming pin index is only index allowed to contain 0 - } - else - { - VerifyOrReturnValue(IsValidCredentialIndex(--credentialIndex, credentialType), false); // otherwise, indices are one-indexed - } - - ChipLogProgress(Zcl, - "Door Lock App: LockManager::SetCredential " - "[credentialStatus=%u,credentialType=%u,credentialDataSize=%u,creator=%d,modifier=%d]", - to_underlying(credentialStatus), to_underlying(credentialType), credentialData.size(), creator, modifier); - - auto & credentialInStorage = mLockCredentials[credentialIndex]; - - credentialInStorage.status = credentialStatus; - credentialInStorage.credentialType = credentialType; - credentialInStorage.createdBy = creator; - credentialInStorage.lastModifiedBy = modifier; - - memcpy(mCredentialData[credentialIndex], credentialData.data(), credentialData.size()); - credentialInStorage.credentialData = chip::ByteSpan{ mCredentialData[credentialIndex], credentialData.size() }; - - // Save credential information in NVM flash - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo) * LockParams.numberOfCredentialsPerUser); - - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_CredentialData, reinterpret_cast(&mCredentialData), - sizeof(mCredentialData)); - - ChipLogProgress(Zcl, "Successfully set the credential [credentialType=%u]", to_underlying(credentialType)); - - return true; -} - -DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - - VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed - VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed - - weekdayIndex--; - userIndex--; - - VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); - VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - - const auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, - uint8_t endHour, uint8_t endMinute) -{ - - VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed - VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed - - weekdayIndex--; - userIndex--; - - VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); - VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - - auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; - - scheduleInStorage.schedule.daysMask = daysMask; - scheduleInStorage.schedule.startHour = startHour; - scheduleInStorage.schedule.startMinute = startMinute; - scheduleInStorage.schedule.endHour = endHour; - scheduleInStorage.schedule.endMinute = endMinute; - scheduleInStorage.status = status; - - // Save schedule information in NVM flash - SILABSConfig::WriteConfigValueBin( - SILABSConfig::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), - sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * LockParams.numberOfUsers); - - return DlStatus::kSuccess; -} - -DlStatus LockManager::GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - VerifyOrReturnValue(yearDayIndex > 0, DlStatus::kFailure); // indices are one-indexed - VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed - - yearDayIndex--; - userIndex--; - - VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); - VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - - const auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockManager::SetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime) -{ - VerifyOrReturnValue(yearDayIndex > 0, DlStatus::kFailure); // indices are one-indexed - VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed - - yearDayIndex--; - userIndex--; - - VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); - VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); - - auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; - - scheduleInStorage.schedule.localStartTime = localStartTime; - scheduleInStorage.schedule.localEndTime = localEndTime; - scheduleInStorage.status = status; - - // Save schedule information in NVM flash - SILABSConfig::WriteConfigValueBin( - SILABSConfig::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), - sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * LockParams.numberOfUsers); - - return DlStatus::kSuccess; -} - -DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, - EmberAfPluginDoorLockHolidaySchedule & schedule) -{ - VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed - - holidayIndex--; - - VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); - - const auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) -{ - VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed - - holidayIndex--; - - VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); - - auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; - - scheduleInStorage.schedule.localStartTime = localStartTime; - scheduleInStorage.schedule.localEndTime = localEndTime; - scheduleInStorage.schedule.operatingMode = operatingMode; - scheduleInStorage.status = status; - - // Save schedule information in NVM flash - SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_HolidaySchedules, - reinterpret_cast(&(mHolidaySchedule)), - sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules); - - return DlStatus::kSuccess; -} - -const char * LockManager::lockStateToString(DlLockState lockState) const -{ - switch (lockState) - { - case DlLockState::kNotFullyLocked: - return "Not Fully Locked"; - case DlLockState::kLocked: - return "Locked"; - case DlLockState::kUnlocked: - return "Unlocked"; - case DlLockState::kUnknownEnumValue: - break; - } - - return "Unknown"; -} - -bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err) -{ - - // Assume pin is required until told otherwise - bool requirePin = true; - chip::app::Clusters::DoorLock::Attributes::RequirePINforRemoteOperation::Get(endpointId, &requirePin); - - // If a pin code is not given - if (!pin.HasValue()) - { - ChipLogDetail(Zcl, "Door Lock App: PIN code is not specified [endpointId=%d]", endpointId); - - // If a pin code is not required - if (!requirePin) - { - ChipLogDetail(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), - endpointId); - - DoorLockServer::Instance().SetLockState(endpointId, lockState); - - return true; - } - - ChipLogError(Zcl, "Door Lock App: PIN code is not specified, but it is required [endpointId=%d]", endpointId); - - return false; - } - - // Check the PIN code - for (uint8_t i = 0; i < kMaxCredentials; i++) - { - if (mLockCredentials[i].credentialType != DlCredentialType::kPin || - mLockCredentials[i].status == DlCredentialStatus::kAvailable) - { - continue; - } - - if (mLockCredentials[i].credentialData.data_equal(pin.Value())) - { - ChipLogDetail(Zcl, - "Lock App: specified PIN code was found in the database, setting lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), endpointId); - - DoorLockServer::Instance().SetLockState(endpointId, lockState); - - return true; - } - } - - ChipLogDetail(Zcl, - "Door Lock App: specified PIN code was not found in the database, ignoring command to set lock state to \"%s\" " - "[endpointId=%d]", - lockStateToString(lockState), endpointId); - - err = DlOperationError::kInvalidCredential; - return false; -} diff --git a/examples/lock-app/efr32/src/ZclCallbacks.cpp b/examples/lock-app/efr32/src/ZclCallbacks.cpp deleted file mode 100644 index 9c1812a90c0a04..00000000000000 --- a/examples/lock-app/efr32/src/ZclCallbacks.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * 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 "LockManager.h" -#include - -#include -#include -#include -#include - -using namespace ::chip::app::Clusters; -using namespace ::chip::DeviceLayer::Internal; - -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 == DoorLock::Id && attributeId == DoorLock::Attributes::LockState::Id) - { - DoorLock::DlLockState lockState = *(reinterpret_cast(value)); - ChipLogProgress(Zcl, "Door lock cluster: " ChipLogFormatMEI " state %d", ChipLogValueMEI(clusterId), - to_underlying(lockState)); - } -} - -/** @brief DoorLock 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 - * - */ -void emberAfDoorLockClusterInitCallback(EndpointId endpoint) {} - -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) -{ - ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); - bool status = LockMgr().Lock(endpointId, pinCode, err); - if (status == true) - { - LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION); - } - return status; -} - -bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) -{ - ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); - bool status = LockMgr().Unlock(endpointId, pinCode, err); - if (status == true) - { - LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION); - } - - return status; -} - -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); -} - -bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) -{ - return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, - credentialData); -} - -bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - return LockMgr().GetUser(endpointId, userIndex, user); -} - -bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) -{ - - return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, - credentials, totalCredentials); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - return LockMgr().GetWeekdaySchedule(endpointId, weekdayIndex, userIndex, schedule); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - return LockMgr().GetYeardaySchedule(endpointId, yearDayIndex, userIndex, schedule); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, - EmberAfPluginDoorLockHolidaySchedule & holidaySchedule) -{ - return LockMgr().GetHolidaySchedule(endpointId, holidayIndex, holidaySchedule); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, - uint8_t endHour, uint8_t endMinute) -{ - return LockMgr().SetWeekdaySchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, - endMinute); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime) -{ - return LockMgr().SetYeardaySchedule(endpointId, yearDayIndex, userIndex, status, localStartTime, localEndTime); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) -{ - return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); -} - -void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId) -{ - // Apply the relock state in the application control - LockMgr().InitiateAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION); -} diff --git a/examples/lock-app/efr32/src/main.cpp b/examples/lock-app/efr32/src/main.cpp deleted file mode 100644 index 67ec50bc6c1319..00000000000000 --- a/examples/lock-app/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * 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-Door-Lock" -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(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/lock-app/efr32/third_party/connectedhomeip b/examples/lock-app/efr32/third_party/connectedhomeip deleted file mode 120000 index c866b86874994d..00000000000000 --- a/examples/lock-app/efr32/third_party/connectedhomeip +++ /dev/null @@ -1 +0,0 @@ -../../../.. \ No newline at end of file diff --git a/examples/lock-app/efr32/with_pw_rpc.gni b/examples/lock-app/efr32/with_pw_rpc.gni deleted file mode 100644 index faa281a6a4597c..00000000000000 --- a/examples/lock-app/efr32/with_pw_rpc.gni +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# add this gni as import in your build args to use pigweed in the example -# 'import("//with_pw_rpc.gni")' - -import("//build_overrides/chip.gni") -import("${chip_root}/config/efr32/lib/pw_rpc/pw_rpc.gni") -import("${chip_root}/examples/platform/silabs/efr32/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") - -chip_enable_pw_rpc = true -chip_enable_openthread = true -chip_openthread_ftd = true - -cpp_standard = "gnu++17" - -# To fit in flash -chip_detail_logging = false -show_qr_code = false diff --git a/examples/lock-app/silabs/efr32/build_overrides b/examples/lock-app/silabs/efr32/build_overrides index e578e73312ebd1..995884e6163eb5 120000 --- a/examples/lock-app/silabs/efr32/build_overrides +++ b/examples/lock-app/silabs/efr32/build_overrides @@ -1 +1 @@ -../../build_overrides \ No newline at end of file +../../../build_overrides \ No newline at end of file diff --git a/examples/lock-app/silabs/efr32/third_party/connectedhomeip b/examples/lock-app/silabs/efr32/third_party/connectedhomeip index c866b86874994d..59307833b4fee9 120000 --- a/examples/lock-app/silabs/efr32/third_party/connectedhomeip +++ b/examples/lock-app/silabs/efr32/third_party/connectedhomeip @@ -1 +1 @@ -../../../.. \ No newline at end of file +../../../../.. \ No newline at end of file diff --git a/examples/thermostat/silabs/efr32/.gn b/examples/thermostat/silabs/efr32/.gn deleted file mode 100644 index 4c078f6acefdcc..00000000000000 --- a/examples/thermostat/silabs/efr32/.gn +++ /dev/null @@ -1,29 +0,0 @@ -# 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/silabs/efr32/BUILD.gn b/examples/thermostat/silabs/efr32/BUILD.gn deleted file mode 100644 index 45770a75c1234b..00000000000000 --- a/examples/thermostat/silabs/efr32/BUILD.gn +++ /dev/null @@ -1,390 +0,0 @@ -# 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/silabs/efr32" -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -examples_common_plat_dir = "${chip_root}/examples/platform/silabs" - -declare_args() { - # Dump memory usage at link time. - chip_print_memory_usage = false - - # 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 - - # Enable the temperature sensor - # Some boards do not have a temperature sensor - use_temp_sensor = silabs_board != "BRD2703A" && silabs_board != "BRD4319A" -} - -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) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -# WiFi settings -if (chip_enable_wifi) { - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_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/silabs/EFR32", - "${efr32_project_dir}/include", - "${examples_plat_dir}", - "${chip_root}/src/lib", - "${examples_common_plat_dir}", - ] - - defines = [ - "BOARD_ID=${silabs_board}", - "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" ] - } - } - if (use_temp_sensor) { - include_dirs += [ - "${efr32_sdk_root}/platform/driver/i2cspm/inc", - "${efr32_sdk_root}/app/bluetooth/common/sensor_rht", - "${efr32_sdk_root}/app/bluetooth/common/sensor_rht/config", - "${efr32_sdk_root}/hardware/driver/si70xx/inc", - "${efr32_sdk_root}/app/bluetooth/common/sensor_select", - "${efr32_sdk_root}/platform/common/config", - ] - - defines += [ "USE_TEMP_SENSOR" ] - } -} - -efr32_executable("thermostat_app") { - output_name = "chip-efr32-thermostat-example.out" - public_configs = [ "${efr32_sdk_build_root}:silabs_config" ] - include_dirs = [ "include" ] - defines = [] - - sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", - "src/AppTask.cpp", - "src/SensorManager.cpp", - "src/TemperatureManager.cpp", - "src/ZclCallbacks.cpp", - "src/main.cpp", - ] - - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (use_temp_sensor) { - sources += [ - "${efr32_sdk_root}/app/bluetooth/common/sensor_rht/sl_sensor_rht.c", - "${efr32_sdk_root}/app/bluetooth/common/sensor_select/sl_sensor_select.c", - "${efr32_sdk_root}/hardware/driver/si70xx/src/sl_si70xx.c", - "${efr32_sdk_root}/platform/common/src/sl_status.c", - "${efr32_sdk_root}/platform/driver/i2cspm/src/sl_i2cspm.c", - "${efr32_sdk_root}/platform/emlib/src/em_i2c.c", - "${examples_plat_dir}/TemperatureSensor.cpp", - "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_i2cspm_init.c", - ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - 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:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - - 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/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - "src/ThermostatUI.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_THERMOSTAT=1", - ] - 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_common_plat_dir}/PigweedLogger.cpp", - "${examples_common_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_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - - ldscript = "${examples_plat_dir}/ldscripts/${silabs_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/silabs/efr32/README.md b/examples/thermostat/silabs/efr32/README.md deleted file mode 100644 index 098f652150e49d..00000000000000 --- a/examples/thermostat/silabs/efr32/README.md +++ /dev/null @@ -1,411 +0,0 @@ -# Matter EFR32 Thermostat Example - -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - -
- -- [Matter EFR32 Thermostat Example](#matter-efr32-thermostat-example) - - [Introduction](#introduction) - - [Building](#building) - - [Linux](#linux) - - [Mac OS X](#mac-os-x) - - [Flashing the Application](#flashing-the-application) - - [Viewing Logging Output](#viewing-logging-output) - - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) - - [On Border Router:](#on-border-router) - - [On PC(Linux):](#on-pclinux) - - [Running RPC console](#running-rpc-console) - - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - - [Building options](#building-options) - - [Disabling logging](#disabling-logging) - - [Debug build / release build](#debug-build--release-build) - - [Disabling LCD](#disabling-lcd) - - [KVS maximum entry count](#kvs-maximum-entry-count) - -
- -> **NOTE:** Silicon Laboratories now maintains a public matter GitHub repo with -> frequent releases thoroughly tested and validated. Developers looking to -> develop matter products with silabs hardware are encouraged to use our latest -> release with added tools and documentation. -> [Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) - - - -## Introduction - -The EFR32 Thermostat example provides a baseline demonstration of a thermostat -device, built using Matter and the Silicon Labs gecko SDK. It can be controlled -by a Chip controller over an Openthread or Wifi 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. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the Thread network. - -If the LCD is enabled, 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 Matter 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 ninja-build - -#### Mac OS X - - $ brew install ninja - -- Supported hardware: - - - > For the latest supported hardware please refer to the - > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) - > in the Silicon Labs Matter Github Repo - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / 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=silabs_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/silabs/efr32/args.gni b/examples/thermostat/silabs/efr32/args.gni deleted file mode 100644 index d216faa0a07dae..00000000000000 --- a/examples/thermostat/silabs/efr32/args.gni +++ /dev/null @@ -1,30 +0,0 @@ -# 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}/config/standalone/args.gni") -import("${chip_root}/src/platform/silabs/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" - -openthread_external_platform = - "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/thermostat/silabs/efr32/build_for_wifi_args.gni b/examples/thermostat/silabs/efr32/build_for_wifi_args.gni deleted file mode 100644 index 363d2be9e6f362..00000000000000 --- a/examples/thermostat/silabs/efr32/build_for_wifi_args.gni +++ /dev/null @@ -1,25 +0,0 @@ -# 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}/config/standalone/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") -chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/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/silabs/efr32/build_for_wifi_gnfile.gn b/examples/thermostat/silabs/efr32/build_for_wifi_gnfile.gn deleted file mode 100644 index d391814190d09f..00000000000000 --- a/examples/thermostat/silabs/efr32/build_for_wifi_gnfile.gn +++ /dev/null @@ -1,28 +0,0 @@ -# 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/silabs/efr32/build_overrides b/examples/thermostat/silabs/efr32/build_overrides deleted file mode 120000 index e578e73312ebd1..00000000000000 --- a/examples/thermostat/silabs/efr32/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../build_overrides \ No newline at end of file diff --git a/examples/thermostat/silabs/efr32/include/AppConfig.h b/examples/thermostat/silabs/efr32/include/AppConfig.h deleted file mode 100644 index a936fe1d8abaeb..00000000000000 --- a/examples/thermostat/silabs/efr32/include/AppConfig.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * 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 silabsInitLog(void); - -void efr32Log(const char * aFormat, ...); -#define SILABS_LOG(...) efr32Log(__VA_ARGS__); -void appError(int err); - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/thermostat/silabs/efr32/include/AppEvent.h b/examples/thermostat/silabs/efr32/include/AppEvent.h deleted file mode 100644 index d8d7de44079886..00000000000000 --- a/examples/thermostat/silabs/efr32/include/AppEvent.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * 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_Install, - }; - - uint16_t Type; - - union - { - struct - { - uint8_t Action; - } ButtonEvent; - struct - { - void * Context; - } TimerEvent; - }; - - EventHandler Handler; -}; diff --git a/examples/thermostat/silabs/efr32/include/AppTask.h b/examples/thermostat/silabs/efr32/include/AppTask.h deleted file mode 100644 index ce4fa6f0fef43c..00000000000000 --- a/examples/thermostat/silabs/efr32/include/AppTask.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * 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 - -#ifdef DISPLAY_ENABLED -#include "ThermostatUI.h" -#endif - -#include "AppEvent.h" -#include "BaseApplication.h" -#include "FreeRTOS.h" -#include "SensorManager.h" -#include "TemperatureManager.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 BaseApplication -{ - -public: - AppTask() = default; - - static AppTask & GetAppTask() { return sAppTask; } - - /** - * @brief AppTask task main loop function - * - * @param pvParameter FreeRTOS task parameter - */ - static void AppTaskMain(void * pvParameter); - - CHIP_ERROR StartAppTask(); - - /** - * @brief Request an update of the Thermostat LCD UI - */ - void UpdateThermoStatUI(); - - /** - * @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) override; - - /** - * @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); - -private: - static AppTask sAppTask; - - /** - * @brief AppTask initialisation function - * - * @return CHIP_ERROR - */ - CHIP_ERROR Init(); - - /** - * @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); - - static void ThermostatActionEventHandler(AppEvent * aEvent); -}; diff --git a/examples/thermostat/silabs/efr32/include/CHIPProjectConfig.h b/examples/thermostat/silabs/efr32/include/CHIPProjectConfig.h deleted file mode 100644 index 526cede60faa2a..00000000000000 --- a/examples/thermostat/silabs/efr32/include/CHIPProjectConfig.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * 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 0x800E - -/** - * 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 - * - * 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/silabs/efr32/include/SensorManager.h b/examples/thermostat/silabs/efr32/include/SensorManager.h deleted file mode 100644 index 9c910abb35881e..00000000000000 --- a/examples/thermostat/silabs/efr32/include/SensorManager.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * 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 - -#include -#include - -#include "AppEvent.h" - -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support -#include -#include - -class SensorManager -{ -public: - CHIP_ERROR Init(); - -private: - friend SensorManager & SensorMgr(); - - // Reads new generated sensor value, stores it, and updates local temperature attribute - static void SensorTimerEventHandler(TimerHandle_t xTimer); - - static SensorManager sSensorManager; -}; - -inline SensorManager & SensorMgr() -{ - return SensorManager::sSensorManager; -} diff --git a/examples/thermostat/silabs/efr32/include/TemperatureManager.h b/examples/thermostat/silabs/efr32/include/TemperatureManager.h deleted file mode 100644 index 1005a6753fe450..00000000000000 --- a/examples/thermostat/silabs/efr32/include/TemperatureManager.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * 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 - -#include -#include - -#include "AppEvent.h" - -#include "FreeRTOS.h" -#include "timers.h" // provides FreeRTOS timer support -#include - -#include - -using namespace chip; - -// AppCluster Spec Table 85. -enum ThermMode -{ - OFF = 0, - AUTO, - NOT_USED, - COOL, - HEAT, -}; - -class TemperatureManager -{ -public: - CHIP_ERROR Init(); - void AttributeChangeHandler(EndpointId endpointId, AttributeId attributeId, uint8_t * value, uint16_t size); - uint8_t GetMode(); - int8_t GetCurrentTemp(); - int8_t GetHeatingSetPoint(); - int8_t GetCoolingSetPoint(); - -private: - friend TemperatureManager & TempMgr(); - - int8_t mCurrentTempCelsius; - int8_t mCoolingCelsiusSetPoint; - int8_t mHeatingCelsiusSetPoint; - uint8_t mThermMode; - - int8_t ConvertToPrintableTemp(int16_t temperature); - static TemperatureManager sTempMgr; -}; - -inline TemperatureManager & TempMgr() -{ - return TemperatureManager::sTempMgr; -} diff --git a/examples/thermostat/silabs/efr32/include/ThermostatIcons.h b/examples/thermostat/silabs/efr32/include/ThermostatIcons.h deleted file mode 100644 index 094775fa9f2141..00000000000000 --- a/examples/thermostat/silabs/efr32/include/ThermostatIcons.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * 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 - -#define SILABS_LOGO_WIDTH 47 -#define SILABS_LOGO_HEIGHT 18 -#define BLUETOOTH_ICON_SIZE 18 - -// Status Icon defines -#define STATUS_ICON_LINE 0 -#define SILABS_ICON_POSITION_X 0 -#define BLE_ICON_POSITION_X 72 -#define NETWORK_ICON_POSITION_X 90 -#define MATTER_ICON_POSITION_X 108 - -// Heating/Cooling position -#define HEATING_COOLING_X 90 -#define HEATING_COOLING_Y 40 - -#define BLUETOOTH_ICON_SMALL \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0x7F, 0xFE, 0xEF, 0xF1, 0x7F, 0x9F, 0xFF, 0x7B, 0xFF, 0x1F, 0xFE, 0xFF, 0xFC, 0xFF, \ - 0xF3, 0xFF, 0x87, 0xFF, 0xEF, 0xFD, 0xDF, 0xE7, 0xBF, 0xC7, 0xFF, 0x9F, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F - -#define SILABS_LOGO_SMALL \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, \ - 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x3F, 0xFF, 0xFF, 0xFF, 0x00, 0xE0, 0x9F, 0xFF, 0xE7, 0x3F, 0xE0, 0xF1, 0x83, \ - 0xFF, 0xF9, 0xEF, 0xFF, 0x3F, 0xE0, 0x3F, 0xFC, 0xFF, 0xFF, 0x7F, 0xF8, 0x0F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFE, 0x03, 0xFC, \ - 0xFF, 0xF7, 0x9F, 0xFF, 0x81, 0x07, 0x02, 0xF8, 0xFF, 0xFF, 0xE0, 0x07, 0x00, 0xFE, 0xFF, 0xFF, 0xF8, 0x03, 0xC0, 0xFF, \ - 0xFF, 0xFF, 0xFE, 0x9F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0x3F - -#define HEATING_BITMAP \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, \ - 0x3F, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0xFE, 0x7F, 0xFC, 0x1F, \ - 0x1F, 0xF8, 0xF8, 0x3F, 0x07, 0xE0, 0xFC, 0xBF, 0xC7, 0xE3, 0xFD, 0xFF, 0xE3, 0xC7, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, \ - 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xE3, 0xC7, 0xFF, 0xBF, 0xC7, 0xE3, 0xFD, 0x3F, \ - 0x07, 0xE0, 0xFC, 0x1F, 0x1F, 0xF8, 0xF8, 0x3F, 0xFE, 0x7F, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xBF, 0xFD, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - -#define HEATING_WIDTH 32 -#define HEATING_HEIGHT 32 - -#define COOLING_BITMAP \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFD, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, \ - 0x3F, 0xFC, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0x3F, 0x7F, 0xFE, 0xFC, 0x3F, 0x7F, 0xFE, 0xFC, 0x3F, \ - 0x3E, 0x7C, 0xFC, 0x0F, 0x0C, 0x30, 0xF0, 0xCF, 0x80, 0x01, 0xF3, 0xFF, 0xE3, 0xC7, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, \ - 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xF3, 0xCF, 0xFF, 0xFF, 0xE3, 0xC7, 0xFF, 0xCF, 0x80, 0x01, 0xF3, 0x0F, \ - 0x0C, 0x30, 0xF0, 0x3F, 0x3E, 0x7C, 0xFC, 0x3F, 0x7F, 0xFE, 0xFC, 0x3F, 0x7F, 0xFE, 0xFC, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF, \ - 0x7F, 0xFE, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0xBF, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - -#define HEATING_COOLING_BITMAP \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFC, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, \ - 0xFC, 0xE0, 0xFF, 0xFF, 0xFC, 0xF9, 0xF7, 0x7F, 0xFC, 0xF8, 0xF3, 0x1F, 0xFC, 0xFC, 0xF9, 0x1F, 0x78, 0xFC, 0xFC, 0xFF, \ - 0x01, 0x7C, 0xFE, 0xFF, 0x03, 0x3C, 0xFF, 0xFF, 0xE3, 0x9F, 0xFF, 0xFF, 0xF3, 0x8F, 0xF3, 0xFF, 0xF3, 0x87, 0xE3, 0xFF, \ - 0xF3, 0x83, 0xF7, 0xC7, 0xF0, 0x01, 0xF7, 0x07, 0xF0, 0x00, 0xFF, 0x0F, 0x7F, 0x00, 0xFF, 0xCF, 0x3F, 0x80, 0xFF, 0xCF, \ - 0x1F, 0x80, 0xFF, 0xFF, 0x0F, 0xC0, 0xFF, 0xFF, 0x07, 0xE0, 0xFD, 0xFF, 0xF3, 0xF8, 0xFD, 0xFF, 0xF9, 0xFF, 0xFC, 0xFF, \ - 0xFC, 0x3F, 0xFC, 0x7F, 0xDE, 0xFF, 0xFF, 0x3F, 0x1F, 0xFE, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF - -#define COOLING_WIDTH 32 -#define COOLING_HEIGHT 32 - -// Font for temperature -#define CELSIUS_INDEX 2320 -#define FAHRENHEIT_INDEX 2370 -#define DEGREE_INDEX 2420 - -#define MONACO_FONT_WIDTH 29 -#define MONACO_FONT_NB_LENGTH 232 -#define MONACO_FONT_CH_LENGTH 50 - -#define MONACO_48PT \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, \ - 0x00, 0xF0, 0xFF, 0x7F, 0x00, 0xC0, 0xFF, 0x3F, 0x00, 0x80, 0xFF, 0x1F, 0x60, 0x00, 0xFF, 0x1F, 0xF8, 0x03, 0xFF, 0x0F, \ - 0xFC, 0x07, 0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x07, 0xFC, 0x07, 0xFF, 0x03, 0xFC, 0x03, 0xFF, 0x03, 0xFC, 0x03, \ - 0xFF, 0x01, 0xF8, 0x83, 0xFF, 0x00, 0xF8, 0x83, 0xFF, 0x00, 0xF8, 0x83, 0x7F, 0x30, 0xF8, 0x83, 0x3F, 0x30, 0xF8, 0x83, \ - 0x3F, 0x38, 0xF8, 0x81, 0x1F, 0x3C, 0xF8, 0x81, 0x0F, 0x3C, 0xF8, 0x81, 0x0F, 0x3E, 0xF8, 0x81, 0x07, 0x3E, 0xF8, 0x81, \ - 0x07, 0x3F, 0xF8, 0x83, 0x83, 0x3F, 0xF8, 0x83, 0x81, 0x3F, 0xF8, 0x83, 0xC1, 0x3F, 0xF8, 0x83, 0xE0, 0x1F, 0xF8, 0x03, \ - 0xE0, 0x1F, 0xF8, 0x03, 0xF0, 0x1F, 0xF8, 0x03, 0xF8, 0x1F, 0xFC, 0x07, 0xF8, 0x0F, 0xFC, 0x07, 0xFC, 0x0F, 0xFC, 0x07, \ - 0xFC, 0x07, 0xFE, 0x0F, 0xFC, 0x07, 0xFE, 0x0F, 0xF8, 0x03, 0xFF, 0x1F, 0xE0, 0x00, 0xFF, 0x3F, 0x00, 0x80, 0xFF, 0x7F, \ - 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0x03, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x30 (48: '0')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x03, 0xFC, 0xFF, 0xFF, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xFC, 0xFF, \ - 0x1F, 0x00, 0xFC, 0xFF, 0x0F, 0x10, 0xFC, 0xFF, 0x0F, 0x1C, 0xFC, 0xFF, 0x0F, 0x1E, 0xFC, 0xFF, 0xCF, 0x1F, 0xFC, 0xFF, \ - 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, \ - 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, \ - 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, \ - 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, \ - 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, \ - 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x31 (49: '1')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, \ - 0x3F, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0x80, 0xFF, 0x0F, 0x00, 0x00, 0xFF, 0x0F, 0xF8, 0x00, 0xFF, 0x0F, 0xFF, 0x03, 0xFE, \ - 0xEF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, \ - 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF, \ - 0xFF, 0x7F, 0xC0, 0xFF, 0xFF, 0x3F, 0xE0, 0xFF, 0xFF, 0x1F, 0xF0, 0xFF, 0xFF, 0x0F, 0xF8, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, \ - 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, \ - 0x3F, 0xF0, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, \ - 0x0F, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0xFE, 0x07, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0xFC, \ - 0x07, 0x00, 0x00, 0xFC, 0x07, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x32 (50: '2')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, 0xFF, \ - 0x0F, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0x0F, 0x7C, 0x80, 0xFF, 0x8F, 0xFF, 0x01, 0xFF, \ - 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, \ - 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0x7F, 0xC0, 0xFF, 0xFF, 0x07, 0xE0, 0xFF, \ - 0x7F, 0x00, 0xF0, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0x7F, 0x00, 0xE0, 0xFF, 0x7F, 0x00, 0x80, 0xFF, 0xFF, 0x7F, 0x00, 0xFF, \ - 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, \ - 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, \ - 0xFF, 0xFF, 0x07, 0xFE, 0xF7, 0xFF, 0x07, 0xFE, 0x87, 0xFF, 0x01, 0xFF, 0x07, 0x7C, 0x80, 0xFF, 0x07, 0x00, 0xC0, 0xFF, \ - 0x07, 0x00, 0xE0, 0xFF, 0x0F, 0x00, 0xF0, 0xFF, 0x7F, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x33 (51: '3')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x3F, 0xE0, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, \ - 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x0F, 0xE0, 0xFF, 0xFF, 0x07, 0xE0, 0xFF, 0xFF, 0x07, 0xE0, 0xFF, 0xFF, 0x83, 0xE0, 0xFF, \ - 0xFF, 0x81, 0xE0, 0xFF, 0xFF, 0xC0, 0xE0, 0xFF, 0xFF, 0xE0, 0xE0, 0xFF, 0x7F, 0xE0, 0xE0, 0xFF, 0x3F, 0xF0, 0xE0, 0xFF, \ - 0x3F, 0xF8, 0xE0, 0xFF, 0x1F, 0xF8, 0xE0, 0xFF, 0x0F, 0xFC, 0xE0, 0xFF, 0x0F, 0xFE, 0xE0, 0xFF, 0x07, 0xFE, 0xE0, 0xFF, \ - 0x03, 0xFF, 0xE0, 0xFF, 0x83, 0xFF, 0xE0, 0xFF, 0x81, 0xFF, 0xC0, 0xFF, 0x01, 0x00, 0x00, 0xF0, 0x01, 0x00, 0x00, 0xF0, \ - 0x01, 0x00, 0x00, 0xF0, 0x01, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, \ - 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, \ - 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x34 (52: '4')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0x0F, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0x00, 0xFE, \ - 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, \ - 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xC0, 0xFF, 0xFF, 0x0F, 0x00, 0xFC, 0xFF, \ - 0x0F, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0xC0, 0xFF, 0x0F, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFE, \ - 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, \ - 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, \ - 0xFF, 0xFF, 0x07, 0xFE, 0xEF, 0xFF, 0x03, 0xFE, 0x07, 0xFF, 0x00, 0xFF, 0x07, 0x00, 0x80, 0xFF, 0x07, 0x00, 0xC0, 0xFF, \ - 0x07, 0x00, 0xE0, 0xFF, 0x0F, 0x00, 0xF0, 0xFF, 0xFF, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x35 (53: '5')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xC0, 0xFF, \ - 0xFF, 0x07, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0x7F, 0x80, 0x07, 0xFE, 0x3F, 0xE0, 0x7F, 0xFE, \ - 0x1F, 0xF0, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, \ - 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x03, 0x0F, 0xE0, 0xFF, \ - 0x83, 0x03, 0x80, 0xFF, 0x83, 0x01, 0x00, 0xFF, 0x83, 0x00, 0x00, 0xFE, 0x03, 0xC0, 0x07, 0xFC, 0x03, 0xF0, 0x0F, 0xFC, \ - 0x03, 0xF8, 0x1F, 0xF8, 0x03, 0xFC, 0x3F, 0xF8, 0x03, 0xFC, 0x3F, 0xF8, 0x07, 0xFE, 0x3F, 0xF8, 0x07, 0xFE, 0x3F, 0xF8, \ - 0x07, 0xFE, 0x3F, 0xF8, 0x07, 0xFE, 0x3F, 0xF8, 0x07, 0xFE, 0x3F, 0xF8, 0x0F, 0xFE, 0x3F, 0xF8, 0x0F, 0xFC, 0x1F, 0xF8, \ - 0x0F, 0xFC, 0x1F, 0xFC, 0x1F, 0xF8, 0x0F, 0xFC, 0x1F, 0xF0, 0x07, 0xFE, 0x3F, 0xC0, 0x01, 0xFE, 0x7F, 0x00, 0x00, 0xFF, \ - 0xFF, 0x00, 0x80, 0xFF, 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x36 (54: '6')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, \ - 0xFF, 0xFF, 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x0F, 0xFE, \ - 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, 0xFF, 0xC1, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, \ - 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x3F, 0xF0, 0xFF, 0xFF, 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, \ - 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x83, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xFF, \ - 0xFF, 0xC1, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, \ - 0x7F, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x7F, 0xE0, 0xFF, 0xFF, 0x7F, 0xF0, 0xFF, 0xFF, \ - 0x7F, 0xF0, 0xFF, 0xFF, 0x7F, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x37 (55: '7')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xF8, 0xFF, \ - 0xFF, 0x01, 0xE0, 0xFF, 0xFF, 0x00, 0x80, 0xFF, 0x7F, 0x00, 0x80, 0xFF, 0x3F, 0xE0, 0x00, 0xFF, 0x3F, 0xF8, 0x03, 0xFF, \ - 0x1F, 0xFC, 0x07, 0xFE, 0x1F, 0xFC, 0x0F, 0xFE, 0x1F, 0xFC, 0x0F, 0xFE, 0x1F, 0xFC, 0x0F, 0xFE, 0x1F, 0xFC, 0x07, 0xFE, \ - 0x1F, 0xF8, 0x07, 0xFF, 0x3F, 0xF0, 0x03, 0xFF, 0x3F, 0xE0, 0x81, 0xFF, 0x7F, 0xC0, 0x80, 0xFF, 0x7F, 0x00, 0xC0, 0xFF, \ - 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0x01, 0xF0, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0x7F, 0x00, 0xC0, 0xFF, \ - 0x3F, 0x60, 0x80, 0xFF, 0x1F, 0xF0, 0x00, 0xFF, 0x1F, 0xF8, 0x01, 0xFE, 0x0F, 0xFC, 0x03, 0xFE, 0x0F, 0xFC, 0x07, 0xFC, \ - 0x07, 0xFE, 0x0F, 0xFC, 0x07, 0xFE, 0x0F, 0xFC, 0x07, 0xFF, 0x1F, 0xFC, 0x07, 0xFF, 0x1F, 0xFC, 0x07, 0xFF, 0x1F, 0xFC, \ - 0x07, 0xFE, 0x0F, 0xFC, 0x07, 0xFC, 0x0F, 0xFC, 0x0F, 0xF8, 0x07, 0xFE, 0x0F, 0xE0, 0x01, 0xFE, 0x1F, 0x00, 0x00, 0xFF, \ - 0x3F, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0xE0, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x38 (56: '8')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, \ - 0xFF, 0x00, 0xF0, 0xFF, 0x3F, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0xC0, 0xFF, 0x0F, 0x70, 0x80, 0xFF, 0x07, 0xFC, 0x01, 0xFF, \ - 0x07, 0xFE, 0x03, 0xFF, 0x03, 0xFF, 0x03, 0xFF, 0x83, 0xFF, 0x07, 0xFE, 0x83, 0xFF, 0x07, 0xFE, 0x83, 0xFF, 0x0F, 0xFC, \ - 0xC1, 0xFF, 0x0F, 0xFC, 0xC1, 0xFF, 0x0F, 0xFC, 0xC1, 0xFF, 0x0F, 0xFC, 0x83, 0xFF, 0x07, 0xFC, 0x83, 0xFF, 0x07, 0xFC, \ - 0x83, 0xFF, 0x07, 0xFC, 0x03, 0xFF, 0x03, 0xF8, 0x03, 0xFE, 0x01, 0xF8, 0x07, 0x7C, 0x00, 0xF8, 0x0F, 0x00, 0x00, 0xF8, \ - 0x1F, 0x00, 0x10, 0xF8, 0x3F, 0x00, 0x1C, 0xFC, 0xFF, 0x00, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x1F, 0xFC, \ - 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x0F, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, 0xFF, 0xFF, 0x07, 0xFE, \ - 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0x81, 0xFF, 0xCF, 0xFF, 0x80, 0xFF, 0x0F, 0x3E, 0xC0, 0xFF, 0x0F, 0x00, 0xE0, 0xFF, \ - 0x0F, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x39 (57: '9')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFC, 0x1F, 0xE0, 0x0F, 0xE3, 0xC7, 0xFF, \ - 0xE3, 0xFF, 0xE3, 0xFF, 0xE3, 0xFF, 0xE3, 0xFF, 0xE3, 0xFF, 0xE3, 0xFF, 0xC3, 0xFF, 0x87, 0xEF, 0x0F, 0xE0, 0x1F, 0xE0, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x63 (99: 'c')*/ \ - 0xFF, 0xFB, 0x7F, 0xC0, 0x3F, 0xC0, 0x1F, 0xFF, 0x1F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x03, 0xF0, 0x03, 0xF0, \ - 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, 0x9F, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x66 (102: 'f')*/ \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0xFF, 0xDD, 0xFF, 0xDD, 0xFF, 0xDD, 0xFF, 0xE3, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* Character 0x20 (32: 'degree')*/ diff --git a/examples/thermostat/silabs/efr32/include/ThermostatUI.h b/examples/thermostat/silabs/efr32/include/ThermostatUI.h deleted file mode 100644 index 671bbf8605952b..00000000000000 --- a/examples/thermostat/silabs/efr32/include/ThermostatUI.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * 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 - -#include "ThermostatIcons.h" -#include "glib.h" -#include "lcd.h" - -class ThermostatUI -{ - -public: - // AppCluster Spec Table 85. - enum HVACMode - { - MODE_OFF = 0, - HEATING_COOLING, - NOT_USED, - COOLING, - HEATING, - }; - - static void DrawUI(GLIB_Context_t * glibContext); - static void SetHeatingSetPoint(int8_t temp); - static void SetCoolingSetPoint(int8_t temp); - static void SetCurrentTemp(int8_t temp); - static void SetMode(uint8_t mode); - -private: - static void DrawHeader(GLIB_Context_t * glibContext); - static void DrawFooter(GLIB_Context_t * glibContext, bool autoMode = true); - static void DrawCurrentTemp(GLIB_Context_t * glibContext, int8_t temp, bool isCelsius = true); - static void DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uint8_t initial_y, uint8_t width, uint8_t * data, - uint32_t size); - static void DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, bool secondLine); -}; diff --git a/examples/thermostat/silabs/efr32/src/AppTask.cpp b/examples/thermostat/silabs/efr32/src/AppTask.cpp deleted file mode 100644 index 40418341d8b697..00000000000000 --- a/examples/thermostat/silabs/efr32/src/AppTask.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * - * 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" - -#ifdef ENABLE_WSTK_LEDS -#include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS - -#ifdef DISPLAY_ENABLED -#include "ThermostatUI.h" -#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 -#include -#include -#include -#include - -/********************************************************** - * Defines and Constants - *********************************************************/ - -#define APP_FUNCTION_BUTTON &sl_button_btn0 -#define APP_THERMOSTAT &sl_button_btn1 - -#define MODE_TIMER 1000 // 1s timer period - -using namespace chip; -using namespace chip::TLV; -using namespace ::chip::DeviceLayer; - -/********************************************************** - * Variable declarations - *********************************************************/ -namespace { -EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; - -} -/********************************************************** - * 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 - AppTask::GetAppTask().StopStatusLEDTimer(); -#endif -} - -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 - AppTask::GetAppTask().StartStatusLEDTimer(); -#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 }, - AppTask::GetAppTask().OnIdentifyStart, - AppTask::GetAppTask().OnIdentifyStop, - EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, - OnTriggerIdentifyEffect, -}; - -} // namespace - -/********************************************************** - * AppTask Definitions - *********************************************************/ - -AppTask AppTask::sAppTask; - -CHIP_ERROR AppTask::Init() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - -#ifdef DISPLAY_ENABLED - GetLCD().Init((uint8_t *) "Thermostat-App"); - GetLCD().SetCustomUI(ThermostatUI::DrawUI); -#endif - - err = BaseApplication::Init(&gIdentify); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("BaseApplication::Init() failed"); - appError(err); - } - err = SensorMgr().Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("SensorMgr::Init() failed"); - appError(err); - } - err = TempMgr().Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("TempMgr::Init() failed"); - appError(err); - } - - return err; -} - -CHIP_ERROR AppTask::StartAppTask() -{ - return BaseApplication::StartAppTask(AppTaskMain); -} - -void AppTask::AppTaskMain(void * pvParameter) -{ - AppEvent event; - QueueHandle_t sAppEventQueue = *(static_cast(pvParameter)); - - CHIP_ERROR err = sAppTask.Init(); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("AppTask.Init() failed"); - appError(err); - } - -#if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) - sAppTask.StartStatusLEDTimer(); -#endif - - SILABS_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.StartStatusLEDTimer(); -#endif -} - -void AppTask::OnIdentifyStop(Identify * identify) -{ - ChipLogProgress(Zcl, "onIdentifyStop"); - -#if CHIP_DEVICE_CONFIG_ENABLE_SED == 1 - sAppTask.StopStatusLEDTimer(); -#endif -} - -void AppTask::UpdateThermoStatUI() -{ -#ifdef DISPLAY_ENABLED - ThermostatUI::SetMode(TempMgr().GetMode()); - ThermostatUI::SetHeatingSetPoint(TempMgr().GetHeatingSetPoint()); - ThermostatUI::SetCoolingSetPoint(TempMgr().GetCoolingSetPoint()); - ThermostatUI::SetCurrentTemp(TempMgr().GetCurrentTemp()); - -#ifdef SL_WIFI - if (ConnectivityMgr().IsWiFiStationProvisioned()) -#else - if (ConnectivityMgr().IsThreadProvisioned()) -#endif /* !SL_WIFI */ - { - AppTask::GetAppTask().GetLCD().WriteDemoUI(false); // State doesn't Matter - } -#else - SILABS_LOG("Thermostat Status - M:%d T:%d'C H:%d'C C:%d'C", TempMgr().GetMode(), TempMgr().GetCurrentTemp(), - TempMgr().GetHeatingSetPoint(), TempMgr().GetCoolingSetPoint()); -#endif // DISPLAY_ENABLED -} - -void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) -{ - if (buttonHandle == nullptr) - { - return; - } - - AppEvent aEvent = {}; - aEvent.Type = AppEvent::kEventType_Button; - aEvent.ButtonEvent.Action = btnAction; - - if (buttonHandle == APP_FUNCTION_BUTTON) - { - aEvent.Handler = BaseApplication::ButtonHandler; - sAppTask.PostEvent(&aEvent); - } -} diff --git a/examples/thermostat/silabs/efr32/src/SensorManager.cpp b/examples/thermostat/silabs/efr32/src/SensorManager.cpp deleted file mode 100644 index 427b1dad57d8ed..00000000000000 --- a/examples/thermostat/silabs/efr32/src/SensorManager.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * 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 "SensorManager.h" -#include "AppConfig.h" -#include "AppEvent.h" -#include "AppTask.h" - -#ifdef USE_TEMP_SENSOR -#include "TemperatureSensor.h" -#endif -/********************************************************** - * Defines and Constants - *********************************************************/ - -using namespace chip; -using namespace ::chip::DeviceLayer; - -constexpr EndpointId kThermostatEndpoint = 1; -constexpr uint16_t kSensorTImerPeriodMs = 30000; // 30s timer period -constexpr uint16_t kMinTemperatureDelta = 50; // 0.5 degree Celcius - -/********************************************************** - * Variable declarations - *********************************************************/ - -TimerHandle_t sSensorTimer; -StaticTimer_t sStaticSensorTimerStruct; - -SensorManager SensorManager::sSensorManager; - -#ifndef USE_TEMP_SENSOR -constexpr uint16_t kSimulatedReadingFrequency = (60000 / kSensorTImerPeriodMs); // Change Simulated number at each minutes -static int16_t mSimulatedTemp[] = { 2300, 2400, 2800, 2550, 2200, 2125, 2100, 2600, 1800, 2700 }; -#endif - -CHIP_ERROR SensorManager::Init() -{ - // Create FreeRTOS sw timer for temp sensor timer. - sSensorTimer = xTimerCreateStatic("sensorTmr", pdMS_TO_TICKS(kSensorTImerPeriodMs), true, nullptr, SensorTimerEventHandler, - &sStaticSensorTimerStruct); - - if (sSensorTimer == NULL) - { - SILABS_LOG("sSensorTimer timer create failed"); - return APP_ERROR_CREATE_TIMER_FAILED; - } - -#ifdef USE_TEMP_SENSOR - if (SL_STATUS_OK != TemperatureSensor::Init()) - { - SILABS_LOG("Failed to Init Sensor"); - return CHIP_ERROR_INTERNAL; - } -#endif - - // Update Temp immediatly at bootup - SensorTimerEventHandler(sSensorTimer); - - // Trigger periodic update - xTimerStart(sSensorTimer, portMAX_DELAY); - - return CHIP_NO_ERROR; -} - -void SensorManager::SensorTimerEventHandler(TimerHandle_t xTimer) -{ - int16_t temperature = 0; - static int16_t lastTemperature = 0; - -#ifdef USE_TEMP_SENSOR - int32_t tempSum = 0; - uint32_t humidity = 0; - - for (uint8_t i = 0; i < 100; i++) - { - if (SL_STATUS_OK != TemperatureSensor::GetTemp(&humidity, &temperature)) - { - SILABS_LOG("Failed to read Temperature !!!"); - } - tempSum += temperature; - } - temperature = static_cast(tempSum / 100); -#else - static uint8_t nbOfRepetition = 0; - static uint8_t simulatedIndex = 0; - if (simulatedIndex >= sizeof(mSimulatedTemp)) - { - simulatedIndex = 0; - } - temperature = mSimulatedTemp[simulatedIndex]; - - nbOfRepetition++; - if (nbOfRepetition >= kSimulatedReadingFrequency) - { - simulatedIndex++; - nbOfRepetition = 0; - } -#endif // USE_TEMP_SENSOR - - SILABS_LOG("Sensor Temp is : %d", temperature); - - if ((temperature >= (lastTemperature + kMinTemperatureDelta)) || temperature <= (lastTemperature - kMinTemperatureDelta)) - { - lastTemperature = temperature; - PlatformMgr().LockChipStack(); - // The SensorMagager shouldn't be aware of the Endpoint ID TODO Fix this. - // TODO Per Spec we should also apply the Offset stored in the same cluster before saving the temp - - app::Clusters::Thermostat::Attributes::LocalTemperature::Set(kThermostatEndpoint, temperature); - PlatformMgr().UnlockChipStack(); - } -} diff --git a/examples/thermostat/silabs/efr32/src/TemperatureManager.cpp b/examples/thermostat/silabs/efr32/src/TemperatureManager.cpp deleted file mode 100644 index 30b2ab26b91da8..00000000000000 --- a/examples/thermostat/silabs/efr32/src/TemperatureManager.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * - * 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 "TemperatureManager.h" -#include "AppConfig.h" -#include "AppEvent.h" -#include "AppTask.h" -#include "semphr.h" - -/********************************************************** - * Defines and Constants - *********************************************************/ - -using namespace chip; -using namespace ::chip::DeviceLayer; - -constexpr EndpointId kThermostatEndpoint = 1; - -namespace ThermAttr = chip::app::Clusters::Thermostat::Attributes; -/********************************************************** - * Variable declarations - *********************************************************/ - -TemperatureManager TemperatureManager::sTempMgr; - -CHIP_ERROR TemperatureManager::Init() -{ - app::DataModel::Nullable temp; - int16_t heatingSetpoint, coolingSetpoint; - uint8_t systemMode; - - PlatformMgr().LockChipStack(); - ThermAttr::LocalTemperature::Get(kThermostatEndpoint, temp); - ThermAttr::OccupiedCoolingSetpoint::Get(kThermostatEndpoint, &coolingSetpoint); - ThermAttr::OccupiedHeatingSetpoint::Get(kThermostatEndpoint, &heatingSetpoint); - ThermAttr::SystemMode::Get(kThermostatEndpoint, &systemMode); - PlatformMgr().UnlockChipStack(); - - mCurrentTempCelsius = ConvertToPrintableTemp(temp.Value()); - mHeatingCelsiusSetPoint = ConvertToPrintableTemp(coolingSetpoint); - mCoolingCelsiusSetPoint = ConvertToPrintableTemp(heatingSetpoint); - mThermMode = systemMode; - - AppTask::GetAppTask().UpdateThermoStatUI(); - - return CHIP_NO_ERROR; -} - -int8_t TemperatureManager::ConvertToPrintableTemp(int16_t temperature) -{ - constexpr uint8_t kRoundUpValue = 50; - - // Round up the temperature as we won't print decimals on LCD - // Is it a negative temperature - if (temperature < 0) - { - temperature -= kRoundUpValue; - } - else - { - temperature += kRoundUpValue; - } - - return static_cast(temperature / 100); -} - -void TemperatureManager::AttributeChangeHandler(EndpointId endpointId, AttributeId attributeId, uint8_t * value, uint16_t size) -{ - switch (attributeId) - { - case ThermAttr::LocalTemperature::Id: { - int8_t Temp = ConvertToPrintableTemp(*((int16_t *) value)); - SILABS_LOG("Local temp %d", Temp); - mCurrentTempCelsius = Temp; - } - break; - - case ThermAttr::OccupiedCoolingSetpoint::Id: { - int8_t coolingTemp = ConvertToPrintableTemp(*((int16_t *) value)); - SILABS_LOG("CoolingSetpoint %d", coolingTemp); - mCoolingCelsiusSetPoint = coolingTemp; - } - break; - - case ThermAttr::OccupiedHeatingSetpoint::Id: { - int8_t heatingTemp = ConvertToPrintableTemp(*((int16_t *) value)); - SILABS_LOG("HeatingSetpoint %d", heatingTemp); - mHeatingCelsiusSetPoint = heatingTemp; - } - break; - - case ThermAttr::SystemMode::Id: { - SILABS_LOG("SystemMode %d", static_cast(*value)); - uint8_t mode = static_cast(*value); - if (mThermMode != mode) - { - mThermMode = mode; - } - } - break; - - default: { - SILABS_LOG("Unhandled thermostat attribute %x", attributeId); - return; - } - break; - } - - AppTask::GetAppTask().UpdateThermoStatUI(); -} - -uint8_t TemperatureManager::GetMode() -{ - return mThermMode; -} - -int8_t TemperatureManager::GetCurrentTemp() -{ - return mCurrentTempCelsius; -} -int8_t TemperatureManager::GetHeatingSetPoint() -{ - return mHeatingCelsiusSetPoint; -} - -int8_t TemperatureManager::GetCoolingSetPoint() -{ - return mCoolingCelsiusSetPoint; -} diff --git a/examples/thermostat/silabs/efr32/src/ThermostatUI.cpp b/examples/thermostat/silabs/efr32/src/ThermostatUI.cpp deleted file mode 100644 index 26e15181585839..00000000000000 --- a/examples/thermostat/silabs/efr32/src/ThermostatUI.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * 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 - -#include "ThermostatUI.h" -#include "demo-ui-bitmaps.h" -#include "dmd.h" -#include "glib.h" -#include "lcd.h" - -// LCD line define -constexpr uint8_t kTempLcdInitialX = 30; - -// Bitmap -static const uint8_t silabsLogo[] = { SILABS_LOGO_SMALL }; -static const uint8_t matterLogoBitmap[] = { MATTER_LOGO_BITMAP }; - -static const uint8_t wifiLogo[] = { WIFI_BITMAP }; -static const uint8_t threadLogo[] = { THREAD_BITMAP }; -static const uint8_t bleLogo[] = { BLUETOOTH_ICON_SMALL }; - -static const unsigned char monaco_48pt[] = { MONACO_48PT }; -static const unsigned char heating_bits[] = { HEATING_BITMAP }; -static const unsigned char cooling_bits[] = { COOLING_BITMAP }; -static const unsigned char heating_cooling_bits[] = { HEATING_COOLING_BITMAP }; - -static int8_t mHeatingCelsiusSetPoint; -static int8_t mCoolingCelsiusSetPoint; -static int8_t mCurrentTempCelsius; -static uint8_t mMode; - -#ifdef SL_WIFI -#define UI_WIFI 1 -#else -#define UI_WIFI 0 -#endif - -void ThermostatUI::DrawUI(GLIB_Context_t * glibContext) -{ - if (glibContext == nullptr) - { - SILABS_LOG("Context is null"); - return; - } - - GLIB_clear(glibContext); - DrawHeader(glibContext); - DrawCurrentTemp(glibContext, mCurrentTempCelsius); - DrawFooter(glibContext, false); - - DMD_updateDisplay(); -} - -void ThermostatUI::SetHeatingSetPoint(int8_t temp) -{ - mHeatingCelsiusSetPoint = temp; -} - -void ThermostatUI::SetCoolingSetPoint(int8_t temp) -{ - mCoolingCelsiusSetPoint = temp; -} - -void ThermostatUI::SetCurrentTemp(int8_t temp) -{ - mCurrentTempCelsius = temp; -} -void ThermostatUI::SetMode(uint8_t mode) -{ - mMode = mode; -} - -void ThermostatUI::DrawHeader(GLIB_Context_t * glibContext) -{ - // Draw Silabs Corner icon - GLIB_drawBitmap(glibContext, SILABS_ICON_POSITION_X, STATUS_ICON_LINE, SILABS_LOGO_WIDTH, SILABS_LOGO_HEIGHT, silabsLogo); - // Draw BLE Icon - GLIB_drawBitmap(glibContext, BLE_ICON_POSITION_X, STATUS_ICON_LINE, BLUETOOTH_ICON_SIZE, BLUETOOTH_ICON_SIZE, bleLogo); - // Draw WiFi/OpenThread Icon - GLIB_drawBitmap(glibContext, NETWORK_ICON_POSITION_X, STATUS_ICON_LINE, (UI_WIFI) ? WIFI_BITMAP_HEIGHT : THREAD_BITMAP_WIDTH, - WIFI_BITMAP_HEIGHT, (UI_WIFI) ? wifiLogo : threadLogo); - // Draw Matter Icon - GLIB_drawBitmap(glibContext, MATTER_ICON_POSITION_X, STATUS_ICON_LINE, MATTER_LOGO_WIDTH, MATTER_LOGO_HEIGHT, matterLogoBitmap); - DMD_updateDisplay(); -} - -void ThermostatUI::DrawFooter(GLIB_Context_t * glibContext, bool autoMode) -{ - switch (static_cast(mMode)) - { - case HVACMode::HEATING: - GLIB_drawStringOnLine(glibContext, "Mode : Heating", 11, GLIB_ALIGN_LEFT, 0, 0, true); - GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, heating_bits); - DrawSetPoint(glibContext, mHeatingCelsiusSetPoint, false); - break; - case HVACMode::COOLING: - GLIB_drawStringOnLine(glibContext, "Mode : Cooling", 11, GLIB_ALIGN_LEFT, 0, 0, true); - GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, cooling_bits); - DrawSetPoint(glibContext, mCoolingCelsiusSetPoint, false); - break; - case HVACMode::HEATING_COOLING: - GLIB_drawStringOnLine(glibContext, "Mode : Auto", 11, GLIB_ALIGN_LEFT, 0, 0, true); - GLIB_drawBitmap(glibContext, HEATING_COOLING_X, HEATING_COOLING_Y, COOLING_WIDTH, COOLING_HEIGHT, heating_cooling_bits); - DrawSetPoint(glibContext, mHeatingCelsiusSetPoint, false); - DrawSetPoint(glibContext, mCoolingCelsiusSetPoint, true); - break; - case HVACMode::MODE_OFF: - DrawSetPoint(glibContext, 0, false); - GLIB_drawStringOnLine(glibContext, "Mode : OFF", 11, GLIB_ALIGN_LEFT, 0, 0, true); - break; - default: - break; - } - - DMD_updateDisplay(); -} - -/** - * @brief Draw a 2 digit Temp of screen. Because of this Celsius is used by default - * @param GLIB_Context_t * pointer to the context for the GLIB library - * @param int8_t current Temperature in Celsius - * @param int8_t setPoint in Celsius - * @param bool isCelsius By default set to True. For future development - */ -void ThermostatUI::DrawCurrentTemp(GLIB_Context_t * glibContext, int8_t temp, bool isCelsius) -{ - uint8_t tempArray[2]; - uint8_t position_x = 10; - uint8_t * data; - - if (temp > 99 || temp < -99) - { - // Invalid temp for a house thermostat - return; - } - - if (temp < 0) - { - for (uint8_t y = 60; y < 64; y++) - { - for (uint8_t x = 1; x < 10; x++) - { - GLIB_drawPixel(glibContext, x, y); - } - } - - temp = temp * -1; - } - - // Draw Unit - if (isCelsius) - { - data = (uint8_t *) &monaco_48pt[DEGREE_INDEX]; - DrawFont(glibContext, 65, kTempLcdInitialX, 15, data, MONACO_FONT_CH_LENGTH); - data = (uint8_t *) &monaco_48pt[CELSIUS_INDEX]; - DrawFont(glibContext, 70, kTempLcdInitialX, 15, data, MONACO_FONT_CH_LENGTH); - } - else - { - data = (uint8_t *) &monaco_48pt[DEGREE_INDEX]; - DrawFont(glibContext, 65, 25, 15, data, MONACO_FONT_CH_LENGTH); // 25 to fit with f of fahrenheint - data = (uint8_t *) &monaco_48pt[FAHRENHEIT_INDEX]; - DrawFont(glibContext, 70, kTempLcdInitialX, 15, data, MONACO_FONT_CH_LENGTH); - } - - // Print Current temp - tempArray[0] = (uint8_t)((temp / 10)); - tempArray[1] = (uint8_t)((temp % 10)); - - for (uint8_t ch = 0; ch < 2; ch++) - { - data = (uint8_t *) &monaco_48pt[tempArray[ch] * MONACO_FONT_NB_LENGTH]; - DrawFont(glibContext, position_x, kTempLcdInitialX, MONACO_FONT_WIDTH, data, MONACO_FONT_NB_LENGTH); - position_x += MONACO_FONT_WIDTH; - } -} - -void ThermostatUI::DrawFont(GLIB_Context_t * glibContext, uint8_t initial_x, uint8_t initial_y, uint8_t width, uint8_t * data, - uint32_t size) -{ - uint8_t x = initial_x, y = initial_y; - for (uint16_t i = 0; i < size; i++) - { - for (uint8_t mask = 0; mask < 8; mask++) - { - if (!(data[i] & (0x01 << mask))) - { - GLIB_drawPixel(glibContext, x, y); - } - // Check line changes - if (((x - initial_x) % width) == 0 && x != initial_x) - { - x = initial_x; - y++; - // Font is 8 bit align with paddings bits; - mask = 8; - } - else - { - x++; - } - } - } -} - -void ThermostatUI::DrawSetPoint(GLIB_Context_t * glibContext, int8_t setPoint, bool secondLine) -{ - char setPointLine[] = { '-', 'X', 'X', '\0' }; - - if (setPoint > 99 || setPoint < -99) - { - return; - } - - // Update SetPoint string - if (static_cast(mMode) == ThermostatUI::HVACMode::MODE_OFF) - { - setPointLine[0] = '-'; - setPointLine[1] = '-'; - setPointLine[2] = '\0'; - } - else if (setPoint < 0) - { - setPointLine[0] = (setPoint < 0) ? '-' : ' '; - setPoint *= -1; - setPointLine[1] = ((setPoint / 10) + 0x30); - setPointLine[2] = ((setPoint % 10) + 0x30); - } - else - { - setPointLine[0] = ((setPoint / 10) + 0x30); - setPointLine[1] = ((setPoint % 10) + 0x30); - setPointLine[2] = '\0'; - } - - // Print SetPoint - GLIB_drawStringOnLine(glibContext, setPointLine, (secondLine) ? 8 : 7, GLIB_ALIGN_LEFT, 67, 0, true); -} diff --git a/examples/thermostat/silabs/efr32/src/ZclCallbacks.cpp b/examples/thermostat/silabs/efr32/src/ZclCallbacks.cpp deleted file mode 100644 index 734637d91be401..00000000000000 --- a/examples/thermostat/silabs/efr32/src/ZclCallbacks.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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 "TemperatureManager.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); - } - else if (clusterId == Thermostat::Id) - { - TempMgr().AttributeChangeHandler(attributePath.mEndpointId, attributeId, value, size); - } -} diff --git a/examples/thermostat/silabs/efr32/src/main.cpp b/examples/thermostat/silabs/efr32/src/main.cpp deleted file mode 100644 index e822b71646261e..00000000000000 --- a/examples/thermostat/silabs/efr32/src/main.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * 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(Silabs::GetSilabsDacProvider()); -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - SILABS_LOG("Starting App Task"); - if (AppTask::GetAppTask().StartAppTask() != CHIP_NO_ERROR) - appError(CHIP_ERROR_INTERNAL); - - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - // Should never get here. - chip::Platform::MemoryShutdown(); - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void sl_button_on_change(const sl_button_t * handle) -{ - AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); -} diff --git a/examples/thermostat/silabs/efr32/third_party/connectedhomeip b/examples/thermostat/silabs/efr32/third_party/connectedhomeip deleted file mode 120000 index c866b86874994d..00000000000000 --- a/examples/thermostat/silabs/efr32/third_party/connectedhomeip +++ /dev/null @@ -1 +0,0 @@ -../../../.. \ No newline at end of file diff --git a/examples/window-app/efr32/.gn b/examples/window-app/efr32/.gn deleted file mode 100644 index 4c078f6acefdcc..00000000000000 --- a/examples/window-app/efr32/.gn +++ /dev/null @@ -1,29 +0,0 @@ -# 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/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn deleted file mode 100644 index 93119f1b263aae..00000000000000 --- a/examples/window-app/efr32/BUILD.gn +++ /dev/null @@ -1,322 +0,0 @@ -# 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("${chip_root}/src/platform/device.gni") -import("${efr32_sdk_build_root}/efr32_executable.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") - -assert(current_os == "freertos") - -project_dir = "${chip_root}/examples/window-app" -efr32_project_dir = "${project_dir}/efr32" -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -examples_common_plat_dir = "${chip_root}/examples/platform/silabs" - -declare_args() { - # Dump memory usage at link time. - chip_print_memory_usage = false - - # 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 - - # Argument to force enable WPA3 security - rs91x_wpa3_only = 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) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -# WiFi settings -if (chip_enable_wifi) { - # disabling LCD for MG24 for wifi - if (silabs_board == "BRD4186C" || silabs_board == "BRD4187C") { - show_qr_code = false - disable_lcd = true - } - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_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/silabs/EFR32", - "${efr32_project_dir}/include", - "${examples_plat_dir}", - "${chip_root}/src/lib", - "${examples_common_plat_dir}", - ] - - defines = [ - "BOARD_ID=${silabs_board}", - "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", - ] - - # 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("window_app") { - output_name = "chip-efr32-window-example.out" - public_configs = [ "${efr32_sdk_build_root}:silabs_config" ] - output_dir = root_out_dir - include_dirs = [ - "include", - "${project_dir}/common/include", - ] - defines = [] - - sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", - "${project_dir}/common/src/WindowApp.cpp", - "${project_dir}/common/src/ZclCallbacks.cpp", - "src/WindowAppImpl.cpp", - "src/main.cpp", - ] - - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - - deps = [ - ":sdk", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/examples/window-app/common:window-common", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", - ] - - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # 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 (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - "src/LcdPainter.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ "DISPLAY_ENABLED" ] - - if (show_qr_code) { - deps += [ "${chip_root}/examples/common/QRCode" ] - defines += [ "QR_CODE_ENABLED" ] - } - } - - if (enable_heap_monitoring) { - defines += [ "HEAP_MONITORING" ] - - sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ] - } - - ldscript = "${examples_plat_dir}/ldscripts/${silabs_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", - ] - } - - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } -} - -group("efr32") { - deps = [ ":window_app" ] -} - -group("default") { - deps = [ ":efr32" ] -} diff --git a/examples/window-app/efr32/README.md b/examples/window-app/efr32/README.md deleted file mode 100644 index dda149285a8f91..00000000000000 --- a/examples/window-app/efr32/README.md +++ /dev/null @@ -1,386 +0,0 @@ -# Matter EFR32 Window Covering Example - -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - -
- -- [Matter EFR32 Window Covering Example](#matter-efr32-window-covering-example) - - [Introduction](#introduction) - - [Building](#building) - - [Flashing the Application](#flashing-the-application) - - [Viewing Logging Output](#viewing-logging-output) - - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) - - [OTA Software Update](#ota-software-update) - - [Building options](#building-options) - - [Disabling logging](#disabling-logging) - - [Debug build / release build](#debug-build--release-build) - - [Disabling LCD](#disabling-lcd) - - [KVS maximum entry count](#kvs-maximum-entry-count) - -
- -> **NOTE:** Silicon Laboratories now maintains a public matter GitHub repo with -> frequent releases thoroughly tested and validated. Developers looking to -> develop matter products with silabs hardware are encouraged to use our latest -> release with added tools and documentation. -> [Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) - - - -## Introduction - -The EFR32 window-covering example provides a baseline demonstration of a Window -Covering device, built using Matter and the Silicon Labs gecko SDK. It can be -controlled by a Chip controller over an Openthread or Wifi 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. In the case of Thread, the Thread Network credentials are provided to -the EFR32 device which will then join the Thread network. - -If the LCD is enabled, 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. Once the device is commissioned, the displays shows a -representation of the window covering state. - -The window-covering example is intended to serve both as a means to explore the -workings of Matter as well as a template for creating real products based on the -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 ninja-build - - # Mac OS X - $ brew install ninja - -- Supported hardware: - - - > For the latest supported hardware please refer to the - > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) - > in the Silicon Labs Matter Github Repo - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@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 : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - -* Build the example application: - - cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/window-app/efr32/ ./out/window-app BRD4161A - -- To delete generated executable, libraries and object files use: - - $ cd ~/connectedhomeip - $ rm -rf ./out/ - - OR use GN/Ninja directly - - $ cd ~/connectedhomeip/examples/window-app/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/window-app/efr32 - $ rm -rf out/ - -* Build the example as Sleepy End Device (SED) - - $ ./scripts/examples/gn_efr32_example.sh ./examples/window-app/efr32/ ./out/window-app_SED BRD4161A --sed - - or use gn as previously mentioned but adding the following arguments: - - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' - -* Build the example with pigweed RCP - - $ ./scripts/examples/gn_efr32_example.sh examples/window-app/efr32/ out/window_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - - or use GN/Ninja Directly - - $ cd ~/connectedhomeip/examples/window-app/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/window-app/efr32 - $ python3 out/debug/chip-efr32-window-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 - -- 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. - - **LED 1** Shows the state of the window covering - - - _Solid On_ ; The window cover if fully open - - _Off_ ; The window cover if fully closed - - _Blinking slowly_ ; The window cover is half-open, either by tilt, or lift - - _Blinking quickly_ ; The window cover is being automatically open or closed - - **Push Button 0** Increase either tilt or lift, and factory reset - - - Pressed and release: The lift/tilt increases by 10% - - - 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. - - **Push Button 1** Decreases either tilt or lift, or switch the cover type - - - Pressed and release: The lift/tilt decreases by 10% - - - Press and hold for 3 s: Cycle between window covering type (Rollershade, Drapery, Tilt Blind - Lift and Tilt). - - **Push Button0 and Button1** Switch between lift and tilt - - - Pressing and release both buttons at the same time: switches between lift and tilt modes. Most window covering types support either lift only, or tilt only, but type 0x08 support both (default) - - - Pressing and hold both buttons at the same time: Cycles between window covering 1, and window covering 2. - -* Once the device is provisioned, it will join the Thread network is - established, look for the RTT log - - ``` -     [DL] Device Role: CHILD -     [DL] Partition Id:0x6A7491B7 -     [DL] \_OnPlatformEvent default: event->Type = 32778 -     [DL] OpenThread State Changed (Flags: 0x00000001) -     [DL] Thread Unicast Addresses: -     [DL]    2001:DB8::E1A2:87F1:7D5D:FECA/64 valid preferred -     [DL]    FDDE:AD00:BEEF::FF:FE00:2402/64 valid preferred rloc -     [DL]    FDDE:AD00:BEEF:0:383F:5E81:A05A:B168/64 valid preferred -     [DL]    FE80::D8F2:592E:C109:CF00/64 valid preferred -     [DL] LwIP Thread interface addresses updated -     [DL] FE80::D8F2:592E:C109:CF00 IPv6 link-local address, preferred) -     [DL] FDDE:AD00:BEEF:0:383F:5E81:A05A:B168 Thread mesh-local address, preferred) -     [DL] 2001:DB8::E1A2:87F1:7D5D:FECA IPv6 global unicast address, preferred) - ``` - - (you can verify that the device is on the thread network with the command - `router table` using a serial terminal (screen / minicom etc.) on the board - running the window-app example. You can also get the address list with the - command ipaddr again in the serial terminal ) - - You can provision the Chip device using Chip tool Android or iOS app or - through CLI commands on your OT BR - - The - [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - can now be used to send ZCL commands to the window covering device. For - instance, to set the window covering lift by percentage: - - ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 - - chip-tool onoff on 1 1 - - chip-tool windowcovering go-to-tilt-percentage 50 0 1 1 - ``` - - To see the supported window covering cluster commands, use: - - ``` - chip-tool windowcovering - ``` - -### 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 - - - -## 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/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" - -### Disabling LCD - -show_qr_code - - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-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/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 diff --git a/examples/window-app/efr32/args.gni b/examples/window-app/efr32/args.gni deleted file mode 100644 index 212e702163aa6a..00000000000000 --- a/examples/window-app/efr32/args.gni +++ /dev/null @@ -1,28 +0,0 @@ -# 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}/config/standalone/args.gni") -import("${chip_root}/src/platform/silabs/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 -openthread_external_platform = - "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/window-app/efr32/build_for_wifi_args.gni b/examples/window-app/efr32/build_for_wifi_args.gni deleted file mode 100644 index 8fe1081d6d9b72..00000000000000 --- a/examples/window-app/efr32/build_for_wifi_args.gni +++ /dev/null @@ -1,24 +0,0 @@ -# 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/silabs/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/window-app/efr32/build_for_wifi_gnfile.gn b/examples/window-app/efr32/build_for_wifi_gnfile.gn deleted file mode 100644 index d391814190d09f..00000000000000 --- a/examples/window-app/efr32/build_for_wifi_gnfile.gn +++ /dev/null @@ -1,28 +0,0 @@ -# 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/window-app/efr32/build_overrides b/examples/window-app/efr32/build_overrides deleted file mode 120000 index e578e73312ebd1..00000000000000 --- a/examples/window-app/efr32/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../build_overrides \ No newline at end of file diff --git a/examples/window-app/efr32/include/AppConfig.h b/examples/window-app/efr32/include/AppConfig.h deleted file mode 100644 index 661819aea7648b..00000000000000 --- a/examples/window-app/efr32/include/AppConfig.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * 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 - -// ---- Window Example App Config ---- -#define APP_TASK_NAME "APP" - -// EFR Logging -#ifdef __cplusplus -extern "C" { -#endif - -#define LCD_SIZE 128 -#define LCD_MARGIN_SIZE 1 -#define LCD_BORDER_SIZE 2 -#define LCD_FRAME_SIZE (2 * LCD_MARGIN_SIZE + LCD_BORDER_SIZE) -#define LCD_COVER_SIZE (LCD_SIZE - 2 * LCD_FRAME_SIZE) -#define LIFT_OPEN_LIMIT 0 -#define LIFT_CLOSED_LIMIT (LCD_COVER_SIZE - 1) -#define LIFT_DELTA 1000 // 10% -#define TILT_OPEN_LIMIT 1 -#define TILT_CLOSED_LIMIT (LCD_COVER_SIZE / 10 - 1) -#define TILT_DELTA 1000 // 10% - -#define WINDOW_COVER_COUNT 2 - -#ifndef WINDOW_COVER_ENDPOINT1 -#define WINDOW_COVER_ENDPOINT1 1 -#endif - -#ifndef WINDOW_COVER_ENDPOINT2 -#define WINDOW_COVER_ENDPOINT2 2 -#endif - -#ifndef LONG_PRESS_TIMEOUT -#define LONG_PRESS_TIMEOUT 3000 -#endif - -#ifndef COVER_LIFT_TILT_TIMEOUT -#define COVER_LIFT_TILT_TIMEOUT 500 -#endif - -void silabsInitLog(void); - -void efr32Log(const char * aFormat, ...); -#define SILABS_LOG(...) efr32Log(__VA_ARGS__); - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/window-app/efr32/include/CHIPProjectConfig.h b/examples/window-app/efr32/include/CHIPProjectConfig.h deleted file mode 100644 index 6a12dbc3794c8f..00000000000000 --- a/examples/window-app/efr32/include/CHIPProjectConfig.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * 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 - * - * 0x8009: example window app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8010 - -/** - * 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 - * - * 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_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) - -/** - * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL - * - * The interval (in units of 0.625ms) at which the device will send BLE advertisements while - * in fast advertising mode. - * - * 40 (25ms). - */ -#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL 40 - -/** - * CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL - * - * The interval (in units of 0.625ms) at which the device will send BLE advertisements while - * in slow advertisement mode. - * - * 800 (500ms). - */ -#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL 800 - -/** - * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT - * - * The amount of time in miliseconds after which BLE should change his advertisements - * from fast interval to slow interval. - * - * 30000 (30 secondes). - */ -#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000) - -/** - * @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/window-app/efr32/include/LcdPainter.h b/examples/window-app/efr32/include/LcdPainter.h deleted file mode 100644 index 4a30bdede2c3ea..00000000000000 --- a/examples/window-app/efr32/include/LcdPainter.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * 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 - -// clang-format off -#include "app-common/app-common/zap-generated/enums.h" -#include "app-common/app-common/zap-generated/cluster-enums.h" -// clang-format on - -#include - -#include - -enum class LcdIcon -{ - None = 0, - One, - Two, - Lift, - Tilt -}; - -class PixelPainter -{ -public: - PixelPainter(uint16_t lift, uint16_t tilt); - virtual ~PixelPainter() = default; - virtual uint8_t Color(uint32_t x, uint32_t y) = 0; - -protected: - uint16_t mLift; - uint16_t mTilt; -}; - -class CompositePainter : public PixelPainter -{ -public: - CompositePainter(uint16_t lift, uint16_t tilt, PixelPainter * painter1, PixelPainter * painter2, PixelPainter * painter3); - uint8_t Color(uint32_t x, uint32_t y); - -private: - PixelPainter * mPainter1; - PixelPainter * mPainter2; - PixelPainter * mPainter3; -}; - -class FramePainter : public PixelPainter -{ - using PixelPainter::PixelPainter; - uint8_t Color(uint32_t x, uint32_t y); -}; - -class IconPainter : public PixelPainter -{ -public: - IconPainter(uint16_t lift, uint16_t tilt, LcdIcon icon); - uint8_t Color(uint32_t x, uint32_t y); - -private: - uint8_t mIconSize; - uint8_t mIconOffset; - LcdIcon mIcon; -}; - -class VerticalShadePainter : public PixelPainter -{ -public: - using PixelPainter::PixelPainter; - uint8_t Color(uint32_t x, uint32_t y); -}; - -class HorizontalShadePainter : public PixelPainter -{ -public: - using PixelPainter::PixelPainter; - uint8_t Color(uint32_t x, uint32_t y); -}; - -class VerticalBlindPainter : public PixelPainter -{ -public: - VerticalBlindPainter(uint16_t lift, uint16_t tilt); - uint8_t Color(uint32_t x, uint32_t y); - -private: - constexpr static uint8_t sBandCount = 12; - uint8_t mBandSize; -}; - -class LcdPainter -{ -public: - static void Paint(SilabsLCD & lcd, chip::app::Clusters::WindowCovering::Type type, uint16_t lift, uint16_t tilt, LcdIcon icon); - -private: - static PixelPainter * GetCoverPainter(chip::app::Clusters::WindowCovering::Type type, uint16_t lift, uint16_t tilt); -}; diff --git a/examples/window-app/efr32/include/WindowAppImpl.h b/examples/window-app/efr32/include/WindowAppImpl.h deleted file mode 100644 index a43f68ed85f6ef..00000000000000 --- a/examples/window-app/efr32/include/WindowAppImpl.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#ifdef ENABLE_WSTK_LEDS -#include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS - -#include -#include -#include -#include -#include -#include -#include -#ifdef DISPLAY_ENABLED -#include -#endif - -class WindowAppImpl : public WindowApp -{ -public: - static WindowAppImpl sInstance; - - WindowAppImpl(); - CHIP_ERROR Init() override; - CHIP_ERROR Start() override; - void Finish() override; - void PostEvent(const WindowApp::Event & event) override; - void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) override; - friend void sl_button_on_change(const sl_button_t * handle); - -protected: - struct Timer : public WindowApp::Timer - { - TimerHandle_t mHandler = nullptr; - - Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context); - void IsrStart(); - void Start() override; - void Stop() override; - - private: - static void TimerCallback(TimerHandle_t xTimer); - }; - - struct Button : public WindowApp::Button - { - Button(Button::Id id, const char * name); - }; - - WindowApp::Timer * CreateTimer(const char * name, uint32_t timeoutInMs, WindowApp::Timer::Callback callback, - void * context) override; - WindowApp::Button * CreateButton(WindowApp::Button::Id id, const char * name) override; - void OnButtonChange(const sl_button_t * handle); - void ProcessEvents(); - void DispatchEvent(const WindowApp::Event & event) override; - void UpdateLEDs(); - void UpdateLCD(); - void OnMainLoop() override; - - static void OnTaskCallback(void * parameter); - static void OnIconTimeout(WindowApp::Timer & timer); - -private: - void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute); - TaskHandle_t mHandle = nullptr; - QueueHandle_t mQueue = nullptr; - -#ifdef ENABLE_WSTK_LEDS - LEDWidget mStatusLED; - LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS - - // Get QR Code and emulate its content using NFC tag - char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; -#ifdef DISPLAY_ENABLED - Timer mIconTimer; - LcdIcon mIcon = LcdIcon::None; -#endif -}; diff --git a/examples/window-app/efr32/src/LcdPainter.cpp b/examples/window-app/efr32/src/LcdPainter.cpp deleted file mode 100644 index e1a8041f075c79..00000000000000 --- a/examples/window-app/efr32/src/LcdPainter.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * - * 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 - -using namespace chip::app::Clusters::WindowCovering; - -constexpr uint32_t sTiltIcon[] = { - 0xffffffff, 0xffffffff, 0xc0000003, 0xc0000003, 0xc0000003, 0xc0000003, 0xc1ffffc3, 0xc1ffffc3, - 0xc1ffffc3, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, - 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, 0xc003c003, - 0xc003c003, 0xc003c003, 0xc0000003, 0xc0000003, 0xc0000003, 0xc0000003, 0xffffffff, 0xffffffff, -}; - -constexpr uint32_t sLiftIcon[] = { - 0xffffffff, 0xffffffff, 0xc0000003, 0xc0000003, 0xc0000003, 0xc0000003, 0xc0f00003, 0xc0f00003, - 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, - 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0f00003, 0xc0ffffc3, - 0xc0ffffc3, 0xc0ffffc3, 0xc0000003, 0xc0000003, 0xc0000003, 0xc0000003, 0xffffffff, 0xffffffff, -}; - -constexpr uint32_t sOneIcon[] = { - 0xffffffff, 0xffffffff, 0xc0000003, 0xc0000003, 0xc0000003, 0xc00fe003, 0xc01fe003, 0xc03fe003, - 0xc07fe003, 0xc0fbe003, 0xc1f3e003, 0xc3e3e003, 0xc003e003, 0xc003e003, 0xc003e003, 0xc003e003, - 0xc003e003, 0xc003e003, 0xc003e003, 0xc003e003, 0xc003e003, 0xc003e003, 0xc003e003, 0xc3ffffc3, - 0xc3ffffc3, 0xc3ffffc3, 0xc3ffffc3, 0xc0000003, 0xc0000003, 0xc0000003, 0xffffffff, 0xffffffff, -}; - -constexpr uint32_t sTwoIcon[] = { - 0xffffffff, 0xffffffff, 0xc0000003, 0xc0000003, 0xc0000003, 0xc07ffe03, 0xc0ffff03, 0xc1ffff83, - 0xc3ffffc3, 0xc3f00fc3, 0xc3e007c3, 0xc3e007c3, 0xc00007c3, 0xc00007c3, 0xc0000fc3, 0xc00fff83, - 0xc03fff03, 0xc07ffe03, 0xc0fc0003, 0xc1f80003, 0xc1f00003, 0xc3e00003, 0xc3e00003, 0xc3ffffc3, - 0xc3ffffc3, 0xc3ffffc3, 0xc3ffffc3, 0xc0000003, 0xc0000003, 0xc0000003, 0xffffffff, 0xffffffff, -}; - -PixelPainter::PixelPainter(uint16_t lift, uint16_t tilt) : mLift(lift), mTilt(tilt) {} - -CompositePainter::CompositePainter(uint16_t lift, uint16_t tilt, PixelPainter * painter1, PixelPainter * painter2, - PixelPainter * painter3) : - PixelPainter(lift, tilt), - mPainter1(painter1), mPainter2(painter2), mPainter3(painter3) -{} - -uint8_t CompositePainter::Color(uint32_t x, uint32_t y) -{ - int8_t pixel = -1; - if (mPainter1) - { - pixel = mPainter1->Color(x, y); - if (pixel >= 0) - { - return pixel; - } - } - if (mPainter2) - { - pixel = mPainter2->Color(x, y); - if (pixel >= 0) - { - return pixel; - } - } - if (mPainter3) - { - pixel = mPainter3->Color(x, y); - if (pixel >= 0) - { - return pixel; - } - } - return pixel; -} - -uint8_t FramePainter::Color(uint32_t x, uint32_t y) -{ - if (x < LCD_FRAME_SIZE || x >= (LCD_SIZE - LCD_FRAME_SIZE) || y < LCD_FRAME_SIZE || y >= (LCD_SIZE - LCD_FRAME_SIZE)) - { - if (x < LCD_MARGIN_SIZE || x >= (LCD_SIZE - LCD_MARGIN_SIZE) || y < LCD_MARGIN_SIZE || y >= (LCD_SIZE - LCD_MARGIN_SIZE)) - { - return 0; - } - else - { - return (x < (LCD_MARGIN_SIZE + LCD_BORDER_SIZE)) || (x >= (LCD_SIZE - LCD_BORDER_SIZE - LCD_MARGIN_SIZE)) || - (y < (LCD_MARGIN_SIZE + LCD_BORDER_SIZE)) || (y >= (LCD_SIZE - LCD_BORDER_SIZE - LCD_MARGIN_SIZE)); - } - } - return -1; -} - -IconPainter::IconPainter(uint16_t lift, uint16_t tilt, LcdIcon icon) : PixelPainter(lift, tilt), mIcon(icon) -{ - mIconSize = sizeof(sTiltIcon) / sizeof(uint32_t); - mIconOffset = (LCD_SIZE - mIconSize) / 2; -} - -uint8_t IconPainter::Color(uint32_t x, uint32_t y) -{ - const uint32_t * icon = nullptr; - switch (mIcon) - { - case LcdIcon::One: - icon = sOneIcon; - break; - case LcdIcon::Two: - icon = sTwoIcon; - break; - case LcdIcon::Lift: - icon = sLiftIcon; - break; - case LcdIcon::Tilt: - icon = sTiltIcon; - break; - default: - return -1; - } - if (x >= mIconOffset && x < (mIconOffset + mIconSize) && y >= mIconOffset && y < (mIconOffset + mIconSize)) - { - uint32_t x0 = x - mIconOffset; - uint32_t y0 = y - mIconOffset; - return (icon[y0] & (1 << (31 - x0))) > 0; - } - return -1; -} - -uint8_t VerticalShadePainter::Color(uint32_t x, uint32_t y) -{ - return (y % 2) && y < (uint32_t)(LCD_FRAME_SIZE + mLift); -} - -uint8_t HorizontalShadePainter::Color(uint32_t x, uint32_t y) -{ - return (x % 2) && x < (uint32_t)(LCD_FRAME_SIZE + mLift); -} - -VerticalBlindPainter::VerticalBlindPainter(uint16_t lift, uint16_t tilt) : PixelPainter(lift, tilt) -{ - mBandSize = (LCD_COVER_SIZE / sBandCount); -} - -uint8_t VerticalBlindPainter::Color(uint32_t x, uint32_t y) -{ - if (x % 2) - { - return 0; - } - else - { - uint32_t closedCount = (mLift + 1) / mBandSize; - uint32_t bandCount = (y - LCD_FRAME_SIZE) / mBandSize; - // ChipLogProgress(Zcl, "BLIND: ccount:%u, ccount:%u", clusterId); - if (bandCount <= closedCount) - { - return y <= (LCD_FRAME_SIZE + mBandSize * bandCount + mTilt); - } - else - { - return 0; - } - } -} - -PixelPainter * LcdPainter::GetCoverPainter(Type type, uint16_t lift, uint16_t tilt) -{ - switch (type) - { - case Type::kRollerShade: - case Type::kRollerShade2Motor: - case Type::kRollerShadeExterior: - case Type::kRollerShadeExterior2Motor: - return new VerticalShadePainter(lift, tilt); - case Type::kDrapery: - case Type::kAwning: - return new HorizontalShadePainter(lift, tilt); - case Type::kShutter: - case Type::kTiltBlindTiltOnly: - case Type::kTiltBlindLiftAndTilt: - return new VerticalBlindPainter(lift, tilt); - case Type::kProjectorScreen: - case Type::kUnknown: - default: - return new VerticalShadePainter(lift, tilt); - } - - return nullptr; -} - -void LcdPainter::Paint(SilabsLCD & lcd, Type type, uint16_t lift, uint16_t tilt, LcdIcon icon) -{ - FramePainter framePaint = FramePainter(lift, tilt); - IconPainter iconPaint = IconPainter(lift, tilt, icon); - PixelPainter * coverPaint = GetCoverPainter(type, lift, tilt); - CompositePainter compositePaint = CompositePainter(lift, tilt, &framePaint, &iconPaint, coverPaint); - void * context = lcd.Context(); - - lcd.Clear(); - - for (int i = 0; i < LCD_SIZE; i++) - { - for (int j = 0; j < LCD_SIZE; j++) - { - if (compositePaint.Color(i, j)) - { - lcd.DrawPixel(context, i, j); - } - } - } - lcd.Update(); - delete coverPaint; -} diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp deleted file mode 100644 index dd81caba36278c..00000000000000 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ /dev/null @@ -1,556 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef QR_CODE_ENABLED -#include -#else -#include "EFR32DeviceDataProvider.h" -#include -#include -#endif // QR_CODE_ENABLED -#include - -#ifdef ENABLE_WSTK_LEDS -#include -#endif // ENABLE_WSTK_LEDS - -#include - -#ifdef SL_WIFI -#include "wfx_host_events.h" -#include -#include -#endif - -#ifdef DISPLAY_ENABLED -#include -SilabsLCD slLCD; -#endif - -#define APP_TASK_STACK_SIZE (4096) -#define APP_TASK_PRIORITY 2 -#define APP_EVENT_QUEUE_SIZE 10 -#define EXAMPLE_VENDOR_ID 0xcafe - -#define LCD_ICON_TIMEOUT 1000 - -using namespace chip::app::Clusters::WindowCovering; -using namespace chip; -using namespace ::chip::DeviceLayer; -#define APP_STATE_LED &sl_led_led0 -#define APP_ACTION_LED &sl_led_led1 - -#ifdef SL_WIFI -chip::app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(chip::DeviceLayer::NetworkCommissioning::SlWiFiDriver::GetInstance())); -#endif -//------------------------------------------------------------------------------ -// Timers -//------------------------------------------------------------------------------ - -WindowAppImpl::Timer::Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context) : - WindowApp::Timer(name, timeoutInMs, callback, context) -{ - mHandler = xTimerCreate(name, // Just a text name, not used by the RTOS kernel - timeoutInMs, // == default timer period (mS) - false, // no timer reload (==one-shot) - (void *) this, // init timer id = app task obj context - TimerCallback // timer callback handler - ); - if (mHandler == NULL) - { - SILABS_LOG("Timer create failed"); - appError(CHIP_ERROR_INTERNAL); - } -} - -void WindowAppImpl::Timer::Start() -{ - if (xTimerIsTimerActive(mHandler)) - { - Stop(); - } - - // Timer is not active - if (xTimerStart(mHandler, 100) != pdPASS) - { - SILABS_LOG("Timer start() failed"); - appError(CHIP_ERROR_INTERNAL); - } - - mIsActive = true; -} - -void WindowAppImpl::Timer::IsrStart() -{ - portBASE_TYPE taskWoken = pdFALSE; // For FreeRTOS timer (below). - // Start/restart the button debounce timer (Note ISR version of FreeRTOS - // api call here). - xTimerStartFromISR(mHandler, &taskWoken); - if (taskWoken != pdFALSE) - { - taskYIELD(); - } - mIsActive = true; -} - -void WindowAppImpl::Timer::Stop() -{ - mIsActive = false; - if (xTimerStop(mHandler, 0) == pdFAIL) - { - SILABS_LOG("Timer stop() failed"); - appError(CHIP_ERROR_INTERNAL); - } -} - -void WindowAppImpl::Timer::TimerCallback(TimerHandle_t xTimer) -{ - Timer * timer = (Timer *) pvTimerGetTimerID(xTimer); - if (timer) - { - timer->Timeout(); - } -} - -//------------------------------------------------------------------------------ -// Main Task -//------------------------------------------------------------------------------ - -StackType_t sAppStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t sAppTaskStruct; - -uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(WindowApp::Event)]; -StaticQueue_t sAppEventQueueStruct; - -WindowAppImpl WindowAppImpl::sInstance; - -WindowApp & WindowApp::Instance() -{ - return WindowAppImpl::sInstance; -} - -#ifdef DISPLAY_ENABLED -WindowAppImpl::WindowAppImpl() : mIconTimer("Timer:icon", LCD_ICON_TIMEOUT, OnIconTimeout, this) {} -#else -WindowAppImpl::WindowAppImpl() {} -#endif - -void WindowAppImpl::OnTaskCallback(void * parameter) -{ -#ifdef SL_WIFI - /* - * Wait for the WiFi to be initialized - */ - SILABS_LOG("APP: Wait WiFi Init"); - while (!wfx_hw_ready()) - { - vTaskDelay(10); - } - SILABS_LOG("APP: Done WiFi Init"); - /* We will init server when we get IP */ - sWiFiNetworkCommissioningInstance.Init(); - /* added for commisioning with wifi */ -#endif - - sInstance.Run(); -} - -void WindowAppImpl::OnIconTimeout(WindowApp::Timer & timer) -{ -#ifdef DISPLAY_ENABLED - sInstance.mIcon = LcdIcon::None; - sInstance.UpdateLCD(); -#endif -} - -CHIP_ERROR WindowAppImpl::Init() -{ - WindowApp::Init(); - - // Initialize App Task - mHandle = xTaskCreateStatic(OnTaskCallback, APP_TASK_NAME, ArraySize(sAppStack), NULL, 1, sAppStack, &sAppTaskStruct); - if (NULL == mHandle) - { - SILABS_LOG("Failed to allocate app task"); - return CHIP_ERROR_NO_MEMORY; - } - - // Initialize App Queue - mQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(WindowApp::Event), sAppEventQueueBuffer, &sAppEventQueueStruct); - if (NULL == mQueue) - { - SILABS_LOG("Failed to allocate app event queue"); - return CHIP_ERROR_NO_MEMORY; - } - - // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS - LEDWidget::InitGpio(); - mStatusLED.Init(APP_STATE_LED); - mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS - -#ifdef DISPLAY_ENABLED - slLCD.Init(); -#endif - -#ifndef 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 (EFR32::EFR32DeviceDataProvider::GetDeviceDataProvider().GetSetupPayload(QRCode) == CHIP_NO_ERROR) - { - PrintQrCodeURL(QRCode); - } - else - { - SILABS_LOG("Getting QR code failed!"); - } -#endif // QR_CODE_ENABLED - - return CHIP_NO_ERROR; -} - -CHIP_ERROR WindowAppImpl::Start() -{ - SILABS_LOG("Starting FreeRTOS scheduler"); - sl_system_kernel_start(); - - return CHIP_NO_ERROR; -} - -void WindowAppImpl::Finish() -{ - WindowApp::Finish(); - chip::Platform::MemoryShutdown(); - // Should never get here. - SILABS_LOG("vTaskStartScheduler() failed"); - appError(CHIP_ERROR_INTERNAL); -} - -void WindowAppImpl::PostEvent(const WindowApp::Event & event) -{ - if (mQueue) - { - BaseType_t status; - if (xPortIsInsideInterrupt()) - { - BaseType_t higherPrioTaskWoken = pdFALSE; - status = xQueueSendFromISR(mQueue, &event, &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(mQueue, &event, 1); - } - - if (!status) - { - SILABS_LOG("Failed to post event to app task event queue"); - } - } -} - -void WindowAppImpl::PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) -{ - Instance().PostEvent(WindowApp::Event(WindowApp::EventId::AttributeChange, endpoint, attributeId)); -} - -void WindowAppImpl::ProcessEvents() -{ - WindowApp::Event event = EventId::None; - - BaseType_t received = xQueueReceive(mQueue, &event, pdMS_TO_TICKS(10)); - while (pdTRUE == received) - { - DispatchEvent(event); - received = xQueueReceive(mQueue, &event, 0); - } -} - -WindowApp::Timer * WindowAppImpl::CreateTimer(const char * name, uint32_t timeoutInMs, WindowApp::Timer::Callback callback, - void * context) -{ - return new Timer(name, timeoutInMs, callback, context); -} - -WindowApp::Button * WindowAppImpl::CreateButton(WindowApp::Button::Id id, const char * name) -{ - return new Button(id, name); -} - -void WindowAppImpl::DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute) -{ - switch (attribute) - { - /* RO OperationalStatus */ - case Attributes::OperationalStatus::Id: - UpdateLEDs(); - break; - /* RO Type: not supposed to dynamically change -> Cycling Window Covering Demo */ - case Attributes::Type::Id: - /* ============= Positions for Position Aware ============= */ - case Attributes::CurrentPositionLiftPercent100ths::Id: - case Attributes::CurrentPositionTiltPercent100ths::Id: - UpdateLCD(); - break; - /* ### ATTRIBUTEs CHANGEs IGNORED ### */ - /* RO EndProductType: not supposed to dynamically change */ - case Attributes::EndProductType::Id: - /* RO ConfigStatus: set by WC server */ - case Attributes::ConfigStatus::Id: - /* RO SafetyStatus: set by WC server */ - case Attributes::SafetyStatus::Id: - /* RW Mode: User can change */ - case Attributes::Mode::Id: - default: - break; - } -} - -void WindowAppImpl::DispatchEvent(const WindowApp::Event & event) -{ - WindowApp::DispatchEvent(event); - switch (event.mId) - { - case EventId::AttributeChange: - DispatchEventAttributeChange(event.mEndpoint, event.mAttributeId); - break; - case EventId::ResetWarning: - SILABS_LOG("Factory Reset Triggered. Release button within %ums to cancel.", LONG_PRESS_TIMEOUT); - // Turn off all LEDs before starting blink to make sure blink is - // co-ordinated. - UpdateLEDs(); - break; - case EventId::ResetCanceled: - SILABS_LOG("Factory Reset has been Canceled"); - UpdateLEDs(); - break; - case EventId::ProvisionedStateChanged: - UpdateLEDs(); - UpdateLCD(); - break; - - case EventId::WinkOn: - case EventId::WinkOff: - mState.isWinking = (EventId::WinkOn == event.mId); - UpdateLEDs(); - break; - case EventId::ConnectivityStateChanged: - case EventId::BLEConnectionsChanged: - UpdateLEDs(); - break; -#ifdef DISPLAY_ENABLED - case EventId::CoverTypeChange: - UpdateLCD(); - break; - case EventId::CoverChange: - mIconTimer.Start(); - mIcon = (GetCover().mEndpoint == 1) ? LcdIcon::One : LcdIcon::Two; - UpdateLCD(); - break; - case EventId::TiltModeChange: - mIconTimer.Start(); - mIcon = mTiltMode ? LcdIcon::Tilt : LcdIcon::Lift; - UpdateLCD(); - break; -#endif - default: - break; - } -} - -void WindowAppImpl::UpdateLEDs() -{ - Cover & cover = GetCover(); - if (mResetWarning) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Set(false); - mStatusLED.Blink(500); - - mActionLED.Set(false); - mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS - } - else - { - if (mState.isWinking) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS - } - else -#if CHIP_ENABLE_OPENTHREAD - if (mState.isThreadProvisioned && mState.isThreadEnabled) -#else - if (mState.isWiFiProvisioned && mState.isWiFiEnabled) -#endif - - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS - } - - // Action LED - NPercent100ths current; - LimitStatus liftLimit = LimitStatus::Intermediate; - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - Attributes::CurrentPositionLiftPercent100ths::Get(cover.mEndpoint, current); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - if (!current.IsNull()) - { - AbsoluteLimits limits = { .open = WC_PERCENT100THS_MIN_OPEN, .closed = WC_PERCENT100THS_MAX_CLOSED }; - liftLimit = CheckLimitState(current.Value(), limits); - } - - if (OperationalState::Stall != cover.mLiftOpState) - { -#ifdef ENABLE_WSTK_LEDS - mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS - } - else if (LimitStatus::IsUpOrOpen == liftLimit) - { -#ifdef ENABLE_WSTK_LEDS - mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS - } - else if (LimitStatus::IsDownOrClose == liftLimit) - { -#ifdef ENABLE_WSTK_LEDS - mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS - } - } -} - -void WindowAppImpl::UpdateLCD() -{ - // Update LCD -#ifdef DISPLAY_ENABLED -#if CHIP_ENABLE_OPENTHREAD - if (mState.isThreadProvisioned) -#else - if (mState.isWiFiProvisioned) -#endif // CHIP_ENABLE_OPENTHREAD - { - Cover & cover = GetCover(); - chip::app::DataModel::Nullable lift; - chip::app::DataModel::Nullable tilt; - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - Type type = TypeGet(cover.mEndpoint); - - Attributes::CurrentPositionLift::Get(cover.mEndpoint, lift); - Attributes::CurrentPositionTilt::Get(cover.mEndpoint, tilt); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - -#ifdef DISPLAY_ENABLED - if (!tilt.IsNull() && !lift.IsNull()) - { - LcdPainter::Paint(slLCD, type, lift.Value(), tilt.Value(), mIcon); - } -#endif - } -#ifdef QR_CODE_ENABLED - else - { - chip::MutableCharSpan qrCode(mQRCodeBuffer); - if (GetQRCode(qrCode, chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)) == CHIP_NO_ERROR) - { - slLCD.SetQRCode((uint8_t *) qrCode.data(), qrCode.size()); - slLCD.ShowQRCode(true, true); - } - } -#endif // QR_CODE_ENABLED -#endif // DISPLAY_ENABLED -} - -void WindowAppImpl::OnMainLoop() -{ -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Animate(); - mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS -} - -//------------------------------------------------------------------------------ -// Buttons -//------------------------------------------------------------------------------ -WindowAppImpl::Button::Button(WindowApp::Button::Id id, const char * name) : WindowApp::Button(id, name) {} - -void WindowAppImpl::OnButtonChange(const sl_button_t * handle) -{ - WindowApp::Button * btn = static_cast