From cdc28b4d7fd8e5dce927d27eaceecd40e8655a72 Mon Sep 17 00:00:00 2001 From: PSONALl Date: Mon, 4 Dec 2023 15:24:24 +0530 Subject: [PATCH 1/5] EVSE app on esp32 --- .../energy-management-app/esp32/.gitignore | 4 + .../esp32/CMakeLists.txt | 87 ++++++ .../energy-management-app/esp32/README.md | 52 ++++ .../esp32/main/CMakeLists.txt | 247 ++++++++++++++++++ .../esp32/main/DeviceCallbacks.cpp | 42 +++ .../esp32/main/Kconfig.projbuild | 187 +++++++++++++ .../esp32/main/idf_component.yml | 2 + .../esp32/main/include/CHIPProjectConfig.h | 47 ++++ .../esp32/main/include/DeviceCallbacks.h | 33 +++ .../energy-management-app/esp32/main/main.cpp | 239 +++++++++++++++++ .../energy-management-app/esp32/output.py | 105 ++++++++ .../esp32/partitions.csv | 10 + .../esp32/partitions_encrypted.csv | 8 + .../esp32/sdkconfig.defaults | 66 +++++ .../esp32/sdkconfig.defaults.esp32c2 | 22 ++ .../esp32/sdkconfig.defaults.esp32c6 | 67 +++++ .../esp32/sdkconfig.defaults.esp32h2 | 81 ++++++ .../esp32/sdkconfig.optimize.defaults | 95 +++++++ .../esp32/sdkconfig_m5stack.defaults | 71 +++++ .../esp32/sdkconfig_rpc.defaults | 57 ++++ .../esp32/third_party/connectedhomeip | 1 + 21 files changed, 1523 insertions(+) create mode 100644 examples/energy-management-app/esp32/.gitignore create mode 100644 examples/energy-management-app/esp32/CMakeLists.txt create mode 100644 examples/energy-management-app/esp32/README.md create mode 100644 examples/energy-management-app/esp32/main/CMakeLists.txt create mode 100644 examples/energy-management-app/esp32/main/DeviceCallbacks.cpp create mode 100644 examples/energy-management-app/esp32/main/Kconfig.projbuild create mode 100644 examples/energy-management-app/esp32/main/idf_component.yml create mode 100644 examples/energy-management-app/esp32/main/include/CHIPProjectConfig.h create mode 100644 examples/energy-management-app/esp32/main/include/DeviceCallbacks.h create mode 100644 examples/energy-management-app/esp32/main/main.cpp create mode 100644 examples/energy-management-app/esp32/output.py create mode 100644 examples/energy-management-app/esp32/partitions.csv create mode 100644 examples/energy-management-app/esp32/partitions_encrypted.csv create mode 100644 examples/energy-management-app/esp32/sdkconfig.defaults create mode 100644 examples/energy-management-app/esp32/sdkconfig.defaults.esp32c2 create mode 100644 examples/energy-management-app/esp32/sdkconfig.defaults.esp32c6 create mode 100644 examples/energy-management-app/esp32/sdkconfig.defaults.esp32h2 create mode 100644 examples/energy-management-app/esp32/sdkconfig.optimize.defaults create mode 100644 examples/energy-management-app/esp32/sdkconfig_m5stack.defaults create mode 100644 examples/energy-management-app/esp32/sdkconfig_rpc.defaults create mode 120000 examples/energy-management-app/esp32/third_party/connectedhomeip diff --git a/examples/energy-management-app/esp32/.gitignore b/examples/energy-management-app/esp32/.gitignore new file mode 100644 index 00000000000000..601ff1b8e9e01e --- /dev/null +++ b/examples/energy-management-app/esp32/.gitignore @@ -0,0 +1,4 @@ +/build/ +/sdkconfig +/sdkconfig.old +main/insights_auth_key.txt diff --git a/examples/energy-management-app/esp32/CMakeLists.txt b/examples/energy-management-app/esp32/CMakeLists.txt new file mode 100644 index 00000000000000..c9944ab9a39e46 --- /dev/null +++ b/examples/energy-management-app/esp32/CMakeLists.txt @@ -0,0 +1,87 @@ +# +# Copyright (c) 2021-2023 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. + +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(PROJECT_VER "v1.0") +set(PROJECT_VER_NUMBER 1) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cmake/idf_flashing.cmake) + +set(EXTRA_COMPONENT_DIRS + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common" +) + +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components") +endif() + + +project(chip-energy-management-app) + +# WARNING: This is just an example for using key for decrypting the encrypted OTA image +# Please do not use it as is. +if(CONFIG_ENABLE_ENCRYPTED_OTA) + target_add_binary_data(chip-energy-management-app.elf "esp_image_encryption_key.pem" TEXT) +endif() + +# C++17 is required for RPC build. +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND) +idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND) +# For the C3, project_include.cmake sets -Wno-format, but does not clear various +# flags that depend on -Wformat +idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND) + +# -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 +idf_build_set_property(COMPILE_OPTIONS "-Wno-error=maybe-uninitialized" APPEND) + +#For the H2, -Werror=uninitialized will cause an error in "src/lib/support/LambdaBridge.h" +idf_build_set_property(COMPILE_OPTIONS "-Wno-error=uninitialized" APPEND) + +flashing_script() + +if (CONFIG_ENABLE_PW_RPC) +get_filename_component(CHIP_ROOT ./third_party/connectedhomeip REALPATH) +include(third_party/connectedhomeip/third_party/pigweed/repo/pw_build/pigweed.cmake) +include($ENV{PW_ROOT}/pw_assert/backend.cmake) +include($ENV{PW_ROOT}/pw_log/backend.cmake) +include($ENV{PW_ROOT}/pw_sys_io/backend.cmake) +include($ENV{PW_ROOT}/pw_trace/backend.cmake) + +pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config) + +pw_set_backend(pw_log pw_log_basic) +pw_set_backend(pw_assert.check pw_assert_log.check_backend) +pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend) +pw_set_backend(pw_sys_io pw_sys_io.esp32) +pw_set_backend(pw_trace pw_trace_tokenized) + +add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo) +add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo) +add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io) + +get_target_property(_target_cxx_flags pw_build.cpp17._public_config INTERFACE_COMPILE_OPTIONS) +list(REMOVE_ITEM _target_cxx_flags $<$:-std=c++17>) +list(APPEND _target_cxx_flags $<$:-std=gnu++17>) +set_target_properties(pw_build.cpp17._public_config PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}") +endif(CONFIG_ENABLE_PW_RPC) diff --git a/examples/energy-management-app/esp32/README.md b/examples/energy-management-app/esp32/README.md new file mode 100644 index 00000000000000..77335382afbcb9 --- /dev/null +++ b/examples/energy-management-app/esp32/README.md @@ -0,0 +1,52 @@ +# Matter ESP32 Energy Management Example + +This example demonstrates the Matter EVSE application on ESP platforms. + +Please +[setup ESP-IDF and CHIP Environment](../../../docs/guides/esp32/setup_idf_chip.md) +and refer +[building and commissioning](../../../docs/guides/esp32/build_app_and_commission.md) +guides to get started. + +### Enabling ESP-Insights: + +- Before building the app, enable the option: ESP_INSIGHTS_ENABLED through + menuconfig. + +- Create a file named insights_auth_key.txt in the main directory of the + example. + +- Follow the steps + present[here](https://github.com/espressif/esp-insights/blob/main/examples/README.md#set-up-esp-insights-account) + to set up an insights_account and the auth key created while setting it up + will be used in the example. + +- Download the auth key and copy Auth Key to the example + +``` +cp /path/to/auth/key.txt path/to/connectedhomeip/examples/energy-management-app/esp32/main/insights_auth_key.txt +``` + +--- + +- [Cluster Control](#cluster-control) +- [Matter OTA guide](../../../docs/guides/esp32/ota.md) + +--- + +### Cluster Control + +- After successful commissioning, use the OnOff cluster command to control the + OnOff attribute. This allows you to toggle a parameter implemented by the + device to be On or Off. + + $ ./out/debug/chip-tool onoff on 1 + +- On + [ESP32C3-DevKitM](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html) + or + [ESP32S3-DevKitM](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitm-1.html) + board, there is an on-board RGB-LED. Use ColorControl cluster command to + control the color attributes: + + $ ./out/debug/chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 1 diff --git a/examples/energy-management-app/esp32/main/CMakeLists.txt b/examples/energy-management-app/esp32/main/CMakeLists.txt new file mode 100644 index 00000000000000..1c7f2a5b782948 --- /dev/null +++ b/examples/energy-management-app/esp32/main/CMakeLists.txt @@ -0,0 +1,247 @@ +# +# Copyright (c) 2021-2023 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.) + +set(PRIV_INCLUDE_DIRS_LIST + "${APP_GEN_DIR}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/include" + "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" +) +set(SRC_DIRS_LIST + "${CMAKE_CURRENT_LIST_DIR}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/src" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" + "${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/src/app/clusters/access-control-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/barrier-control-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-evse-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" +) + +set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash) + +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND PRIV_REQUIRES_LIST spidriver screen-framework) +endif() + + +if (CONFIG_ENABLE_PW_RPC) +# Append additional directories for RPC build +set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" +) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + +set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" +) +endif (CONFIG_ENABLE_PW_RPC) + +idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} + SRC_DIRS ${SRC_DIRS_LIST} + PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) +get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) + +include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") + +chip_app_component_codegen("${CHIP_ROOT}/examples/energy-management-app/energy-management-common/energy-management-app.matter") +chip_app_component_zapgen("${CHIP_ROOT}/examples/energy-management-app/energy-management-common/energy-management-app.zap") + +if (CONFIG_ENABLE_ESP_INSIGHTS_TRACE) + target_add_binary_data(${COMPONENT_TARGET} "insights_auth_key.txt" TEXT) +endif() + +set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) +target_compile_options(${COMPONENT_LIB} PRIVATE "-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 ${CMAKE_SOURCE_DIR}/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_proto +) + +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_proto +) + +pw_proto_library(descriptor_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto + PREFIX + descriptor_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +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_proto +) + +pw_proto_library(lighting_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/lighting_service.proto + PREFIX + lighting_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(locking_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/locking_service.proto + PREFIX + locking_service + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos + DEPS + pw_protobuf.common_proto +) + +pw_proto_library(wifi_service + SOURCES + ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.proto + INPUTS + ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.options + PREFIX + wifi_service + DEPS + pw_protobuf.common_proto + STRIP_PREFIX + ${CHIP_ROOT}/examples/common/pigweed/protos +) + +target_link_libraries(${COMPONENT_LIB} PUBLIC + attributes_service.nanopb_rpc + button_service.nanopb_rpc + descriptor_service.nanopb_rpc + device_service.nanopb_rpc + lighting_service.nanopb_rpc + locking_service.nanopb_rpc + wifi_service.nanopb_rpc + pw_checksum + pw_hdlc + pw_log + pw_rpc.server + pw_sys_io + pw_trace + 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" + "-L${PIGWEED_ROOT}/pw_tokenizer" +) + +target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DESCRIPTOR_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_LIGHTING_SERVICE=1" + "-DPW_RPC_LOCKING_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1" + "-DPW_RPC_WIFI_SERVICE=1" + "-DPW_TRACE_BACKEND_SET=1") + +endif (CONFIG_ENABLE_PW_RPC) diff --git a/examples/energy-management-app/esp32/main/DeviceCallbacks.cpp b/examples/energy-management-app/esp32/main/DeviceCallbacks.cpp new file mode 100644 index 00000000000000..46f2dccc348663 --- /dev/null +++ b/examples/energy-management-app/esp32/main/DeviceCallbacks.cpp @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2021-2023 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 "DeviceCallbacks.h" + +#include + +#include +#include +#include +#include +#include + +static const char * TAG = "energy-management-app-callbacks"; + +using namespace chip; +using namespace chip::Inet; +using namespace chip::System; +using namespace chip::app::Clusters; + +void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, + uint8_t type, uint16_t size, uint8_t * value) +{ + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", + clusterId, endpointId, attributeId); + + ESP_LOGI(TAG, "Current free heap: %u\n", static_cast(heap_caps_get_free_size(MALLOC_CAP_8BIT))); +} diff --git a/examples/energy-management-app/esp32/main/Kconfig.projbuild b/examples/energy-management-app/esp32/main/Kconfig.projbuild new file mode 100644 index 00000000000000..d994865b7aaee4 --- /dev/null +++ b/examples/energy-management-app/esp32/main/Kconfig.projbuild @@ -0,0 +1,187 @@ +# +# Copyright (c) 2021-2023 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 + default DEVICE_TYPE_ESP32_S3_DEVKITM if IDF_TARGET_ESP32S3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 + default DEVICE_TYPE_ESP32_C6_DEVKITC if IDF_TARGET_ESP32C6 + default DEVICE_TYPE_ESP32_H2_DEVKITC if IDF_TARGET_ESP32H2 + 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 + config DEVICE_TYPE_ESP32_S3_DEVKITM + bool "ESP32S3-DevKitM" + depends on IDF_TARGET_ESP32S3 + config DEVICE_TYPE_ESP32H2_DEVKITC + bool "ESP32H2-DevKitC" + depends on IDF_TARGET_ESP32H2 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 + config DEVICE_TYPE_ESP32_C6_DEVKITC + bool "ESP32C6-DevKitC" + depends on IDF_TARGET_ESP32C6 + endchoice + + config CHIP_PROJECT_CONFIG + string "CHIP Project Configuration file" + default "main/include/CHIPProjectConfig.h" + + choice LED_TYPE + prompt "LED type" + default LED_TYPE_RMT if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_S3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C6_DEVKITC + default LED_TYPE_GPIO + help + Defines the default LED type used in the example + + config LED_TYPE_GPIO + bool "GPIO" + config LED_TYPE_RMT + bool "RMT - Addressable LED" + endchoice + + config LED_RMT_CHANNEL + depends on LED_TYPE_RMT + int "RMT Channel" + range 0 7 + default 0 + help + Set the RMT peripheral channel. + ESP32 RMT channel from 0 to 7 + ESP32-S3 RMT channel from 0 to 3 + ESP32-C3 RMT channel from 0 to 1 + + config LED_GPIO + int "LED GPIO number" + range 0 48 + default 26 if DEVICE_TYPE_ESP32_WROVER_KIT + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC + default 48 if DEVICE_TYPE_ESP32_S3_DEVKITM + default 5 if DEVICE_TYPE_M5STACK + default 5 + help + GPIO number (IOxx) to blink on and off or the RMT signal for the addressable LED. + + choice + prompt "Rendezvous Mode" + default RENDEZVOUS_MODE_BLE + help + Specifies the Rendezvous mode of the peripheral. + + config RENDEZVOUS_MODE_WIFI + bool "Wi-Fi" + config RENDEZVOUS_MODE_BLE + bool "BLE" + config RENDEZVOUS_MODE_THREAD + bool "Thread" + config RENDEZVOUS_MODE_ETHERNET + bool "Ethernet" + endchoice + + # 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 || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C6_DEVKITC + default 3 if DEVICE_TYPE_M5STACK + default 4 if DEVICE_TYPE_ESP32_WROVER_KIT + + config HAVE_DISPLAY + bool + default y if DEVICE_TYPE_M5STACK || DEVICE_TYPE_ESP32_WROVER_KIT + default n if !(DEVICE_TYPE_M5STACK || DEVICE_TYPE_ESP32_WROVER_KIT) + + config RENDEZVOUS_MODE + int + range 0 8 + default 1 if RENDEZVOUS_MODE_WIFI + default 2 if RENDEZVOUS_MODE_BLE + default 4 if RENDEZVOUS_MODE_THREAD + default 8 if RENDEZVOUS_MODE_ETHERNET + + 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/energy-management-app/esp32/main/idf_component.yml b/examples/energy-management-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/energy-management-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/energy-management-app/esp32/main/include/CHIPProjectConfig.h b/examples/energy-management-app/esp32/main/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..559895608a08d0 --- /dev/null +++ b/examples/energy-management-app/esp32/main/include/CHIPProjectConfig.h @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2023 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 + +/** + * @def CHIP_CONFIG_MAX_FABRICS + * + * @brief + * Maximum number of fabrics the device can participate in. Each fabric can + * provision the device with its unique operational credentials and manage + * its own access control lists. + */ +#define CHIP_CONFIG_MAX_FABRICS 5 // 5 is the minimum number of supported fabrics + +/** + * @def CHIP_IM_MAX_NUM_SUBSCRIPTIONS + * + * @brief Defines the maximum number of ReadHandler for subscriptions, limits the number of active subscription transactions on + * server. + * + */ +#define CHIP_IM_MAX_NUM_SUBSCRIPTIONS 45 diff --git a/examples/energy-management-app/esp32/main/include/DeviceCallbacks.h b/examples/energy-management-app/esp32/main/include/DeviceCallbacks.h new file mode 100644 index 00000000000000..3434cf9437c03d --- /dev/null +++ b/examples/energy-management-app/esp32/main/include/DeviceCallbacks.h @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2021-2023 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 +#include +#include +#include + +class AppDeviceCallbacks : public CommonDeviceCallbacks +{ +public: + virtual void PostAttributeChangeCallback(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId, + uint8_t type, uint16_t size, uint8_t * value); + +private: + void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); +}; diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp new file mode 100644 index 00000000000000..b4c523e2698374 --- /dev/null +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -0,0 +1,239 @@ +/* + * + * Copyright (c) 2021-2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DeviceCallbacks.h" +#include +#include +#include + +#include "esp_log.h" +#include +#include +#include +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) +#include "spi_flash_mmap.h" +#else +#include "esp_spi_flash.h" +#endif +#include "esp_system.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "nvs_flash.h" +#include "shell_extension/launch.h" +#include "shell_extension/openthread_cli_register.h" +#include +#include +#include +#include +#include + +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +#include +#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + +#if CONFIG_ENABLE_PW_RPC +#include "Rpc.h" +#endif + +#if CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +#include +#else +#include +#endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER + +#if CONFIG_SEC_CERT_DAC_PROVIDER +#include +#endif + +#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE +#include +#include +#include +#endif + +#define ENERGY_EVSE_ENDPOINT 1 + +using namespace ::chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceManager; +using namespace ::chip::DeviceLayer; + +static EnergyEvseDelegate * gDelegate = nullptr; +static EnergyEvseManager * gInstance = nullptr; +static EVSEManufacturer * gEvseManufacturer = nullptr; + +#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE +extern const char insights_auth_key_start[] asm("_binary_insights_auth_key_txt_start"); +extern const char insights_auth_key_end[] asm("_binary_insights_auth_key_txt_end"); +#endif + +static const char * TAG = "energy-management-app"; + +static AppDeviceCallbacks EchoCallbacks; +static DeviceCallbacksDelegate sAppDeviceCallbacksDelegate; + +namespace { +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider; +#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + +#if CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +DeviceLayer::ESP32DeviceInfoProvider gExampleDeviceInfoProvider; +#else +DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; +#endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER + +#if CONFIG_SEC_CERT_DAC_PROVIDER +DeviceLayer::ESP32SecureCertDACProvider gSecureCertDACProvider; +#endif // CONFIG_SEC_CERT_DAC_PROVIDER + +chip::Credentials::DeviceAttestationCredentialsProvider * get_dac_provider(void) +{ +#if CONFIG_SEC_CERT_DAC_PROVIDER + return &gSecureCertDACProvider; +#elif CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + return &sFactoryDataProvider; +#else // EXAMPLE_DAC_PROVIDER + return chip::Credentials::Examples::GetExampleDACProvider(); +#endif +} + +} // namespace + +void ApplicationInit() +{ + if ((gDelegate == nullptr) && (gInstance == nullptr)) + { + gDelegate = new EnergyEvseDelegate(); + if (gDelegate != nullptr) + { + gInstance = new EnergyEvseManager( + EndpointId(ENERGY_EVSE_ENDPOINT), *gDelegate, + BitMask(EnergyEvse::Feature::kChargingPreferences, + EnergyEvse::Feature::kPlugAndCharge, EnergyEvse::Feature::kRfid, + EnergyEvse::Feature::kSoCReporting, EnergyEvse::Feature::kV2x), + BitMask(OptionalAttributes::kSupportsUserMaximumChargingCurrent, + OptionalAttributes::kSupportsRandomizationWindow, + OptionalAttributes::kSupportsApproximateEvEfficiency), + BitMask(OptionalCommands::kSupportsStartDiagnostics)); + gInstance->Init(); /* Register Attribute & Command handlers */ + } + } + else + { + ChipLogError(AppServer, "EVSE Instance or Delegate already exist.") + } + + if (gEvseManufacturer == nullptr) + { + gEvseManufacturer = new EVSEManufacturer(); + gEvseManufacturer->Init(gInstance); + } + else + { + ChipLogError(AppServer, "EVSEManufacturer already exists.") + } +} + +static void InitServer(intptr_t context) +{ + ApplicationInit(); + // Print QR Code URL + PrintOnboardingCodes(chip::RendezvousInformationFlags(CONFIG_RENDEZVOUS_MODE)); + + DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate); + Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config +#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE + esp_insights_config_t config = { + .log_type = ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT, + .auth_key = insights_auth_key_start, + }; + + esp_err_t ret = esp_insights_init(&config); + + if (ret != ESP_OK) + { + ESP_LOGE(TAG, "Failed to initialize ESP Insights, err:0x%x", ret); + } + + static Tracing::Insights::ESP32Backend backend; + Tracing::Register(backend); +#endif +} + +extern "C" void app_main() +{ + // Initialize the ESP NVS layer. + esp_err_t err = nvs_flash_init(); + if (err != ESP_OK) + { + ESP_LOGE(TAG, "nvs_flash_init() failed: %s", esp_err_to_name(err)); + return; + } + err = esp_event_loop_create_default(); + if (err != ESP_OK) + { + ESP_LOGE(TAG, "esp_event_loop_create_default() failed: %s", esp_err_to_name(err)); + return; + } +#if CONFIG_ENABLE_PW_RPC + chip::rpc::Init(); +#endif + + ESP_LOGI(TAG, "=================================================="); + ESP_LOGI(TAG, "chip-esp32-energy-management-example starting"); + ESP_LOGI(TAG, "=================================================="); + +#if CONFIG_ENABLE_CHIP_SHELL +#if CONFIG_OPENTHREAD_CLI + chip::RegisterOpenThreadCliCommands(); +#endif + chip::LaunchShell(); +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + if (Internal::ESP32Utils::InitWiFiStack() != CHIP_NO_ERROR) + { + ESP_LOGE(TAG, "Failed to initialize WiFi stack"); + return; + } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + + DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + + CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); + CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); + if (error != CHIP_NO_ERROR) + { + ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + return; + } + +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + SetCommissionableDataProvider(&sFactoryDataProvider); +#if CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&sFactoryDataProvider); +#endif +#endif + + SetDeviceAttestationCredentialsProvider(get_dac_provider()); + ESPOpenThreadInit(); + + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); + +} diff --git a/examples/energy-management-app/esp32/output.py b/examples/energy-management-app/esp32/output.py new file mode 100644 index 00000000000000..566d6438540a1d --- /dev/null +++ b/examples/energy-management-app/esp32/output.py @@ -0,0 +1,105 @@ +cluster_t *IdentifyCluster = esp_matter::cluster::create(endpoint, 3, CLUSTER_FLAG_SERVER); + set_plugin_server_init_callback(IdentifyCluster, MatterIdentifyPluginServerInitCallback); + add_function_list(IdentifyCluster, identify_function_list, CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION); + +attribute_t *identifyTimeAttribute = esp_matter::attribute::create(IdentifyCluster, 0, ATTRIBUTE_FLAG_WRITABLE,0); + esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(m ax)); +# min and max are mentioned in spec and also in esp_matter_cluster.cpp + +attribute_t *identifyTypeAttribute = esp_matter::attribute::create(IdentifyCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(IdentifyCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(IdentifyCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *eventListAttribute = esp_matter::attribute::create(IdentifyCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *attributeListAttribute = esp_matter::attribute::create(IdentifyCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *featureMapAttribute = esp_matter::attribute::create(IdentifyCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(IdentifyCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +command_t *IdentifyCommand = esp_matter::command::create(IdentifyCluster, 0, COMMAND_FLAGS, commandCallback); +command_t *TriggerEffectCommand = esp_matter::command::create(IdentifyCluster, 64, COMMAND_FLAGS, commandCallback); + +cluster_t *GroupsCluster = esp_matter::cluster::create(endpoint, 4, CLUSTER_FLAG_SERVER); + set_plugin_server_init_callback(cluster, MatterGroupsPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + +attribute_t *nameSupportAttribute = esp_matter::attribute::create(GroupsCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(GroupsCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(GroupsCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *eventListAttribute = esp_matter::attribute::create(GroupsCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *attributeListAttribute = esp_matter::attribute::create(GroupsCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *featureMapAttribute = esp_matter::attribute::create(GroupsCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(GroupsCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +command_t *AddGroupCommand = esp_matter::command::create(GroupsCluster, 0, COMMAND_FLAGS, commandCallback); +command_t *ViewGroupCommand = esp_matter::command::create(GroupsCluster, 1, COMMAND_FLAGS, commandCallback); +command_t *GetGroupMembershipCommand = esp_matter::command::create(GroupsCluster, 2, COMMAND_FLAGS, commandCallback); +command_t *RemoveGroupCommand = esp_matter::command::create(GroupsCluster, 3, COMMAND_FLAGS, commandCallback); +command_t *RemoveAllGroupsCommand = esp_matter::command::create(GroupsCluster, 4, COMMAND_FLAGS, commandCallback); +command_t *AddGroupIfIdentifyingCommand = esp_matter::command::create(GroupsCluster, 5, COMMAND_FLAGS, commandCallback); + +cluster_t *ScenesCluster = esp_matter::cluster::create(endpoint, 5, CLUSTER_FLAG_SERVER); + set_plugin_server_init_callback(cluster, MatterScenesPluginServerInitCallback); + add_function_list(cluster, NULL, CLUSTER_FLAG_NONE); + +attribute_t *sceneCountAttribute = esp_matter::attribute::create(ScenesCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *currentSceneAttribute = esp_matter::attribute::create(ScenesCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *currentGroupAttribute = esp_matter::attribute::create(ScenesCluster, 2, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *sceneValidAttribute = esp_matter::attribute::create(ScenesCluster, 3, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *nameSupportAttribute = esp_matter::attribute::create(ScenesCluster, 4, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *lastConfiguredByAttribute = esp_matter::attribute::create(ScenesCluster, 5, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *sceneTableSizeAttribute = esp_matter::attribute::create(ScenesCluster, 6, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *remainingCapacityAttribute = esp_matter::attribute::create(ScenesCluster, 7, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(ScenesCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(ScenesCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *eventListAttribute = esp_matter::attribute::create(ScenesCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *attributeListAttribute = esp_matter::attribute::create(ScenesCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *featureMapAttribute = esp_matter::attribute::create(ScenesCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(ScenesCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +command_t *AddSceneCommand = esp_matter::command::create(ScenesCluster, 0, COMMAND_FLAGS, commandCallback); +command_t *ViewSceneCommand = esp_matter::command::create(ScenesCluster, 1, COMMAND_FLAGS, commandCallback); +command_t *RemoveSceneCommand = esp_matter::command::create(ScenesCluster, 2, COMMAND_FLAGS, commandCallback); +command_t *RemoveAllScenesCommand = esp_matter::command::create(ScenesCluster, 3, COMMAND_FLAGS, commandCallback); +command_t *StoreSceneCommand = esp_matter::command::create(ScenesCluster, 4, COMMAND_FLAGS, commandCallback); +command_t *RecallSceneCommand = esp_matter::command::create(ScenesCluster, 5, COMMAND_FLAGS, commandCallback); +command_t *GetSceneMembershipCommand = esp_matter::command::create(ScenesCluster, 6, COMMAND_FLAGS, commandCallback); +command_t *EnhancedAddSceneCommand = esp_matter::command::create(ScenesCluster, 64, COMMAND_FLAGS, commandCallback); +command_t *EnhancedViewSceneCommand = esp_matter::command::create(ScenesCluster, 65, COMMAND_FLAGS, commandCallback); +command_t *CopySceneCommand = esp_matter::command::create(ScenesCluster, 66, COMMAND_FLAGS, commandCallback); + +cluster_t *OnOffCluster = esp_matter::cluster::create(endpoint, 6, CLUSTER_FLAG_SERVER); +attribute_t *onOffAttribute = esp_matter::attribute::create(OnOffCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); + set_plugin_server_init_callback(cluster, MatterOnOffPluginServerInitCallback); + add_function_list(cluster, on_off_function_list, CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FUNCTION); + + +attribute_t *globalSceneControlAttribute = esp_matter::attribute::create(OnOffCluster, 16384, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *onTimeAttribute = esp_matter::attribute::create(OnOffCluster, 16385, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *offWaitTimeAttribute = esp_matter::attribute::create(OnOffCluster, 16386, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *startUpOnOffAttribute = esp_matter::attribute::create(OnOffCluster, 16387, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(OnOffCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(OnOffCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *eventListAttribute = esp_matter::attribute::create(OnOffCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *attributeListAttribute = esp_matter::attribute::create(OnOffCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *featureMapAttribute = esp_matter::attribute::create(OnOffCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(OnOffCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +command_t *OffCommand = esp_matter::command::create(OnOffCluster, 0, COMMAND_FLAGS, commandCallback); +command_t *OnCommand = esp_matter::command::create(OnOffCluster, 1, COMMAND_FLAGS, commandCallback); +command_t *ToggleCommand = esp_matter::command::create(OnOffCluster, 2, COMMAND_FLAGS, commandCallback); +command_t *OffWithEffectCommand = esp_matter::command::create(OnOffCluster, 64, COMMAND_FLAGS, commandCallback); +command_t *OnWithRecallGlobalSceneCommand = esp_matter::command::create(OnOffCluster, 65, COMMAND_FLAGS, commandCallback); +command_t *OnWithTimedOffCommand = esp_matter::command::create(OnOffCluster, 66, COMMAND_FLAGS, commandCallback); + + +cluster_t *DescriptorCluster = esp_matter::cluster::create(endpoint, 29, CLUSTER_FLAG_SERVER); + set_plugin_server_init_callback(cluster, MatterDescriptorPluginServerInitCallback); + add_function_list(cluster, NULL, CLUSTER_FLAG_NONE); + +attribute_t *deviceTypeListAttribute = esp_matter::attribute::create(DescriptorCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *serverListAttribute = esp_matter::attribute::create(DescriptorCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clientListAttribute = esp_matter::attribute::create(DescriptorCluster, 2, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *partsListAttribute = esp_matter::attribute::create(DescriptorCluster, 3, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(DescriptorCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(DescriptorCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *eventListAttribute = esp_matter::attribute::create(DescriptorCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *attributeListAttribute = esp_matter::attribute::create(DescriptorCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *featureMapAttribute = esp_matter::attribute::create(DescriptorCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(DescriptorCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); +endpoint_t *endpoint = esp_matter::endpoint::create(node, 1, ENDPOINT_FLAGS, priv_data); + diff --git a/examples/energy-management-app/esp32/partitions.csv b/examples/energy-management-app/esp32/partitions.csv new file mode 100644 index 00000000000000..428d873fa54a05 --- /dev/null +++ b/examples/energy-management-app/esp32/partitions.csv @@ -0,0 +1,10 @@ +# Name, Type, SubType, Offset, Size, Flags +# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table +esp_secure_cert, 0x3F, , 0xD000, 0x2000, encrypted +nvs, data, nvs, 0x10000, 0xC000, +nvs_keys, data, nvs_keys,, 0x1000, +otadata, data, ota, , 0x2000 +phy_init, data, phy, , 0x1000, +ota_0, app, ota_0, 0x20000, 0x1E0000, +ota_1, app, ota_1, 0x200000, 0x1E0000, +fctry, data, nvs, 0x3E0000, 0x6000 diff --git a/examples/energy-management-app/esp32/partitions_encrypted.csv b/examples/energy-management-app/esp32/partitions_encrypted.csv new file mode 100644 index 00000000000000..94ec9f7a2b7f17 --- /dev/null +++ b/examples/energy-management-app/esp32/partitions_encrypted.csv @@ -0,0 +1,8 @@ +# 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, , 0xC000, +otadata, data, ota, , 0x2000, encrypted +phy_init, data, phy, , 0x1000, encrypted +ota_0, app, ota_0, , 1500K, encrypted +ota_1, app, ota_1, , 1500K, encrypted +nvs_key, data, nvs_keys,, 0x1000, encrypted diff --git a/examples/energy-management-app/esp32/sdkconfig.defaults b/examples/energy-management-app/esp32/sdkconfig.defaults new file mode 100644 index 00000000000000..a8833c13a1a23b --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig.defaults @@ -0,0 +1,66 @@ +# +# 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. +# +# Description: +# Some useful defaults for the demo app configuration. +# + +# 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 + +#disable BT connection reattempt +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +#enable debug shell +CONFIG_ENABLE_CHIP_SHELL=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +#enable lwIP route hooks +CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y +CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so suppressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y + +# Disable Read Client +CONFIG_DISABLE_READ_CLIENT=y + +# Increase LwIP IPv6 address number +CONFIG_LWIP_IPV6_NUM_ADDRESSES=6 diff --git a/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c2 b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..5e5d596cacb673 --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,22 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c6 b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c6 new file mode 100644 index 00000000000000..4947bd2fdf276f --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32c6 @@ -0,0 +1,67 @@ +CONFIG_IDF_TARGET="esp32c6" + +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +# libsodium +CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y + + +# NIMBLE +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_BT_NIMBLE_EXT_ADV=n +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n + +# Disable OpenThread +CONFIG_OPENTHREAD_ENABLED=n + +# Disable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=n + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" + +# LwIP config for OpenThread +CONFIG_LWIP_IPV6_NUM_ADDRESSES=8 +CONFIG_LWIP_MULTICAST_PING=y + +# mbedTLS +CONFIG_MBEDTLS_HARDWARE_AES=n +CONFIG_MBEDTLS_HARDWARE_MPI=n +CONFIG_MBEDTLS_HARDWARE_SHA=n +CONFIG_MBEDTLS_HARDWARE_ECC=y +CONFIG_MBEDTLS_CMAC_C=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y +CONFIG_MBEDTLS_ECJPAKE_C=y + +# MDNS platform +CONFIG_USE_MINIMAL_MDNS=y +CONFIG_ENABLE_EXTENDED_DISCOVERY=y + +# FreeRTOS should use legacy API +CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y + +# Wi-Fi Settings +CONFIG_ENABLE_WIFI_STATION=y +CONFIG_ENABLE_WIFI_AP=n +# Enable this to avoid implicit declaration of function 'esp_send_assoc_resp' +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y + +# Enable OTA Requestor +CONFIG_ENABLE_OTA_REQUESTOR=y + +# Enable chip shell +CONFIG_ENABLE_CHIP_SHELL=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/energy-management-app/esp32/sdkconfig.defaults.esp32h2 b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32h2 new file mode 100644 index 00000000000000..11d5991c353b20 --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig.defaults.esp32h2 @@ -0,0 +1,81 @@ +CONFIG_IDF_TARGET="esp32h2" +CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2=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_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +# libsodium +CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# NIMBLE +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_BT_NIMBLE_EXT_ADV=n +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n + +# Enable OpenThread +CONFIG_OPENTHREAD_ENABLED=y +CONFIG_OPENTHREAD_SRP_CLIENT=y +CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n +CONFIG_OPENTHREAD_LOG_LEVEL_NOTE=y +CONFIG_OPENTHREAD_CLI=n +CONFIG_OPENTHREAD_DNS_CLIENT=y + +# Disable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=n + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" + +# LwIP config for OpenThread +CONFIG_LWIP_IPV6_NUM_ADDRESSES=8 +CONFIG_LWIP_MULTICAST_PING=y + +# mbedTLS +CONFIG_MBEDTLS_HARDWARE_AES=n +CONFIG_MBEDTLS_HARDWARE_MPI=n +CONFIG_MBEDTLS_HARDWARE_SHA=n +CONFIG_MBEDTLS_HARDWARE_ECC=y +CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN=n +CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY=n +CONFIG_MBEDTLS_CMAC_C=y +CONFIG_MBEDTLS_SSL_PROTO_DTLS=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y + +# rtc clk for ble +# CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y + +# MDNS platform +CONFIG_USE_MINIMAL_MDNS=n +CONFIG_ENABLE_EXTENDED_DISCOVERY=y + +# FreeRTOS should use legacy API +CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y + +# Disable STA and AP for ESP32H2 +CONFIG_ENABLE_WIFI_STATION=n +CONFIG_ENABLE_WIFI_AP=n +# Enable this to avoid implicit declaration of function 'esp_send_assoc_resp' +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y + +# Enable OTA Requestor +CONFIG_ENABLE_OTA_REQUESTOR=y + +# Enable chip shell +CONFIG_ENABLE_CHIP_SHELL=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/energy-management-app/esp32/sdkconfig.optimize.defaults b/examples/energy-management-app/esp32/sdkconfig.optimize.defaults new file mode 100644 index 00000000000000..78b876c81aa991 --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig.optimize.defaults @@ -0,0 +1,95 @@ +# +# Copyright (c) 2023 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: +# Some useful defaults for the demo app configuration. +# + +# 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 + +#disable BT connection reattempt +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +#enable debug shell +CONFIG_ENABLE_CHIP_SHELL=n + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +#enable lwIP route hooks +CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y +CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y + +# Compiler options new options-- +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +# Bluetooth controller +CONFIG_BTDM_CTRL_BLE_MAX_CONN=1 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=1 + +# NimBLE Options +CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 + +# Wi-Fi +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 + +# FreeRTOS +CONFIG_FREERTOS_UNICORE=y + +# Add RTC memory to system heap +CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y + +# LWIP +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 + +# TCP +CONFIG_LWIP_TCP_SYNMAXRTX=6 + +# Compatibility options +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=1 +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=1 +CONFIG_NIMBLE_MAX_CONNECTIONS=1 +CONFIG_TCPIP_RECVMBOX_SIZE=16 +CONFIG_TCP_SYNMAXRTX=6 + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y diff --git a/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults b/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults new file mode 100644 index 00000000000000..be4c85a9c4bb14 --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults @@ -0,0 +1,71 @@ +# +# Copyright (c) 2021-2023 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: +# Some useful defaults for the demo app configuration. +# +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 + +#disable BT connection reattempt +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +#enable debug shell +CONFIG_ENABLE_CHIP_SHELL=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +#enable lwIP route hooks +CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y +CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Main task needs a bit more stack than the default +# default is 3584, bump this up to 5k. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120 + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Disable softap support by default +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y + +# Optimize IRAM +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y + diff --git a/examples/energy-management-app/esp32/sdkconfig_rpc.defaults b/examples/energy-management-app/esp32/sdkconfig_rpc.defaults new file mode 100644 index 00000000000000..57ac2d6b027c56 --- /dev/null +++ b/examples/energy-management-app/esp32/sdkconfig_rpc.defaults @@ -0,0 +1,57 @@ +# +# 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. +# +# Description: +# CI uses this to select the ESP32C3-DevKitM. +# +# 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" + +#enable lwIP route hooks +CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y +CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# 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 + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y + +CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y diff --git a/examples/energy-management-app/esp32/third_party/connectedhomeip b/examples/energy-management-app/esp32/third_party/connectedhomeip new file mode 120000 index 00000000000000..11a54ed360106c --- /dev/null +++ b/examples/energy-management-app/esp32/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../../ \ No newline at end of file From ca381ed1d65226ce971842f949edf1a437d3c06f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 12 Dec 2023 07:18:24 +0000 Subject: [PATCH 2/5] Restyled by clang-format --- examples/energy-management-app/esp32/main/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/energy-management-app/esp32/main/main.cpp b/examples/energy-management-app/esp32/main/main.cpp index b4c523e2698374..3f8d60d37fbb2b 100644 --- a/examples/energy-management-app/esp32/main/main.cpp +++ b/examples/energy-management-app/esp32/main/main.cpp @@ -235,5 +235,4 @@ extern "C" void app_main() ESPOpenThreadInit(); chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); - } From 8223c71b6148d65242cc616e382888ec10357bbc Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 12 Dec 2023 07:18:39 +0000 Subject: [PATCH 3/5] Restyled by autopep8 --- .../energy-management-app/esp32/output.py | 105 ------------------ .../esp32/sdkconfig.optimize.defaults | 2 +- .../esp32/sdkconfig_m5stack.defaults | 2 +- 3 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 examples/energy-management-app/esp32/output.py diff --git a/examples/energy-management-app/esp32/output.py b/examples/energy-management-app/esp32/output.py deleted file mode 100644 index 566d6438540a1d..00000000000000 --- a/examples/energy-management-app/esp32/output.py +++ /dev/null @@ -1,105 +0,0 @@ -cluster_t *IdentifyCluster = esp_matter::cluster::create(endpoint, 3, CLUSTER_FLAG_SERVER); - set_plugin_server_init_callback(IdentifyCluster, MatterIdentifyPluginServerInitCallback); - add_function_list(IdentifyCluster, identify_function_list, CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION); - -attribute_t *identifyTimeAttribute = esp_matter::attribute::create(IdentifyCluster, 0, ATTRIBUTE_FLAG_WRITABLE,0); - esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(m ax)); -# min and max are mentioned in spec and also in esp_matter_cluster.cpp - -attribute_t *identifyTypeAttribute = esp_matter::attribute::create(IdentifyCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(IdentifyCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(IdentifyCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *eventListAttribute = esp_matter::attribute::create(IdentifyCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *attributeListAttribute = esp_matter::attribute::create(IdentifyCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *featureMapAttribute = esp_matter::attribute::create(IdentifyCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(IdentifyCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -command_t *IdentifyCommand = esp_matter::command::create(IdentifyCluster, 0, COMMAND_FLAGS, commandCallback); -command_t *TriggerEffectCommand = esp_matter::command::create(IdentifyCluster, 64, COMMAND_FLAGS, commandCallback); - -cluster_t *GroupsCluster = esp_matter::cluster::create(endpoint, 4, CLUSTER_FLAG_SERVER); - set_plugin_server_init_callback(cluster, MatterGroupsPluginServerInitCallback); - add_function_list(cluster, function_list, function_flags); - -attribute_t *nameSupportAttribute = esp_matter::attribute::create(GroupsCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(GroupsCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(GroupsCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *eventListAttribute = esp_matter::attribute::create(GroupsCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *attributeListAttribute = esp_matter::attribute::create(GroupsCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *featureMapAttribute = esp_matter::attribute::create(GroupsCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(GroupsCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -command_t *AddGroupCommand = esp_matter::command::create(GroupsCluster, 0, COMMAND_FLAGS, commandCallback); -command_t *ViewGroupCommand = esp_matter::command::create(GroupsCluster, 1, COMMAND_FLAGS, commandCallback); -command_t *GetGroupMembershipCommand = esp_matter::command::create(GroupsCluster, 2, COMMAND_FLAGS, commandCallback); -command_t *RemoveGroupCommand = esp_matter::command::create(GroupsCluster, 3, COMMAND_FLAGS, commandCallback); -command_t *RemoveAllGroupsCommand = esp_matter::command::create(GroupsCluster, 4, COMMAND_FLAGS, commandCallback); -command_t *AddGroupIfIdentifyingCommand = esp_matter::command::create(GroupsCluster, 5, COMMAND_FLAGS, commandCallback); - -cluster_t *ScenesCluster = esp_matter::cluster::create(endpoint, 5, CLUSTER_FLAG_SERVER); - set_plugin_server_init_callback(cluster, MatterScenesPluginServerInitCallback); - add_function_list(cluster, NULL, CLUSTER_FLAG_NONE); - -attribute_t *sceneCountAttribute = esp_matter::attribute::create(ScenesCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *currentSceneAttribute = esp_matter::attribute::create(ScenesCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *currentGroupAttribute = esp_matter::attribute::create(ScenesCluster, 2, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *sceneValidAttribute = esp_matter::attribute::create(ScenesCluster, 3, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *nameSupportAttribute = esp_matter::attribute::create(ScenesCluster, 4, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *lastConfiguredByAttribute = esp_matter::attribute::create(ScenesCluster, 5, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *sceneTableSizeAttribute = esp_matter::attribute::create(ScenesCluster, 6, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *remainingCapacityAttribute = esp_matter::attribute::create(ScenesCluster, 7, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(ScenesCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(ScenesCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *eventListAttribute = esp_matter::attribute::create(ScenesCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *attributeListAttribute = esp_matter::attribute::create(ScenesCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *featureMapAttribute = esp_matter::attribute::create(ScenesCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(ScenesCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -command_t *AddSceneCommand = esp_matter::command::create(ScenesCluster, 0, COMMAND_FLAGS, commandCallback); -command_t *ViewSceneCommand = esp_matter::command::create(ScenesCluster, 1, COMMAND_FLAGS, commandCallback); -command_t *RemoveSceneCommand = esp_matter::command::create(ScenesCluster, 2, COMMAND_FLAGS, commandCallback); -command_t *RemoveAllScenesCommand = esp_matter::command::create(ScenesCluster, 3, COMMAND_FLAGS, commandCallback); -command_t *StoreSceneCommand = esp_matter::command::create(ScenesCluster, 4, COMMAND_FLAGS, commandCallback); -command_t *RecallSceneCommand = esp_matter::command::create(ScenesCluster, 5, COMMAND_FLAGS, commandCallback); -command_t *GetSceneMembershipCommand = esp_matter::command::create(ScenesCluster, 6, COMMAND_FLAGS, commandCallback); -command_t *EnhancedAddSceneCommand = esp_matter::command::create(ScenesCluster, 64, COMMAND_FLAGS, commandCallback); -command_t *EnhancedViewSceneCommand = esp_matter::command::create(ScenesCluster, 65, COMMAND_FLAGS, commandCallback); -command_t *CopySceneCommand = esp_matter::command::create(ScenesCluster, 66, COMMAND_FLAGS, commandCallback); - -cluster_t *OnOffCluster = esp_matter::cluster::create(endpoint, 6, CLUSTER_FLAG_SERVER); -attribute_t *onOffAttribute = esp_matter::attribute::create(OnOffCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); - set_plugin_server_init_callback(cluster, MatterOnOffPluginServerInitCallback); - add_function_list(cluster, on_off_function_list, CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FUNCTION); - - -attribute_t *globalSceneControlAttribute = esp_matter::attribute::create(OnOffCluster, 16384, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *onTimeAttribute = esp_matter::attribute::create(OnOffCluster, 16385, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *offWaitTimeAttribute = esp_matter::attribute::create(OnOffCluster, 16386, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *startUpOnOffAttribute = esp_matter::attribute::create(OnOffCluster, 16387, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(OnOffCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(OnOffCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *eventListAttribute = esp_matter::attribute::create(OnOffCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *attributeListAttribute = esp_matter::attribute::create(OnOffCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *featureMapAttribute = esp_matter::attribute::create(OnOffCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(OnOffCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -command_t *OffCommand = esp_matter::command::create(OnOffCluster, 0, COMMAND_FLAGS, commandCallback); -command_t *OnCommand = esp_matter::command::create(OnOffCluster, 1, COMMAND_FLAGS, commandCallback); -command_t *ToggleCommand = esp_matter::command::create(OnOffCluster, 2, COMMAND_FLAGS, commandCallback); -command_t *OffWithEffectCommand = esp_matter::command::create(OnOffCluster, 64, COMMAND_FLAGS, commandCallback); -command_t *OnWithRecallGlobalSceneCommand = esp_matter::command::create(OnOffCluster, 65, COMMAND_FLAGS, commandCallback); -command_t *OnWithTimedOffCommand = esp_matter::command::create(OnOffCluster, 66, COMMAND_FLAGS, commandCallback); - - -cluster_t *DescriptorCluster = esp_matter::cluster::create(endpoint, 29, CLUSTER_FLAG_SERVER); - set_plugin_server_init_callback(cluster, MatterDescriptorPluginServerInitCallback); - add_function_list(cluster, NULL, CLUSTER_FLAG_NONE); - -attribute_t *deviceTypeListAttribute = esp_matter::attribute::create(DescriptorCluster, 0, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *serverListAttribute = esp_matter::attribute::create(DescriptorCluster, 1, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clientListAttribute = esp_matter::attribute::create(DescriptorCluster, 2, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *partsListAttribute = esp_matter::attribute::create(DescriptorCluster, 3, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *generatedCommandListAttribute = esp_matter::attribute::create(DescriptorCluster, 65528, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *acceptedCommandListAttribute = esp_matter::attribute::create(DescriptorCluster, 65529, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *eventListAttribute = esp_matter::attribute::create(DescriptorCluster, 65530, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *attributeListAttribute = esp_matter::attribute::create(DescriptorCluster, 65531, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *featureMapAttribute = esp_matter::attribute::create(DescriptorCluster, 65532, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -attribute_t *clusterRevisionAttribute = esp_matter::attribute::create(DescriptorCluster, 65533, ATTRIBUTE_FLAGS, DEFAULT_VALUE); -endpoint_t *endpoint = esp_matter::endpoint::create(node, 1, ENDPOINT_FLAGS, priv_data); - diff --git a/examples/energy-management-app/esp32/sdkconfig.optimize.defaults b/examples/energy-management-app/esp32/sdkconfig.optimize.defaults index 78b876c81aa991..87248eebfcdfa7 100644 --- a/examples/energy-management-app/esp32/sdkconfig.optimize.defaults +++ b/examples/energy-management-app/esp32/sdkconfig.optimize.defaults @@ -53,7 +53,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n # This example uses the older version of RMT driver to work with both -# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +# idf-v4.4.3 and idf-v5.0, so suppressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y # Compiler options new options-- diff --git a/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults b/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults index be4c85a9c4bb14..990b77a2adac35 100644 --- a/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/energy-management-app/esp32/sdkconfig_m5stack.defaults @@ -60,7 +60,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n # This example uses the older version of RMT driver to work with both -# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +# idf-v4.4.3 and idf-v5.0, so suppressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y # Enable HKDF in mbedtls From fbcb26aca07c2b4861df30059e2aafcd37f393ea Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Wed, 20 Dec 2023 14:55:15 +0530 Subject: [PATCH 4/5] spelcheck --- examples/energy-management-app/esp32/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/energy-management-app/esp32/README.md b/examples/energy-management-app/esp32/README.md index 77335382afbcb9..75890a491b5fdb 100644 --- a/examples/energy-management-app/esp32/README.md +++ b/examples/energy-management-app/esp32/README.md @@ -1,6 +1,7 @@ # Matter ESP32 Energy Management Example -This example demonstrates the Matter EVSE application on ESP platforms. +This example demonstrates the Matter Electric Vehicle Supply Equipment +application on ESP platforms. Please [setup ESP-IDF and CHIP Environment](../../../docs/guides/esp32/setup_idf_chip.md) From 6c1e966d839e4c9a0003b49c3c1e10e4f197a7e7 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 26 Dec 2023 12:24:42 +0530 Subject: [PATCH 5/5] Address review comments --- .../energy-management-app/esp32/README.md | 20 ++++++++----------- .../energy-management-app/esp32/main/main.cpp | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/examples/energy-management-app/esp32/README.md b/examples/energy-management-app/esp32/README.md index 75890a491b5fdb..c2fb2bc7a1f63c 100644 --- a/examples/energy-management-app/esp32/README.md +++ b/examples/energy-management-app/esp32/README.md @@ -37,17 +37,13 @@ cp /path/to/auth/key.txt path/to/connectedhomeip/examples/energy-management-app/ ### Cluster Control -- After successful commissioning, use the OnOff cluster command to control the - OnOff attribute. This allows you to toggle a parameter implemented by the - device to be On or Off. +- After successful commissioning, use the Energy Electric Vehicle Supply + Equipment cluster command to disable/enable charging and discharging. - $ ./out/debug/chip-tool onoff on 1 - -- On - [ESP32C3-DevKitM](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html) - or - [ESP32S3-DevKitM](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitm-1.html) - board, there is an on-board RGB-LED. Use ColorControl cluster command to - control the color attributes: +``` + $./out/debug/chip-tool energyevse disable 1 +``` - $ ./out/debug/chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 1 +``` + $ ./out/debug/chip-tool energyevse enable-charging 0xFFFFFFFF 6000 32000 1 --timedInteractionTimeoutMs