From 824b0e2a1d4fbc3cffe3be240f27fa70b45d9f6c Mon Sep 17 00:00:00 2001 From: Douglas Rocha Ferraz Date: Wed, 6 Apr 2022 14:02:03 -0400 Subject: [PATCH] chef sample app (#16731) * new: chef app is a configurable application that processes zap files during the build process Change-Id: Ia6aeba2d5587e09074defcd34dc5028288d74a90 * fix: esp32 functional on master on 28/mar/2021 Change-Id: I33f572f313dc7be91e208b074fe6ba6c7ab9da31 * chg: removed old zap files that need to be updated Change-Id: Ibbe26ad39ba69d251fd4ef956632eb1aac9dfdf8 * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * Restyled by autopep8 * fix: init server on scheduled task Change-Id: If7c287ea7e9632fb8b4a49e8e4c82af4002cf4e4 * fix: excluded unsued context from task call Change-Id: I8a353828804b2a203d336e47edbe58ce7d62163a * chg: fixes to paths in README file Change-Id: I252594388ec759c84525ea9090c153bdd7f80d3f * fix: update to zap regen script to ignore chef sample app Change-Id: Ia17baae1a7cca206fd1854928f1b56ca05c0b9e7 * Update wordlist: add new work (flags gzbf) and sort|unique the word list Co-authored-by: Restyled.io Co-authored-by: Andrei Litvin --- .github/.wordlist.txt | 54 +- examples/chef/.gitignore | 4 + examples/chef/README.md | 38 + examples/chef/README_DEVICE.md | 1 + examples/chef/README_OTCLI.md | 1 + examples/chef/README_SHELL.md | 1 + examples/chef/chef.py | 402 + examples/chef/chef_config.py | 17 + examples/chef/devices/lighting-app.zap | 6988 +++++++++++++++++ examples/chef/esp32/.gitignore | 5 + examples/chef/esp32/CMakeLists.txt | 76 + examples/chef/esp32/main/CMakeLists.txt | 185 + examples/chef/esp32/main/Kconfig.projbuild | 142 + examples/chef/esp32/main/QRCodeScreen.cpp | 103 + .../chef/esp32/main/include/QRCodeScreen.h | 49 + examples/chef/esp32/main/main.cpp | 214 + examples/chef/esp32/partitions.csv | 6 + examples/chef/esp32/sdkconfig.defaults | 49 + examples/chef/esp32/sdkconfig_rpc.defaults | 54 + .../chef/esp32/third_party/connectedhomeip | 1 + examples/chef/linux/.gn | 25 + examples/chef/linux/BUILD.gn | 54 + examples/chef/linux/build_overrides | 1 + examples/chef/linux/main.cpp | 60 + .../chef/linux/third_party/connectedhomeip | 1 + examples/chef/nrfconnect/.gitignore | 1 + examples/chef/nrfconnect/CHIPProjectConfig.h | 37 + examples/chef/nrfconnect/CMakeLists.txt | 95 + examples/chef/nrfconnect/README.md | 11 + .../boards/nrf52840dk_nrf52840.overlay | 27 + .../boards/nrf5340dk_nrf5340_cpuapp.conf | 17 + examples/chef/nrfconnect/main.cpp | 104 + examples/chef/nrfconnect/prj.conf | 42 + .../nrfconnect/third_party/connectedhomeip | 1 + examples/chef/shell_common | 1 + scripts/tools/zap_regen_all.py | 3 + src/lib/shell/streamer_esp32.cpp | 1 + src/platform/ESP32/CHIPDevicePlatformConfig.h | 4 + 38 files changed, 8844 insertions(+), 31 deletions(-) create mode 100644 examples/chef/.gitignore create mode 100644 examples/chef/README.md create mode 120000 examples/chef/README_DEVICE.md create mode 120000 examples/chef/README_OTCLI.md create mode 120000 examples/chef/README_SHELL.md create mode 100755 examples/chef/chef.py create mode 100644 examples/chef/chef_config.py create mode 100644 examples/chef/devices/lighting-app.zap create mode 100644 examples/chef/esp32/.gitignore create mode 100644 examples/chef/esp32/CMakeLists.txt create mode 100644 examples/chef/esp32/main/CMakeLists.txt create mode 100644 examples/chef/esp32/main/Kconfig.projbuild create mode 100644 examples/chef/esp32/main/QRCodeScreen.cpp create mode 100644 examples/chef/esp32/main/include/QRCodeScreen.h create mode 100644 examples/chef/esp32/main/main.cpp create mode 100644 examples/chef/esp32/partitions.csv create mode 100644 examples/chef/esp32/sdkconfig.defaults create mode 100644 examples/chef/esp32/sdkconfig_rpc.defaults create mode 120000 examples/chef/esp32/third_party/connectedhomeip create mode 100644 examples/chef/linux/.gn create mode 100644 examples/chef/linux/BUILD.gn create mode 120000 examples/chef/linux/build_overrides create mode 100644 examples/chef/linux/main.cpp create mode 120000 examples/chef/linux/third_party/connectedhomeip create mode 100644 examples/chef/nrfconnect/.gitignore create mode 100644 examples/chef/nrfconnect/CHIPProjectConfig.h create mode 100644 examples/chef/nrfconnect/CMakeLists.txt create mode 100644 examples/chef/nrfconnect/README.md create mode 100644 examples/chef/nrfconnect/boards/nrf52840dk_nrf52840.overlay create mode 100644 examples/chef/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.conf create mode 100644 examples/chef/nrfconnect/main.cpp create mode 100644 examples/chef/nrfconnect/prj.conf create mode 120000 examples/chef/nrfconnect/third_party/connectedhomeip create mode 120000 examples/chef/shell_common diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index f8d0a2dc434631..f40faaea3095a0 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -55,6 +55,7 @@ APIs apk AppConfig AppImpl +appliable ApplianceControl applianceeventsandalert ApplianceIdentification @@ -69,6 +70,7 @@ ApplyUpdateRequest ApplyUpdateResponse approver appspot +appwrite aps arg argc @@ -142,6 +144,7 @@ BooleanState bootable Bootloader BorderRouterAP +bouffalolab BRD breakpoint bredr @@ -231,6 +234,7 @@ clusterAttrs clusterId clusterList clusterListName +ClusterObjectTests ClusterRevision ClusterTestGeneration cmake @@ -250,11 +254,13 @@ Comcast Commandline Commissionable commissionables +commissionee CommissioningFlow commondatastorage CONF CONFIG ConfigDescription +configs configTOTAL ConfigurationManager ConfigurationManagerImpl @@ -291,6 +297,7 @@ CQM crypto cryptographic CSA +csg csrrequest csu csv @@ -310,6 +317,7 @@ dadbdcdddedf DAP DAPLINK DataFrame +datamodel DataModelRevision dataset datasets @@ -402,6 +410,7 @@ Dockerfile Dockerfiles Don'ts DoorLock +doru DOTBR DOVERLAY downcasting @@ -562,6 +571,7 @@ gtk GUA Gv gz +gzbf HaloaceticAcidsConcentrationMeasurement hardcoded hardknott @@ -645,6 +655,7 @@ isLowerCase isUpperCase itemName iterable +itsfoss JDK jinja JLink @@ -828,7 +839,6 @@ mydir MyPASSWORD MySSID NAMESERVER -nameserver namespacing nano natively @@ -903,6 +913,7 @@ otaImageList OTAImageProcessorDriver OTAImageProcessorImpl OTAImageProcessorInterface +otaissues OTAProvider OTAProviderIpAddress OTAProviderNodeId @@ -913,6 +924,7 @@ OTARequestorDriver OTARequestorSerialPort OtaSoftwareUpdateProvider otasoftwareupdaterequestor +otatesting otaURL OTBR otcli @@ -940,6 +952,7 @@ PCA pcaps PDFs PDK +PDM peerAddrStr peerNodeId peerSessionId @@ -989,6 +1002,7 @@ ProxyValid ProxyView PRs PSCAN +PSECT PSK PSoC PTR @@ -1019,6 +1033,7 @@ QSPI QueryImage QueryImageResponse queryImageStatus +Quickstart qvCHIP RADVD raspberryPi @@ -1068,6 +1083,7 @@ rootfs RPC RPCs RPi +RPis rsn RSSI rsync @@ -1151,6 +1167,7 @@ spinel src SRP SRV +SSBL SSID startoffset StartScan @@ -1220,6 +1237,7 @@ TESTSSID TestString TestStruct TestThreadStackMgr +TestTimedRequestTimeout TestUint TestUpdateValue testws @@ -1256,10 +1274,11 @@ totalTests TotalTrihalomethanesConcentrationMeasurement trackAlloc trackFree -transitionTime TransferSession +transitionTime TransportMgrBase TrustedRootCertificates +tsan TSG tsv TTL @@ -1338,6 +1357,7 @@ WaitNewInputEvent WakeOnLan WantedBy webpage +wg wget whde whitespace @@ -1363,8 +1383,8 @@ xAAAA xab xaver xb -xbef xBEEF +xbef xc xcd Xcode @@ -1423,31 +1443,3 @@ zephyrproject Zigbee zigbeealliance zigbeethread -libshell -TestGroupDemoConfig -ACLs -AddNOC -CHIPConfig -CHIPProjectAppConfig -CaseAdminNode -DataVersion -ProxyView -ReadAttribute -WriteAttribute -kAdminister -kManage -kOperate -kView -xFFFFFFFD -ClusterObjectTests -TestTimedRequestTimeout -datamodel -appliable -commissionee -configs -NAMESERVER -UTF -localedef -nameserver -nmcli -tsan diff --git a/examples/chef/.gitignore b/examples/chef/.gitignore new file mode 100644 index 00000000000000..79d65e24f32dbb --- /dev/null +++ b/examples/chef/.gitignore @@ -0,0 +1,4 @@ +zap-generated +project_include.cmake +linux/args.gni +linux/sample.gni diff --git a/examples/chef/README.md b/examples/chef/README.md new file mode 100644 index 00000000000000..b5a7372a40502f --- /dev/null +++ b/examples/chef/README.md @@ -0,0 +1,38 @@ +# MATTER CHEF APP + +The purpose of the chef app is to to increase the coverage of device types in +Matter. + +It uses the shell app a starting point, adding the processing of ZAP files and +the support of a few targets under a unified build script: `chef.py`. + +As it incorporates the processing of ZAP files as part of the build process, it +does not use `zzz_generated`, but rather places the auto-generated zap artifacts +under its `zap-generated` temporary folder. + +All device types available (DM/IM .zap files) are found inside the `devices` +folder. + +## Building a Sample Application + +Run `chef.py -h` to see the available commands + +## Building your first sample + +1. Make sure you have the toolchain installed for your desired target +2. Update your SoC SDK paths on `chef_config.py` and flip the `configured` + variable to True +3. Run `$ chef.py -u` to update zap and the toolchain (on selected platforms) +4. Run `$ chef.py -gzbf -t -d lighting`. This command will run the + ZAP GUI opening the `devices/lighting.zap` file and will allow editing. It + will then generate the zap artifacts, place them on the `zap-generated` + folder, run a build and flash the binary in your target + +## Creating a new device type in your device library + +1. Run `$ chef.py -g -d ` to open in the ZAP GUI a device to be used as + a starting point. +2. Edit your cluster configurations +3. Click on `Save As` and save the file with the name of your new device type + into the `devices` folder. This device is now available for the script. See + `chef.py -h` for a list of devices available. diff --git a/examples/chef/README_DEVICE.md b/examples/chef/README_DEVICE.md new file mode 120000 index 00000000000000..e8ea164338a0e3 --- /dev/null +++ b/examples/chef/README_DEVICE.md @@ -0,0 +1 @@ +../shell/README_DEVICE.md \ No newline at end of file diff --git a/examples/chef/README_OTCLI.md b/examples/chef/README_OTCLI.md new file mode 120000 index 00000000000000..f0517db8a72d06 --- /dev/null +++ b/examples/chef/README_OTCLI.md @@ -0,0 +1 @@ +../shell/README_OTCLI.md \ No newline at end of file diff --git a/examples/chef/README_SHELL.md b/examples/chef/README_SHELL.md new file mode 120000 index 00000000000000..436ec8580a5e29 --- /dev/null +++ b/examples/chef/README_SHELL.md @@ -0,0 +1 @@ +../shell/README.md \ No newline at end of file diff --git a/examples/chef/chef.py b/examples/chef/chef.py new file mode 100755 index 00000000000000..12c2ad77e213e9 --- /dev/null +++ b/examples/chef/chef.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python3 + +# 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 sys +import optparse +import os +import subprocess +from pathlib import Path +import chef_config as config +from sys import platform + +global commandQueue +commandQueue = "" + + +class TermColors: + STRBOLD = '\033[1m' + STRRESET = '\033[0m' + STRCYAN = '\033[1;36m' + STRYELLOW = '\033[1;33m' + + +def splash(): + splashText = TermColors.STRBOLD + TermColors.STRYELLOW + '''\ + ______ __ __ _______ _______ + / || | | | | ____|| ____| +| ,----'| |__| | | |__ | |__ +| | | __ | | __| | __| +| `----.| | | | | |____ | | + \\______||__| |__| |_______||__|\ +''' + TermColors.STRRESET + return splash + + +def printc(strInput): + color = TermColors.STRCYAN + print(color + strInput + TermColors.STRRESET) + + +def definePaths(): + paths = dict() + paths["scriptFolder"] = os.path.abspath(os.path.dirname(__file__)) + paths["matterFolder"] = paths["scriptFolder"] + "/../../" + paths["rootSampleFolder"] = paths["scriptFolder"] + paths["genFolder"] = paths["rootSampleFolder"] + "/zap-generated" + paths["devices"] = [] + for filepath in Path(f"{paths['rootSampleFolder']}/devices").rglob('*.zap'): + paths["devices"].append( + str(os.path.splitext(os.path.basename(filepath))[0])) + return paths + + +def checkPythonVersion(): + if sys.version_info[0] < 3: + print('Must use Python 3. Current version is ' + + str(sys.version_info[0])) + exit(1) + + +def queuePrint(str): + global commandQueue + if (len(commandQueue) > 0): + commandQueue = commandQueue + "; " + commandQueue = commandQueue + "echo -e " + str + + +def queueCommand(command): + global commandQueue + if (len(commandQueue) > 0): + commandQueue = commandQueue + "; " + commandQueue = commandQueue + command + + +def execQueue(): + global commandQueue + subprocess.run(commandQueue, shell=True, executable=shellApp) + commandQueue = "" + + +def hexInputToInt(valIn): + '''Parses inputs as hexadecimal numbers, takes into account optional 0x + prefix + ''' + if (type(valIn) is str): + if (valIn[0:2].lower() == "0x"): + valOut = valIn[2:] + else: + valOut = valIn + valOut = int(valOut, 16) + else: + valOut = valIn + return valOut + + +def main(argv): + checkPythonVersion() + paths = definePaths() + global myEnv + myEnv = os.environ.copy() + + # + # Build environment switches + # + + global shellApp + if platform == "linux" or platform == "linux2": + shellApp = '/bin/bash' + elif platform == "darwin": + shellApp = '/bin/zsh' + elif platform == "win32": + print('Windows is currently not supported. Use Linux or MacOS platforms') + exit(1) + + # + # Checks if user has configured its custom settings + # + if not config.configured: + print('Please edit chef_config.py file and change the flag to True') + exit(1) + + # + # Arguments parser + # + + deviceTypes = "\n ".join(paths["devices"]) + + usage = f'''usage: chef.py [options] + +Platforms: + nrf52840dk_nrf52840 + esp32 + linux + +Device Types: + {deviceTypes} + +Notes: +- Whenever you change a device type, make sure to also use options -zbe +- Be careful if you have more than one device connected. The script assumes you have only one device connected and might flash the wrong one\ +''' + parser = optparse.OptionParser(usage=usage) + + parser.add_option("-u", "--update_toolchain", help="updates toolchain & installs zap", + action="store_true", dest="doUpdateToolchain") + parser.add_option("-b", "--build", help="builds", + action="store_true", dest="doBuild") + parser.add_option("-c", "--clean", help="clean build. Only valid if also building", + action="store_true", dest="doClean") + parser.add_option("-f", "--flash", help="flashes device", + action="store_true", dest="doFlash") + parser.add_option("-e", "--erase", help="erases flash before flashing. Only valid if also flashing", + action="store_true", dest="doErase") + parser.add_option("-i", "--terminal", help="opens terminal to interact with with device", + action="store_true", dest="doInteract") + parser.add_option("-m", "--menuconfig", help="runs menuconfig on platforms that support it", + action="store_true", dest="doMenuconfig") + parser.add_option("", "--bootstrap_zap", help="installs zap dependencies", + action="store_true", dest="doBootstrapZap") + parser.add_option("-z", "--zap", help="runs zap to generate data model & interaction model artifacts", + action="store_true", dest="doRunZap") + parser.add_option("-g", "--zapgui", help="runs zap GUI display to allow editing of data model", + action="store_true", dest="doRunGui") + parser.add_option("-d", "--device", dest="sampleDeviceTypeName", + help="specifies device type. Default is lighting. See info above for supported device types", metavar="TARGET", default="lighting") + parser.add_option("-t", "--target", type='choice', + action='store', + dest="buildTarget", + help="specifies target platform. Default is esp32. See info below for currently supported target platforms", + choices=['nrf52840dk_nrf52840', 'esp32', 'linux', ], + metavar="TARGET", + default="esp32") + parser.add_option("-r", "--rpc", help="enables Pigweed RPC interface. Enabling RPC disables the shell interface. Your sdkconfig configurations will be reverted to default. Default is PW RPC off. When enabling or disabling this flag, on the first build force a clean build with -c", action="store_true", dest="doRPC") + parser.add_option("-v", "--vid", dest="vid", + help="specifies the Vendor ID. Default is 0xFFF1", metavar="VID", default=0xFFF1) + parser.add_option("-p", "--pid", dest="pid", + help="specifies the Product ID. Default is 0x8000", metavar="PID", default=0x8000) + parser.add_option("", "--rpc_console", help="Opens PW RPC Console", + action="store_true", dest="doRPC_CONSOLE") + + options, _ = parser.parse_args(argv) + + splash() + + # + # Platform Folder + # + + queuePrint(f"Target is set to {options.sampleDeviceTypeName}") + queuePrint("Setting up environment...") + if options.buildTarget == "esp32": + paths["platFolder"] = os.path.normpath( + paths["rootSampleFolder"] + "/esp32") + queueCommand(f"source {config.esp32Folder}/export.sh") + elif options.buildTarget == "nrf52840dk_nrf52840": + paths["platFolder"] = os.path.normpath( + paths["rootSampleFolder"] + "/nrfconnect") + queueCommand(f"source {config.nrfconnectFolder}/zephyr/zephyr-env.sh") + queueCommand("export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb") + elif options.buildTarget == "linux": + pass + else: + print(f"Target {options.buildTarget} not supported") + + queueCommand(f"source {paths['matterFolder']}/scripts/activate.sh") + + # + # Toolchain update + # + + if options.doUpdateToolchain: + if options.buildTarget == "esp32": + queuePrint("ESP32 toolchain update not supported. Skipping") + elif options.buildTarget == "nrf52840dk_nrf52840": + queuePrint("Updating toolchain") + queueCommand( + f"cd {paths['matterFolder']} && python3 scripts/setup/nrfconnect/update_ncs.py --update") + elif options.buildTarget == "linux": + queuePrint("Linux toolchain update not supported. Skipping") + + # + # ZAP bootstrapping + # + + if options.doBootstrapZap: + if platform == "linux" or platform == "linux2": + queuePrint("Installing ZAP OS package dependencies") + queueCommand(f"sudo apt-get install sudo apt-get install node node-yargs npm libpixman-1-dev libcairo2-dev libpango1.0-dev node-pre-gyp libjpeg9-dev libgif-dev node-typescript") + if platform == "darwin": + queuePrint("Installation of ZAP OS packages not supported on MacOS") + if platform == "win32": + queuePrint( + "Installation of ZAP OS packages not supported on Windows") + + queuePrint("Running NPM to install ZAP Node.JS dependencies") + queueCommand( + f"cd {paths['matterFolder']}/third_party/zap/repo/ && npm install") + + # + # Cluster customization + # + + if options.doRunGui: + queuePrint("Starting ZAP GUI editor") + queueCommand(f"cd {paths['rootSampleFolder']}/devices") + queueCommand( + f"{paths['matterFolder']}/scripts/tools/zap/run_zaptool.sh {options.sampleDeviceTypeName}.zap") + + if options.doRunZap: + queuePrint("Running ZAP script to generate artifacts") + queueCommand(f"mkdir -p {paths['genFolder']}/") + queueCommand(f"rm {paths['genFolder']}/*") + queueCommand( + f"{paths['matterFolder']}/scripts/tools/zap/generate.py {paths['rootSampleFolder']}/devices/{options.sampleDeviceTypeName}.zap -o {paths['genFolder']}") + # sometimes af-gen-event.h is not generated + queueCommand(f"touch {paths['genFolder']}/af-gen-event.h") + + # + # Menuconfig + # + + if options.doMenuconfig: + if options.buildTarget == "esp32": + queueCommand(f"cd {paths['rootSampleFolder']}/esp32") + queueCommand("idf.py menuconfig") + elif options.buildTarget == "nrf52840dk_nrf52840": + queueCommand(f"cd {paths['rootSampleFolder']}/nrfconnect") + queueCommand("west build -t menuconfig") + elif options.buildTarget == "linux": + queuePrint("Menuconfig not available on Linux target. Skipping") + + # + # Build + # + + if options.doBuild: + queuePrint("Building...") + if options.doRPC: + queuePrint("RPC PW enabled") + queueCommand( + f"export SDKCONFIG_DEFAULTS={paths['rootSampleFolder']}/esp32/sdkconfig_rpc.defaults") + else: + queuePrint("RPC PW disabled") + queueCommand( + f"export SDKCONFIG_DEFAULTS={paths['rootSampleFolder']}/esp32/sdkconfig.defaults") + options.vid = hexInputToInt(options.vid) + options.pid = hexInputToInt(options.pid) + queuePrint( + f"Product ID 0x{options.pid:02X} / Vendor ID 0x{options.vid:02X}") + queueCommand(f"cd {paths['rootSampleFolder']}") + + if (options.buildTarget == "esp32") or (options.buildTarget == "nrf52840dk_nrf52840"): + queueCommand(f''' +cat > project_include.cmake < args.gni < sample.gni <:-std=c++17>) +list(APPEND _target_cxx_flags $<$:-std=gnu++17>) +set_target_properties(pw_build.cpp17 PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}") +endif(CONFIG_ENABLE_PW_RPC) diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt new file mode 100644 index 00000000000000..b8c28da4eefb94 --- /dev/null +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -0,0 +1,185 @@ +# +# Copyright (c) 2021 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. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../.. REALPATH) +get_filename_component(CHEF ${CMAKE_CURRENT_SOURCE_DIR}/../../ REALPATH) +get_filename_component(GEN_DIR ${CHEF}/zap-generated/ REALPATH) + +# include(${CMAKE_CURRENT_LIST_DIR}/../../project_include.cmake) + +# message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) +# message(STATUS "Vendor ID " ${CONFIG_DEVICE_VENDOR_ID}) + +set(CHIP_SHELL_DIR "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/shell") + +set(PRIV_INCLUDE_DIRS_LIST + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/third_party/nlio/repo/include" + "${CMAKE_SOURCE_DIR}/../" + "${CMAKE_SOURCE_DIR}/main/include/" +) + + +# find_package(Python3 REQUIRED) +set(ZAP_FILE ${CMAKE_CURRENT_LIST_DIR}/../../devices/${SAMPLE_NAME}.zap) +execute_process( + COMMAND ${Python3_EXECUTABLE} ${CHIP_ROOT}/src/app/zap_cluster_list.py --zap_file ${ZAP_FILE} + OUTPUT_VARIABLE CLUSTER_LIST + ERROR_VARIABLE ERROR_MESSAGE + RESULT_VARIABLE RC +) +# if (NOT RC EQUAL 0) +# message(FATAL_ERROR "Failed to execute zap_cluster_list.py: ${ERROR_MESSAGE}") +# endif() + +message(STATUS "** Start of Cluster List **") +string(REPLACE "\n" ";" CLUSTER_LIST "${CLUSTER_LIST}") +foreach(CLUSTER ${CLUSTER_LIST}) + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" + "${CHIP_ROOT}/src/app/clusters/${CLUSTER}") + message(STATUS "src/app/clusters/${CLUSTER}") +endforeach() +message(STATUS "** End of Cluster List **") + +set(SRC_DIRS_LIST + ${SRC_DIRS_LIST} + "${CMAKE_CURRENT_LIST_DIR}" + "${GEN_DIR}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" +) + +if (CONFIG_ENABLE_CHIP_SHELL) +set(SRC_DIRS_LIST + ${SRC_DIRS_LIST} + "${CHIP_SHELL_DIR}/shell_common/" +) +endif() + + +if (CONFIG_ENABLE_PW_RPC) +# Append additional directories for RPC build +set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/../../platform/esp32/pw_sys_io/public" + "${CMAKE_SOURCE_DIR}/../../common" + "${CMAKE_SOURCE_DIR}/../../common/pigweed" + "${CMAKE_SOURCE_DIR}/../../common/pigweed/esp32" + "${CMAKE_SOURCE_DIR}/../../common/screen-framework/include/" + "${CMAKE_SOURCE_DIR}/../../../src/lib/support" + "${IDF_PATH}/components/freertos/include/freertos" +) +set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/../../platform/esp32" + "${CMAKE_SOURCE_DIR}/../../common/pigweed" + "${CMAKE_SOURCE_DIR}/../../common/pigweed/esp32" +) +else() +set(SRC_DIRS_LIST + ${SRC_DIRS_LIST} + "${CHIP_SHELL_DIR}/shell_common/" +) +endif (CONFIG_ENABLE_PW_RPC) + +idf_component_register(PRIV_INCLUDE_DIRS + "${CHIP_SHELL_DIR}/shell_common/include" + "${PRIV_INCLUDE_DIRS_LIST}" + PRIV_REQUIRES chip nvs_flash bt console esp32_mbedtls QRCode tft screen-framework spidriver + SRC_DIRS ${SRC_DIRS_LIST}) + +set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) +target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H") +target_compile_options(${COMPONENT_LIB} PUBLIC + "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" +) + +if (CONFIG_ENABLE_PW_RPC) + +get_filename_component(CHIP_ROOT ../third_party/connectedhomeip REALPATH) + +set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") +include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) +include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) +set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE) + +pw_proto_library(attributes_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.options + PREFIX + attributes_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_protos +) + +pw_proto_library(button_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto + PREFIX + button_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_protos +) + +pw_proto_library(device_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.options + PREFIX + device_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_protos +) + +target_link_libraries(${COMPONENT_LIB} PUBLIC + attributes_service.nanopb_rpc + button_service.nanopb_rpc + device_service.nanopb_rpc + pw_checksum + pw_hdlc + pw_log + pw_rpc.server + pw_trace_tokenized + pw_trace_tokenized.trace_buffer + pw_trace_tokenized.rpc_service + pw_trace_tokenized.protos.nanopb_rpc +) + +target_link_options(${COMPONENT_LIB} + PUBLIC + "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" +) + +target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1") + +endif (CONFIG_ENABLE_PW_RPC) diff --git a/examples/chef/esp32/main/Kconfig.projbuild b/examples/chef/esp32/main/Kconfig.projbuild new file mode 100644 index 00000000000000..307b7f6ccb83bc --- /dev/null +++ b/examples/chef/esp32/main/Kconfig.projbuild @@ -0,0 +1,142 @@ +# +# 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. +# +# Description: +# Configuration options CHIP ESP32 demo application. +# + +menu "Demo" + + choice + prompt "Device Type" + default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 + default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 + help + Specifies the type of ESP32 device. + + Note that the "ESP32-DevKitC" choice is compatible with a number of clone devices + available from third-party manufacturers. + + config DEVICE_TYPE_ESP32_DEVKITC + bool "ESP32-DevKitC" + depends on IDF_TARGET_ESP32 + config DEVICE_TYPE_ESP32_WROVER_KIT + bool "ESP32-WROVER-KIT_V4.1" + depends on IDF_TARGET_ESP32 + config DEVICE_TYPE_M5STACK + bool "M5Stack" + depends on IDF_TARGET_ESP32 + config DEVICE_TYPE_ESP32_C3_DEVKITM + bool "ESP32C3-DevKitM" + depends on IDF_TARGET_ESP32C3 + endchoice + + choice + prompt "Rendezvous Mode" + default RENDEZVOUS_MODE_BLE if BT_ENABLED + default RENDEZVOUS_MODE_SOFTAP + help + Specifies the Rendezvous mode of the peripheral. + + config RENDEZVOUS_MODE_BYPASS + bool "Bypass" + config RENDEZVOUS_MODE_SOFTAP + bool "Soft-AP" + config RENDEZVOUS_MODE_BLE + bool "BLE" + depends on BT_ENABLED + config RENDEZVOUS_MODE_ON_NETWORK + bool "On-Network" + config RENDEZVOUS_MODE_SOFTAP_ON_NETWORK + bool "Soft-AP / On-Network" + config RENDEZVOUS_MODE_BLE_ON_NETWORK + bool "BLE / On-Network" + endchoice + + config ECHO_HOST_IP + string "IPV4 address" + default "127.0.0.1" + depends on USE_ECHO_CLIENT + help + The IPV4 Address of the ECHO Server. + + # NOTE: This config is not displayed as a input in the Kconfig menu, as its value is + # entirely derived from the Device Type choice. However the CONFIG_EXAMPLE_DISPLAY_TYPE + # define that is produced is needed to configure the TFT library correctly. + config TFT_PREDEFINED_DISPLAY_TYPE + int + range 0 5 + default 0 if DEVICE_TYPE_ESP32_DEVKITC + default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 3 if DEVICE_TYPE_M5STACK + default 4 if DEVICE_TYPE_ESP32_WROVER_KIT + + config RENDEZVOUS_MODE + int + range 0 8 + default 0 if RENDEZVOUS_MODE_BYPASS + default 1 if RENDEZVOUS_MODE_SOFTAP + default 2 if RENDEZVOUS_MODE_BLE + default 4 if RENDEZVOUS_MODE_ON_NETWORK + default 5 if RENDEZVOUS_MODE_SOFTAP_ON_NETWORK + default 6 if RENDEZVOUS_MODE_BLE_ON_NETWORK + + config DISPLAY_AUTO_OFF + bool "Automatically turn off the M5Stack's Display after a few seconds" + default "y" + depends on DEVICE_TYPE_M5STACK + help + To reduce wear and heat the M5Stack's Display is automatically switched off after a few seconds + +endmenu + +menu "PW RPC Debug channel" +depends on ENABLE_PW_RPC + config EXAMPLE_UART_PORT_NUM + int "UART port number" + range 0 2 if IDF_TARGET_ESP32 + range 0 1 if IDF_TARGET_ESP32C3 + default 0 + help + UART communication port number for the example. + See UART documentation for available port numbers. + + config EXAMPLE_UART_BAUD_RATE + int "UART communication speed" + range 1200 115200 + default 115200 + help + UART communication speed for Modbus example. + + config EXAMPLE_UART_RXD + int "UART RXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 5 + help + GPIO number for UART RX pin. See UART documentation for more information + about available pin numbers for UART. + + config EXAMPLE_UART_TXD + int "UART TXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 4 + help + GPIO number for UART TX pin. See UART documentation for more information + about available pin numbers for UART. + +endmenu diff --git a/examples/chef/esp32/main/QRCodeScreen.cpp b/examples/chef/esp32/main/QRCodeScreen.cpp new file mode 100644 index 00000000000000..2130da0107f31d --- /dev/null +++ b/examples/chef/esp32/main/QRCodeScreen.cpp @@ -0,0 +1,103 @@ +/* + * + * 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. + */ + +/** + * @file QRCodeScreen.cpp + * + * Screen which displays a QR code. + * + */ + +#include "QRCodeScreen.h" + +#if CONFIG_HAVE_DISPLAY + +// TODO organize includes below + +#include "esp_log.h" +#include "esp_system.h" +#include "esp_wifi.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "qrcodegen.h" + +#include +#include +#include + +// TODO need sensible library tag when put in library +extern const char * TAG; + +namespace { + +constexpr int kVersion = 4; +constexpr int kModuleSize = 4; +constexpr int kBorderSize = 1; + +color_t qrCodeColor = TFT_LIGHTGREY; + +}; // namespace + +QRCodeScreen::QRCodeScreen(std::string text, std::string title) : title(title) +{ + constexpr int qrCodeSize = qrcodegen_BUFFER_LEN_FOR_VERSION(kVersion); + + // TODO check text length against max size permitted, or maybe adjust version used accordingly + + std::vector temp(qrCodeSize); + qrCode.resize(qrCodeSize); + + if (!qrcodegen_encodeText(text.c_str(), temp.data(), qrCode.data(), qrcodegen_Ecc_LOW, kVersion, kVersion, qrcodegen_Mask_AUTO, + true)) + { + ESP_LOGE(TAG, "qrcodegen_encodeText() failed"); + qrCode.clear(); + } +} + +void QRCodeScreen::Display() +{ + if (qrCode.empty()) + { + return; + } + + const uint8_t * data = qrCode.data(); + const int size = qrcodegen_getSize(data); + const int displaySize = (2 * kBorderSize + size) * kModuleSize; + const int displayX = (DisplayWidth - displaySize) / 2; + const int displayY = ScreenTitleSafeTop + ((DisplayHeight - ScreenTitleSafeTop - ScreenTitleSafeBottom) - displaySize) / 2; + + TFT_fillRect(displayX, displayY, displaySize, displaySize, qrCodeColor); + + for (int y = 0; y < size; ++y) + { + for (int x = 0; x < size; ++x) + { + if (qrcodegen_getModule(data, x, y)) + { + TFT_fillRect(displayX + (kBorderSize + x) * kModuleSize, displayY + (kBorderSize + y) * kModuleSize, kModuleSize, + kModuleSize, TFT_BLACK); + } + } + } +} + +#endif // CONFIG_HAVE_DISPLAY diff --git a/examples/chef/esp32/main/include/QRCodeScreen.h b/examples/chef/esp32/main/include/QRCodeScreen.h new file mode 100644 index 00000000000000..e24fcd86d81e1a --- /dev/null +++ b/examples/chef/esp32/main/include/QRCodeScreen.h @@ -0,0 +1,49 @@ +/* + * + * 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. + */ + +/** + * @file QRCodeScreen.h + * + * Screen which displays a QR code. + * + */ + +#pragma once + +#include "Screen.h" +#include "ScreenManager.h" + +#if CONFIG_HAVE_DISPLAY + +#include +#include + +class QRCodeScreen : public Screen +{ + std::vector qrCode; + std::string title; + +public: + QRCodeScreen(std::string text, std::string title = "QR Code"); + + virtual std::string GetTitle() { return title; } + + virtual void Display(); +}; + +#endif // CONFIG_HAVE_DISPLAY diff --git a/examples/chef/esp32/main/main.cpp b/examples/chef/esp32/main/main.cpp new file mode 100644 index 00000000000000..9ef7a7bf24529b --- /dev/null +++ b/examples/chef/esp32/main/main.cpp @@ -0,0 +1,214 @@ +/* + * + * 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 "nvs_flash.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Display.h" +#include "QRCodeScreen.h" +#include "ScreenManager.h" + +#if CONFIG_ENABLE_PW_RPC +#include "Rpc.h" +#endif /* CONFIG_ENABLE_PW_RPC */ + +using namespace chip; +using namespace chip::Shell; +using chip::Shell::Engine; +using namespace chip::DeviceLayer; + +#if CONFIG_ENABLE_CHIP_SHELL +static void chip_shell_task(void * args) +{ + + cmd_misc_init(); + cmd_ping_init(); + cmd_send_init(); + + Engine::Root().RunMainLoop(); +} +#endif /* CONFIG_ENABLE_CHIP_SHELL */ + +void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) +{ + switch (event->Type) + { + case DeviceEventType::kInternetConnectivityChange: + if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) + { + ChipLogProgress(Shell, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); + chip::app::DnssdServer::Instance().StartServer(); + } + else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) + { + ChipLogProgress(Shell, "Lost IPv4 connectivity..."); + } + if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established) + { + ChipLogProgress(Shell, "IPv6 Server ready..."); + chip::app::DnssdServer::Instance().StartServer(); + } + else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost) + { + ChipLogProgress(Shell, "Lost IPv6 connectivity..."); + } + + break; + + case DeviceEventType::kSessionEstablished: + if (event->SessionEstablished.IsCommissioner) + { + ChipLogProgress(Shell, "Commissioner detected!"); + } + break; + + case DeviceEventType::kCHIPoBLEConnectionEstablished: + ChipLogProgress(Shell, "CHIPoBLE connection established"); + break; + + case DeviceEventType::kCHIPoBLEConnectionClosed: + ChipLogProgress(Shell, "CHIPoBLE disconnected"); + break; + + case DeviceEventType::kCommissioningComplete: + ChipLogProgress(Shell, "Commissioning complete"); + break; + + case DeviceEventType::kInterfaceIpAddressChanged: + if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || + (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) + { + // DNSSD server restart on any ip assignment: if link local ipv6 is configured, that + // will not trigger a 'internet connectivity change' as there is no internet + // connectivity. DNSSD still wants to refresh its listening interfaces to include the + // newly selected address. + chip::app::DnssdServer::Instance().StartServer(); + } + break; + } + + ChipLogProgress(Shell, "Current free heap: %zu\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); +} + +const char * TAG = "chef-app"; + +#if CONFIG_HAVE_DISPLAY +void printQRCode() +{ + std::string qrCodeText; + + GetQRCode(qrCodeText, chip::RendezvousInformationFlags(CONFIG_RENDEZVOUS_MODE)); + + // Initialize the display device. + esp_err_t err = InitDisplay(); + if (err != ESP_OK) + { + ChipLogError(Shell, "InitDisplay() failed: %s", esp_err_to_name(err)); + return; + } + + // Initialize the screen manager + ScreenManager::Init(); + + ESP_LOGI(TAG, "Opening QR code screen"); + ESP_LOGI(TAG, "QR CODE Text: '%s'", qrCodeText.c_str()); + ScreenManager::PushScreen(chip::Platform::New(qrCodeText)); +} +#endif // CONFIG_HAVE_DISPLAY + +void InitServer(intptr_t) +{ + // Start IM server + chip::Server::GetInstance().Init(); + + // Device Attestation & Onboarding codes + chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); + chip::DeviceLayer::ConfigurationMgr().LogDeviceConfig(); + + if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR) + { + ChipLogError(Shell, "OpenBasicCommissioningWindow() failed"); + } + + // Register a function to receive events from the CHIP device layer. Note that calls to + // this function will happen on the CHIP event loop thread, not the app_main thread. + PlatformMgr().AddEventHandler(DeviceEventCallback, reinterpret_cast(nullptr)); +} + +extern "C" void app_main(void) +{ + ESP_ERROR_CHECK(nvs_flash_init()); + chip::Platform::MemoryInit(); + chip::DeviceLayer::PlatformMgr().InitChipStack(); + chip::DeviceLayer::PlatformMgr().StartEventLoopTask(); + +#if CONFIG_ENABLE_CHIP_SHELL + int ret = Engine::Root().Init(); + VerifyOrDie(ret == 0); +#endif /* CONFIG_ENABLE_CHIP_SHELL */ + + // Network connectivity + // Note to integration: StartWiFiManagement does not exist on ESP32 + + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer); + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); + +#if CONFIG_HAVE_DISPLAY + printQRCode(); +#endif // CONFIG_HAVE_DISPLAY + +#if CONFIG_ENABLE_PW_RPC + chip::rpc::Init(); +#endif // CONFIG_ENABLE_PW_RPC + +#if CONFIG_ENABLE_CHIP_SHELL + xTaskCreate(&chip_shell_task, "chip_shell", 8192, NULL, 5, NULL); +#endif /* CONFIG_ENABLE_CHIP_SHELL */ + + while (1) + { + vTaskDelay(100 / portTICK_PERIOD_MS); + } +} diff --git a/examples/chef/esp32/partitions.csv b/examples/chef/esp32/partitions.csv new file mode 100644 index 00000000000000..b338ff11a11589 --- /dev/null +++ b/examples/chef/esp32/partitions.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap +nvs, data, nvs, , 0x6000, +phy_init, data, phy, , 0x1000, +# Factory partition size about 1.9MB +factory, app, factory, , 1945K, diff --git a/examples/chef/esp32/sdkconfig.defaults b/examples/chef/esp32/sdkconfig.defaults new file mode 100644 index 00000000000000..ab2bb7c5dcb419 --- /dev/null +++ b/examples/chef/esp32/sdkconfig.defaults @@ -0,0 +1,49 @@ +# +# Copyright (c) 2021 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. +# + +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_DEVICE_TYPE_M5STACK=y + +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +#enable BT +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +CONFIG_ENABLE_CHIP_SHELL=y + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 + +CONFIG_STACK_CHECK_NORM=y +CONFIG_STACK_CHECK=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" diff --git a/examples/chef/esp32/sdkconfig_rpc.defaults b/examples/chef/esp32/sdkconfig_rpc.defaults new file mode 100644 index 00000000000000..517949476e7d87 --- /dev/null +++ b/examples/chef/esp32/sdkconfig_rpc.defaults @@ -0,0 +1,54 @@ +# +# Copyright (c) 2021 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. +# + +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_DEVICE_TYPE_M5STACK=y + +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +#enable BT +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +# Disable shell +CONFIG_ENABLE_CHIP_SHELL=n + +# PW RPC Debug channel +CONFIG_EXAMPLE_UART_PORT_NUM=0 +CONFIG_EXAMPLE_UART_BAUD_RATE=115200 +CONFIG_EXAMPLE_UART_RXD=3 +CONFIG_EXAMPLE_UART_TXD=1 +CONFIG_ENABLE_PW_RPC=y + +CONFIG_ESP_MAIN_TASK_STACK_SIZE=6144 + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" diff --git a/examples/chef/esp32/third_party/connectedhomeip b/examples/chef/esp32/third_party/connectedhomeip new file mode 120000 index 00000000000000..11a54ed360106c --- /dev/null +++ b/examples/chef/esp32/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../../ \ No newline at end of file diff --git a/examples/chef/linux/.gn b/examples/chef/linux/.gn new file mode 100644 index 00000000000000..5d1ce757507582 --- /dev/null +++ b/examples/chef/linux/.gn @@ -0,0 +1,25 @@ +# 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 = { + import("//args.gni") +} diff --git a/examples/chef/linux/BUILD.gn b/examples/chef/linux/BUILD.gn new file mode 100644 index 00000000000000..e1ac1f4685e40e --- /dev/null +++ b/examples/chef/linux/BUILD.gn @@ -0,0 +1,54 @@ +# 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/openthread.gni") +import("${chip_root}/build/chip/tools.gni") +import("${chip_root}/src/app/chip_data_model.gni") +import("sample.gni") + +assert(chip_build_tools) + +project_dir = "./.." + +chip_data_model("chef-data-model") { + zap_file = "${project_dir}/devices/${sample_zap_file}" + + zap_pregenerated_dir = "${chip_root}/examples/chef/zap-generated" + is_server = true +} + +executable("${sample_name}") { + sources = [ "${project_dir}/linux/main.cpp" ] + + deps = [ + ":chef-data-model", + "${chip_root}/src/controller", + "${chip_root}/src/credentials", + "${chip_root}/src/lib/shell", + "${chip_root}/src/platform", + "${project_dir}/shell_common:shell_common", + ] + + cflags = [ "-Wconversion" ] + + output_dir = root_out_dir +} + +group("chef") { + deps = [ ":${sample_name}" ] +} + +import("//build_overrides/chip.gni") diff --git a/examples/chef/linux/build_overrides b/examples/chef/linux/build_overrides new file mode 120000 index 00000000000000..e578e73312ebd1 --- /dev/null +++ b/examples/chef/linux/build_overrides @@ -0,0 +1 @@ +../../build_overrides \ No newline at end of file diff --git a/examples/chef/linux/main.cpp b/examples/chef/linux/main.cpp new file mode 100644 index 00000000000000..0335bbb6e497e0 --- /dev/null +++ b/examples/chef/linux/main.cpp @@ -0,0 +1,60 @@ +/* + * + * 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 + +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace chip; +using namespace chip::Shell; + +int main() +{ + chip::Platform::MemoryInit(); + chip::DeviceLayer::PlatformMgr().InitChipStack(); + chip::DeviceLayer::PlatformMgr().StartEventLoopTask(); +#if CHIP_DEVICE_CONFIG_ENABLE_WPA + chip::DeviceLayer::ConnectivityManagerImpl().StartWiFiManagement(); +#endif + + const int rc = Engine::Root().Init(); + + if (rc != 0) + { + ChipLogError(Shell, "Streamer initialization failed: %d", rc); + return rc; + } + + cmd_misc_init(); + cmd_otcli_init(); + cmd_ping_init(); + cmd_send_init(); +#if CHIP_SHELL_ENABLE_CMD_SERVER + cmd_app_server_init(); +#endif + + Engine::Root().RunMainLoop(); + return 0; +} diff --git a/examples/chef/linux/third_party/connectedhomeip b/examples/chef/linux/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/chef/linux/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/chef/nrfconnect/.gitignore b/examples/chef/nrfconnect/.gitignore new file mode 100644 index 00000000000000..378eac25d31170 --- /dev/null +++ b/examples/chef/nrfconnect/.gitignore @@ -0,0 +1 @@ +build diff --git a/examples/chef/nrfconnect/CHIPProjectConfig.h b/examples/chef/nrfconnect/CHIPProjectConfig.h new file mode 100644 index 00000000000000..2bd41247a382f9 --- /dev/null +++ b/examples/chef/nrfconnect/CHIPProjectConfig.h @@ -0,0 +1,37 @@ +/* + * + * 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. + */ + +/** + * @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. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Enable support functions for parsing command-line arguments +#define CHIP_CONFIG_ENABLE_ARG_PARSER 1 + +#define CHIP_DEVICE_CONFIG_DISABLE_SHELL_PING 1 diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt new file mode 100644 index 00000000000000..1a7a7afd22e322 --- /dev/null +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -0,0 +1,95 @@ +# +# 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. +# +cmake_minimum_required(VERSION 3.13.1) + +get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH) +get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH) +get_filename_component(APP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH) +get_filename_component(CHEF ${CMAKE_CURRENT_SOURCE_DIR}/../ REALPATH) +get_filename_component(GEN_DIR ${CHEF}/zap-generated/ REALPATH) + +include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake) +include(${CHEF}/project_include.cmake) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}") +set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${CONFIG_DEVICE_VENDOR_ID}") +set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_PLATFORM_NRFCONNECT=1") +message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) +message(STATUS "Vendor ID " ${CONFIG_DEVICE_VENDOR_ID}) + +# Load NCS/Zephyr build system +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) + +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf) + list(APPEND CONF_FILE boards/${BOARD}.conf) +endif() + +list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module) +find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) + +project(chip-nrfconnect-shell-example) + +include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) + +# -Wmaybe-uninitialized has too many false positives, including on std::optional +# and chip::Optional. Make it nonfatal. +# +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 +target_compile_options(app PRIVATE -Werror -Wno-error=maybe-uninitialized) + +target_include_directories(app PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common + ${APP_ROOT}/shell_common/include + ${GEN_DIR} + ${CHEF} + ${GEN_DIR}/app-common + ${NRFCONNECT_COMMON}/util/include + ${NRFCONNECT_COMMON}/app/include +) + +target_sources(app PRIVATE + ${APP_ROOT}/shell_common/globals.cpp + ${APP_ROOT}/shell_common/cmd_misc.cpp + ${APP_ROOT}/shell_common/cmd_otcli.cpp + ${APP_ROOT}/shell_common/cmd_ping.cpp + ${APP_ROOT}/shell_common/cmd_send.cpp + ${APP_ROOT}/nrfconnect/main.cpp + ${GEN_DIR}/callback-stub.cpp + ${GEN_DIR}/IMClusterCommandHandler.cpp + ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp +) + +message(STATUS ${CHEF}/devices/${SAMPLE_NAME}.zap) +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CHEF}/devices/${SAMPLE_NAME}.zap +) + + +# 1) The example needs be linked with openthread command line interpreter (required by cmd_otcli.cpp) +# 2) Zephyr shell must be disabled not to interfere with the example +# We can't achieve 1 and 2 with Kconfig since CONFIG_OPENTHREAD_SHELL implies CONFIG_SHELL. +# Hence the workaround below. +if(CONFIG_OPENTHREAD_FTD) + target_link_libraries(app INTERFACE openthread-cli-ftd) +elseif(CONFIG_OPENTHREAD_MTD) + target_link_libraries(app INTERFACE openthread-cli-mtd) +endif() + +include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/examples/chef/nrfconnect/README.md b/examples/chef/nrfconnect/README.md new file mode 100644 index 00000000000000..8e17340c92069b --- /dev/null +++ b/examples/chef/nrfconnect/README.md @@ -0,0 +1,11 @@ +# CHIP nRF Connect SDK Shell Application + +A [chip-shell](../README.md) project for the Nordic nRF52840 and nRF5340 +development kits, built using the nRF Connect SDK. + +## Building + +The steps to build the Shell Application for Nordic Semiconductor's development +kits are exactly the same as in case of the Lock Example. Please refer to +[this guide](../../lock-app/nrfconnect/README.md) to learn how to build, +program, and debug the application. diff --git a/examples/chef/nrfconnect/boards/nrf52840dk_nrf52840.overlay b/examples/chef/nrfconnect/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 00000000000000..987cbe57cec722 --- /dev/null +++ b/examples/chef/nrfconnect/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,27 @@ +/* + * 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. + */ + +/ { + /* + * In some default configurations within the nRF Connect SDK, + * e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell. + * This devicetree overlay ensures that default is overridden wherever it + * is set, as this application uses the RNG node for entropy exclusively. + */ + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/examples/chef/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.conf b/examples/chef/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 00000000000000..b9f4ed7648da78 --- /dev/null +++ b/examples/chef/nrfconnect/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,17 @@ +# +# 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. +# + +CONFIG_XOROSHIRO_RANDOM_GENERATOR=y diff --git a/examples/chef/nrfconnect/main.cpp b/examples/chef/nrfconnect/main.cpp new file mode 100644 index 00000000000000..a14c8b1bdeba8d --- /dev/null +++ b/examples/chef/nrfconnect/main.cpp @@ -0,0 +1,104 @@ +/* + * + * 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 + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace chip; +using namespace chip::Shell; + +int main() +{ + chip::Platform::MemoryInit(); + chip::DeviceLayer::PlatformMgr().InitChipStack(); + chip::DeviceLayer::PlatformMgr().StartEventLoopTask(); + + // Network connectivity +#if CHIP_DEVICE_CONFIG_ENABLE_WPA + chip::DeviceLayer::ConnectivityManagerImpl().StartWiFiManagement(); +#endif +#if CHIP_ENABLE_OPENTHREAD + chip::DeviceLayer::ThreadStackMgr().InitThreadStack(); +#ifdef CONFIG_OPENTHREAD_MTD_SED + chip::DeviceLayer::ConnectivityMgr().SetThreadDeviceType( + chip::DeviceLayer::ConnectivityManager::kThreadDeviceType_SleepyEndDevice); +#else + chip::DeviceLayer::ConnectivityMgr().SetThreadDeviceType( + chip::DeviceLayer::ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#endif /* CONFIG_OPENTHREAD_MTD_SED */ +#endif /* CHIP_ENABLE_OPENTHREAD */ + + // Start IM server + chip::Server::GetInstance().Init(); + + // Device Attestation & Onboarding codes + chip::Credentials::SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); + chip::DeviceLayer::ConfigurationMgr().LogDeviceConfig(); + + // When SoftAP support becomes available, it should be added here. +#if CONFIG_NETWORK_LAYER_BLE + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +#else + PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kOnNetwork)); +#endif /* CONFIG_NETWORK_LAYER_BLE */ + + // Starts commissioning window automatically. Starts BLE advertising when BLE enabled + if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR) + { + ChipLogError(Shell, "OpenBasicCommissioningWindow() failed"); + } + + const int rc = Engine::Root().Init(); + + if (rc != 0) + { + ChipLogError(Shell, "Streamer initialization failed: %d", rc); + return rc; + } + +#if CONFIG_ENABLE_CHIP_SHELL + cmd_misc_init(); + cmd_otcli_init(); + cmd_ping_init(); + cmd_send_init(); +#endif + +#if CHIP_SHELL_ENABLE_CMD_SERVER + cmd_app_server_init(); +#endif + +#if CONFIG_ENABLE_CHIP_SHELL + Engine::Root().RunMainLoop(); +#endif + + return 0; +} diff --git a/examples/chef/nrfconnect/prj.conf b/examples/chef/nrfconnect/prj.conf new file mode 100644 index 00000000000000..2c47390feaa450 --- /dev/null +++ b/examples/chef/nrfconnect/prj.conf @@ -0,0 +1,42 @@ +# +# 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. +# + +# This sample uses sample-defaults.conf to set options common for all +# samples. This file should contain only options specific for this sample +# or overrides of default values. + +# Add support for LEDs and buttons on Nordic development kits +CONFIG_DK_LIBRARY=y + +# OpenThread configs +CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD=y + +# Configure CHIP shell +CONFIG_CHIP_LIB_SHELL=y +CONFIG_OPENTHREAD_SHELL=n + +# Some shell commands require OpenThread FTD configuration +CONFIG_OPENTHREAD_MTD=n +CONFIG_OPENTHREAD_FTD=y + +# Additional configs for debbugging experience. +CONFIG_THREAD_NAME=y +CONFIG_MPU_STACK_GUARD=y +CONFIG_RESET_ON_FATAL_ERROR=n + +# CHIP configuration +CONFIG_CHIP_PROJECT_CONFIG="CHIPProjectConfig.h" +CONFIG_CHIP_NFC_COMMISSIONING=n diff --git a/examples/chef/nrfconnect/third_party/connectedhomeip b/examples/chef/nrfconnect/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/chef/nrfconnect/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/chef/shell_common b/examples/chef/shell_common new file mode 120000 index 00000000000000..ff72f69b4e1025 --- /dev/null +++ b/examples/chef/shell_common @@ -0,0 +1 @@ +../shell/shell_common \ No newline at end of file diff --git a/scripts/tools/zap_regen_all.py b/scripts/tools/zap_regen_all.py index e990aea54042b7..f953e822d04174 100755 --- a/scripts/tools/zap_regen_all.py +++ b/scripts/tools/zap_regen_all.py @@ -115,6 +115,9 @@ def getGlobalTemplatesTargets(): ZAPGenerateTarget(filepath, output_dir=output_dir, template=template)) continue + if example_name == "chef": + continue + logging.info("Found example %s (via %s)" % (example_name, str(filepath))) diff --git a/src/lib/shell/streamer_esp32.cpp b/src/lib/shell/streamer_esp32.cpp index e5daaf324c7281..c35abed55c5eb0 100644 --- a/src/lib/shell/streamer_esp32.cpp +++ b/src/lib/shell/streamer_esp32.cpp @@ -82,6 +82,7 @@ int streamer_esp32_init(streamer_t * streamer) esp_console_cmd_t command = { .command = "matter", .help = "Matter utilities", .func = chip_command_handler }; ESP_ERROR_CHECK(esp_console_cmd_register(&command)); + ESP_ERROR_CHECK(esp_console_register_help_command()); return 0; } diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 5dcbb9787dc03b..9292c658db44e3 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -37,12 +37,16 @@ #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY CONFIG_CHIP_TASK_PRIORITY #define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE CONFIG_MAX_EVENT_QUEUE_SIZE +#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID #define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID CONFIG_DEVICE_VENDOR_ID +#endif /* CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID CONFIG_DEVICE_PRODUCT_ID #define CHIP_DEVICE_CONFIG_DEVICE_TYPE CONFIG_DEVICE_TYPE #define CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING CONFIG_DEVICE_SOFTWARE_VERSION #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER +#endif /* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID */ #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_OPENTHREAD_ENABLED #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT