From 40306326e3bb40afadf648ddb880d20961438c37 Mon Sep 17 00:00:00 2001 From: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Date: Sat, 11 Mar 2023 01:09:00 +0800 Subject: [PATCH] ESP32: fix compile errors related to screen framwork (#25588) * ESP32: fix compile errors related to screen framwork * Restyled by clang-format * fix errors in all-clusters-minimal-app and use ESP32-H2-MP now --------- Co-authored-by: Restyled.io --- config/esp32/components/chip/CMakeLists.txt | 4 +- .../esp32/components/chip/idf_component.yml | 1 + docs/guides/esp32/setup_idf_chip.md | 17 ++----- .../all-clusters-app/esp32/main/AppTask.cpp | 2 + .../esp32/main/BluetoothWidget.cpp | 5 ++- .../all-clusters-app/esp32/main/Button.cpp | 1 - .../esp32/main/CMakeLists.txt | 15 ++----- .../esp32/main/Kconfig.projbuild | 5 +++ .../all-clusters-app/esp32/main/LEDWidget.cpp | 4 +- .../esp32/main/WiFiWidget.cpp | 5 ++- .../esp32/main/include/BluetoothWidget.h | 2 - .../esp32/main/include/DeviceWithDisplay.h | 9 ++-- .../esp32/main/include/LEDWidget.h | 2 - .../esp32/main/include/QRCodeScreen.h | 4 +- .../esp32/main/include/StatusScreen.h | 5 ++- .../esp32/main/include/WiFiWidget.h | 2 - .../esp32/main/AppTask.cpp | 2 + .../esp32/main/BluetoothWidget.cpp | 5 ++- .../esp32/main/Button.cpp | 2 + .../esp32/main/CMakeLists.txt | 25 ++++------- .../esp32/main/Kconfig.projbuild | 5 +++ .../esp32/main/LEDWidget.cpp | 4 +- .../esp32/main/WiFiWidget.cpp | 6 +-- .../esp32/main/include/BluetoothWidget.h | 2 - .../esp32/main/include/DeviceWithDisplay.h | 4 +- .../esp32/main/include/LEDWidget.h | 2 - .../esp32/main/include/QRCodeScreen.h | 5 ++- .../esp32/main/include/StatusScreen.h | 5 ++- .../esp32/main/include/WiFiWidget.h | 2 - examples/chef/esp32/main/Kconfig.projbuild | 5 +++ .../common/screen-framework/include/Display.h | 15 +------ examples/lighting-app/esp32/main/Button.cpp | 2 + .../lighting-app/esp32/main/CMakeLists.txt | 2 +- .../esp32/main/DeviceWithDisplay.h | 10 ++--- .../lighting-app/esp32/main/Kconfig.projbuild | 16 +++++-- .../lighting-app/esp32/main/LEDWidget.cpp | 2 + .../lighting-app/esp32/main/WiFiWidget.cpp | 6 +-- .../esp32/main/include/QRCodeScreen.h | 5 ++- .../esp32/main/include/StatusScreen.h | 5 ++- .../esp32/main/include/WiFiWidget.h | 2 - .../esp32/sdkconfig.defaults.esp32h2 | 6 +++ src/platform/ESP32/CHIPDevicePlatformConfig.h | 2 +- src/platform/ESP32/ESP32Utils.cpp | 45 ++++++++++--------- 43 files changed, 139 insertions(+), 136 deletions(-) diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index a878b95ee3f5b8..00696281ad64c0 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -292,9 +292,7 @@ if(CONFIG_BT_ENABLED) if("${CONFIG_IDF_TARGET}" STREQUAL "esp32h2") idf_component_get_property(bt_dir bt COMPONENT_DIR) list(APPEND chip_libraries $) - if(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2) - list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32h2/esp32h2-bt-lib/beta2/libble_app.a) - endif() + list(APPEND chip_libraries ${bt_dir}/controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a) elseif("${CONFIG_IDF_TARGET}" STREQUAL "esp32c2") idf_component_get_property(bt_dir bt COMPONENT_DIR) list(APPEND chip_libraries $) diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml index e47917975ce13d..7ffcad18792541 100644 --- a/config/esp32/components/chip/idf_component.yml +++ b/config/esp32/components/chip/idf_component.yml @@ -4,3 +4,4 @@ dependencies: version: "^1.0.3" rules: - if: "idf_version >=5.0" + - if: "target != esp32h2" diff --git a/docs/guides/esp32/setup_idf_chip.md b/docs/guides/esp32/setup_idf_chip.md index 63303c79a5dfca..bd30222934dcb4 100644 --- a/docs/guides/esp32/setup_idf_chip.md +++ b/docs/guides/esp32/setup_idf_chip.md @@ -39,23 +39,12 @@ step. $ ./install.sh ``` -- For ESP32H2, please checkout tag - [v5.0](https://github.com/espressif/esp-idf/tree/v5.0), currently only - lighting-app is supported on H2 +- For ESP32C6 & ESP32H2, please use commit + [47852846d3](https://github.com/espressif/esp-idf/tree/47852846d3). ``` $ cd esp-idf - $ git checkout v5.0-beta1 - $ git submodule update --init - $ ./install.sh - ``` - -- For ESP32C6, please use commit - [afbdb0f3e](https://github.com/espressif/esp-idf/tree/afbdb0f3e). - - ``` - $ cd esp-idf - $ git checkout afbdb0f3e + $ git checkout 47852846d3 $ git submodule update --init $ ./install.sh ``` diff --git a/examples/all-clusters-app/esp32/main/AppTask.cpp b/examples/all-clusters-app/esp32/main/AppTask.cpp index 836e4d8b2b7f02..0b63316c2d53ac 100644 --- a/examples/all-clusters-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-app/esp32/main/AppTask.cpp @@ -21,7 +21,9 @@ #include "DeviceWithDisplay.h" #include "Globals.h" #include "LEDWidget.h" +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" +#endif #include "driver/gpio.h" #include "esp_idf_version.h" #include "esp_log.h" diff --git a/examples/all-clusters-app/esp32/main/BluetoothWidget.cpp b/examples/all-clusters-app/esp32/main/BluetoothWidget.cpp index 4f8a011254bed0..452fb4ff85bb6f 100644 --- a/examples/all-clusters-app/esp32/main/BluetoothWidget.cpp +++ b/examples/all-clusters-app/esp32/main/BluetoothWidget.cpp @@ -23,12 +23,13 @@ * connection on display. */ -#include "ScreenManager.h" - #include "BluetoothWidget.h" #include "esp_log.h" #include "esp_system.h" +#if CONFIG_HAVE_DISPLAY +#include "ScreenManager.h" +#endif extern const char * TAG; diff --git a/examples/all-clusters-app/esp32/main/Button.cpp b/examples/all-clusters-app/esp32/main/Button.cpp index 5708f196b14944..a1930290f6ebad 100644 --- a/examples/all-clusters-app/esp32/main/Button.cpp +++ b/examples/all-clusters-app/esp32/main/Button.cpp @@ -31,7 +31,6 @@ #include "AppTask.h" #include "Button.h" #include "Globals.h" -#include "ScreenManager.h" #include #include #include diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 02d6693e20fecf..144dbd4892af33 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -108,22 +108,15 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C6_DEVKITC}" STREQUAL "y")) - list(APPEND PRIV_INCLUDE_DIRS_LIST - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") - set(PRIV_REQUIRES_LIST chip QRCode bt) -elseif(("${CONFIG_DEVICE_TYPE_M5STACK}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT}" STREQUAL "y")) - set(PRIV_REQUIRES_LIST chip QRCode bt tft spidrier screen-framework) +set(PRIV_REQUIRES_LIST chip QRCode bt driver app_update nvs_flash spi_flash openthread) +if(CONFIG_HAVE_DISPLAY) + list(APPEND PRIV_REQUIRES_LIST tft spidrier screen-framework) endif() -if("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") +if(CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM) list(APPEND PRIV_REQUIRES_LIST led_strip) endif() -if (CONFIG_OPENTHREAD_ENABLED) - list(APPEND PRIV_REQUIRES_LIST openthread) -endif() - idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} SRC_DIRS ${SRC_DIRS_LIST} EXCLUDE_SRCS ${EXCLUDE_SRCS_LIST} diff --git a/examples/all-clusters-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-app/esp32/main/Kconfig.projbuild index 8ed41e03971ef3..fb2eb7d6c3b46f 100644 --- a/examples/all-clusters-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-app/esp32/main/Kconfig.projbuild @@ -89,6 +89,11 @@ menu "Demo" 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 diff --git a/examples/all-clusters-app/esp32/main/LEDWidget.cpp b/examples/all-clusters-app/esp32/main/LEDWidget.cpp index 4a95c13b09a46e..9927e490c0d3d4 100644 --- a/examples/all-clusters-app/esp32/main/LEDWidget.cpp +++ b/examples/all-clusters-app/esp32/main/LEDWidget.cpp @@ -24,9 +24,9 @@ */ #include "LEDWidget.h" - +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" - +#endif #include "esp_log.h" #include "esp_system.h" #include "esp_timer.h" diff --git a/examples/all-clusters-app/esp32/main/WiFiWidget.cpp b/examples/all-clusters-app/esp32/main/WiFiWidget.cpp index 07fa20d9186fe0..06a47a6f8532c7 100644 --- a/examples/all-clusters-app/esp32/main/WiFiWidget.cpp +++ b/examples/all-clusters-app/esp32/main/WiFiWidget.cpp @@ -23,12 +23,13 @@ * connection on display. */ -#include "ScreenManager.h" - #include "WiFiWidget.h" #include "esp_log.h" #include "esp_system.h" +#if CONFIG_HAVE_DISPLAY +#include "ScreenManager.h" +#endif extern const char * TAG; diff --git a/examples/all-clusters-app/esp32/main/include/BluetoothWidget.h b/examples/all-clusters-app/esp32/main/include/BluetoothWidget.h index 93b636e9b3c083..6bda359f2b755a 100644 --- a/examples/all-clusters-app/esp32/main/include/BluetoothWidget.h +++ b/examples/all-clusters-app/esp32/main/include/BluetoothWidget.h @@ -18,8 +18,6 @@ #pragma once -#include "Display.h" - #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h b/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h index 3dc7b57f2af3fb..f86bce6c870307 100644 --- a/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h +++ b/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h @@ -20,11 +20,8 @@ #include "Button.h" #include "DeviceCallbacks.h" -#include "Display.h" #include "Globals.h" -#include "ListScreen.h" #include "QRCodeScreen.h" -#include "ScreenManager.h" #include "StatusScreen.h" #include "esp_check.h" #include "esp_log.h" @@ -40,6 +37,12 @@ #include #include +#if CONFIG_HAVE_DISPLAY +#include "Display.h" +#include "ListScreen.h" +#include "ScreenManager.h" +#endif + #if CONFIG_DEVICE_TYPE_M5STACK #define BUTTON_1_GPIO_NUM ((gpio_num_t) 39) // Left button on M5Stack #define BUTTON_2_GPIO_NUM ((gpio_num_t) 38) // Middle button on M5Stack diff --git a/examples/all-clusters-app/esp32/main/include/LEDWidget.h b/examples/all-clusters-app/esp32/main/include/LEDWidget.h index 195e44196e2fa7..93e38d4001acc8 100644 --- a/examples/all-clusters-app/esp32/main/include/LEDWidget.h +++ b/examples/all-clusters-app/esp32/main/include/LEDWidget.h @@ -19,8 +19,6 @@ #pragma once -#include "Display.h" - #include "driver/gpio.h" #include "freertos/FreeRTOS.h" diff --git a/examples/all-clusters-app/esp32/main/include/QRCodeScreen.h b/examples/all-clusters-app/esp32/main/include/QRCodeScreen.h index e24fcd86d81e1a..ced5be2ac3a670 100644 --- a/examples/all-clusters-app/esp32/main/include/QRCodeScreen.h +++ b/examples/all-clusters-app/esp32/main/include/QRCodeScreen.h @@ -25,11 +25,11 @@ #pragma once +#include "sdkconfig.h" +#if CONFIG_HAVE_DISPLAY #include "Screen.h" #include "ScreenManager.h" -#if CONFIG_HAVE_DISPLAY - #include #include diff --git a/examples/all-clusters-app/esp32/main/include/StatusScreen.h b/examples/all-clusters-app/esp32/main/include/StatusScreen.h index 621604804aa923..1a72080f8e67ad 100644 --- a/examples/all-clusters-app/esp32/main/include/StatusScreen.h +++ b/examples/all-clusters-app/esp32/main/include/StatusScreen.h @@ -25,10 +25,11 @@ #pragma once -#include "ListScreen.h" -#include "ScreenManager.h" +#include #if CONFIG_HAVE_DISPLAY +#include "ListScreen.h" +#include "ScreenManager.h" #include #include diff --git a/examples/all-clusters-app/esp32/main/include/WiFiWidget.h b/examples/all-clusters-app/esp32/main/include/WiFiWidget.h index 986ab48b63ad4b..5069a2ae5b0f95 100644 --- a/examples/all-clusters-app/esp32/main/include/WiFiWidget.h +++ b/examples/all-clusters-app/esp32/main/include/WiFiWidget.h @@ -18,8 +18,6 @@ #pragma once -#include "Display.h" - #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp index 82a8f9757b590d..27c77c94ff90a4 100644 --- a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp @@ -21,7 +21,9 @@ #include "DeviceWithDisplay.h" #include "Globals.h" #include "LEDWidget.h" +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" +#endif #include "driver/gpio.h" #include "esp_idf_version.h" #include "esp_log.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/BluetoothWidget.cpp b/examples/all-clusters-minimal-app/esp32/main/BluetoothWidget.cpp index 4f8a011254bed0..452fb4ff85bb6f 100644 --- a/examples/all-clusters-minimal-app/esp32/main/BluetoothWidget.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/BluetoothWidget.cpp @@ -23,12 +23,13 @@ * connection on display. */ -#include "ScreenManager.h" - #include "BluetoothWidget.h" #include "esp_log.h" #include "esp_system.h" +#if CONFIG_HAVE_DISPLAY +#include "ScreenManager.h" +#endif extern const char * TAG; diff --git a/examples/all-clusters-minimal-app/esp32/main/Button.cpp b/examples/all-clusters-minimal-app/esp32/main/Button.cpp index 5708f196b14944..dd25966503ba80 100644 --- a/examples/all-clusters-minimal-app/esp32/main/Button.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/Button.cpp @@ -31,7 +31,9 @@ #include "AppTask.h" #include "Button.h" #include "Globals.h" +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" +#endif #include #include #include diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index 678d19d1940252..e2ed8315f4223f 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -38,9 +38,9 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/test-cluster-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fan-control-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fan-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/level-control" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" @@ -65,7 +65,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/target-navigator-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thermostat-user-interface-configuration-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" @@ -80,8 +80,8 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-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/wifi-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wake-on-lan-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wake-on-lan-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-server" @@ -105,22 +105,15 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y")) - list(APPEND PRIV_INCLUDE_DIRS_LIST - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") - set(PRIV_REQUIRES_LIST chip QRCode bt) -elseif(("${CONFIG_DEVICE_TYPE_M5STACK}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT}" STREQUAL "y")) - set(PRIV_REQUIRES_LIST chip QRCode bt tft spidrier screen-framework) +set(PRIV_REQUIRES_LIST chip QRCode bt driver app_update nvs_flash spi_flash openthread) +if(CONFIG_HAVE_DISPLAY) + list(APPEND PRIV_REQUIRES_LIST tft spidrier screen-framework) endif() -if("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") +if(CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM) list(APPEND PRIV_REQUIRES_LIST led_strip) endif() -if (CONFIG_OPENTHREAD_ENABLED) - list(APPEND PRIV_REQUIRES_LIST openthread) -endif() - idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} SRC_DIRS ${SRC_DIRS_LIST} PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) diff --git a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild index 9b5bff48d90a1e..171af4f0ba2c24 100644 --- a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild @@ -81,6 +81,11 @@ menu "Demo" 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 diff --git a/examples/all-clusters-minimal-app/esp32/main/LEDWidget.cpp b/examples/all-clusters-minimal-app/esp32/main/LEDWidget.cpp index 13dcdc4893c2cf..3163afb5a59a05 100644 --- a/examples/all-clusters-minimal-app/esp32/main/LEDWidget.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/LEDWidget.cpp @@ -24,9 +24,9 @@ */ #include "LEDWidget.h" - +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" - +#endif #include "esp_log.h" #include "esp_system.h" #include "esp_timer.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/WiFiWidget.cpp b/examples/all-clusters-minimal-app/esp32/main/WiFiWidget.cpp index 07fa20d9186fe0..cafc40cbfabf19 100644 --- a/examples/all-clusters-minimal-app/esp32/main/WiFiWidget.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/WiFiWidget.cpp @@ -23,13 +23,13 @@ * connection on display. */ -#include "ScreenManager.h" - #include "WiFiWidget.h" #include "esp_log.h" #include "esp_system.h" - +#if CONFIG_HAVE_DISPLAY +#include "ScreenManager.h" +#endif extern const char * TAG; void WiFiWidget::Init() diff --git a/examples/all-clusters-minimal-app/esp32/main/include/BluetoothWidget.h b/examples/all-clusters-minimal-app/esp32/main/include/BluetoothWidget.h index 93b636e9b3c083..6bda359f2b755a 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/BluetoothWidget.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/BluetoothWidget.h @@ -18,8 +18,6 @@ #pragma once -#include "Display.h" - #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h b/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h index 3dc7b57f2af3fb..b9f89e15ee8792 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h @@ -20,12 +20,14 @@ #include "Button.h" #include "DeviceCallbacks.h" -#include "Display.h" #include "Globals.h" +#if CONFIG_HAVE_DISPLAY +#include "Display.h" #include "ListScreen.h" #include "QRCodeScreen.h" #include "ScreenManager.h" #include "StatusScreen.h" +#endif #include "esp_check.h" #include "esp_log.h" #include "esp_system.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/include/LEDWidget.h b/examples/all-clusters-minimal-app/esp32/main/include/LEDWidget.h index 8ce4323329854d..a356667da7a489 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/LEDWidget.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/LEDWidget.h @@ -19,8 +19,6 @@ #pragma once -#include "Display.h" - #include "driver/gpio.h" #include "freertos/FreeRTOS.h" diff --git a/examples/all-clusters-minimal-app/esp32/main/include/QRCodeScreen.h b/examples/all-clusters-minimal-app/esp32/main/include/QRCodeScreen.h index e24fcd86d81e1a..da0ca8de53fe20 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/QRCodeScreen.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/QRCodeScreen.h @@ -25,10 +25,11 @@ #pragma once -#include "Screen.h" -#include "ScreenManager.h" +#include #if CONFIG_HAVE_DISPLAY +#include "Screen.h" +#include "ScreenManager.h" #include #include diff --git a/examples/all-clusters-minimal-app/esp32/main/include/StatusScreen.h b/examples/all-clusters-minimal-app/esp32/main/include/StatusScreen.h index 621604804aa923..d1f4d9e52a449d 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/StatusScreen.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/StatusScreen.h @@ -25,10 +25,11 @@ #pragma once -#include "ListScreen.h" -#include "ScreenManager.h" +#include "sdkconfig.h" #if CONFIG_HAVE_DISPLAY +#include "ListScreen.h" +#include "ScreenManager.h" #include #include diff --git a/examples/all-clusters-minimal-app/esp32/main/include/WiFiWidget.h b/examples/all-clusters-minimal-app/esp32/main/include/WiFiWidget.h index 986ab48b63ad4b..5069a2ae5b0f95 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/WiFiWidget.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/WiFiWidget.h @@ -18,8 +18,6 @@ #pragma once -#include "Display.h" - #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/chef/esp32/main/Kconfig.projbuild b/examples/chef/esp32/main/Kconfig.projbuild index a2b3ea3ce1c34c..1be798e990cb7a 100644 --- a/examples/chef/esp32/main/Kconfig.projbuild +++ b/examples/chef/esp32/main/Kconfig.projbuild @@ -79,6 +79,11 @@ menu "Demo" 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 diff --git a/examples/common/screen-framework/include/Display.h b/examples/common/screen-framework/include/Display.h index 13fbabd5de6355..691d6ed2c77074 100644 --- a/examples/common/screen-framework/include/Display.h +++ b/examples/common/screen-framework/include/Display.h @@ -28,25 +28,14 @@ #include "esp_system.h" -#if CONFIG_DEVICE_TYPE_M5STACK +#if CONFIG_HAVE_DISPLAY -#define CONFIG_HAVE_DISPLAY 1 -// for some reason this is backwards (turns out this is because of a 2019 update to the m5stack hw) +#if CONFIG_DEVICE_TYPE_M5STACK #define INVERT_DISPLAY INVERT_ON - #elif CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT - -#define CONFIG_HAVE_DISPLAY 1 #define INVERT_DISPLAY INVERT_OFF - -#else - -#define CONFIG_HAVE_DISPLAY 0 - #endif -#if CONFIG_HAVE_DISPLAY - extern "C" { #include "tft.h" #include "tftspi.h" diff --git a/examples/lighting-app/esp32/main/Button.cpp b/examples/lighting-app/esp32/main/Button.cpp index ea4959ff6188cb..639b90befa8055 100644 --- a/examples/lighting-app/esp32/main/Button.cpp +++ b/examples/lighting-app/esp32/main/Button.cpp @@ -23,7 +23,9 @@ #include "AppTask.h" #include "Button.h" #include "Globals.h" +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" +#endif #include #include #include diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index fcedfb4774637e..9a7f8c26a16a34 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -85,7 +85,7 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if ("${CONFIG_DEVICE_TYPE_M5STACK}" STREQUAL "y") +if (CONFIG_HAVE_DISPLAY) list(APPEND PRIV_REQUIRES_LIST tft screen-framework) endif() diff --git a/examples/lighting-app/esp32/main/DeviceWithDisplay.h b/examples/lighting-app/esp32/main/DeviceWithDisplay.h index 82feb8dbf841b6..a52a50f79816c0 100644 --- a/examples/lighting-app/esp32/main/DeviceWithDisplay.h +++ b/examples/lighting-app/esp32/main/DeviceWithDisplay.h @@ -20,11 +20,6 @@ #include "Button.h" #include "DeviceCallbacks.h" -#include "Display.h" -#include "ListScreen.h" -#include "QRCodeScreen.h" -#include "ScreenManager.h" -#include "StatusScreen.h" #include "esp_check.h" #include "esp_log.h" #include "esp_system.h" @@ -34,6 +29,11 @@ #include #if CONFIG_HAVE_DISPLAY +#include "Display.h" +#include "ListScreen.h" +#include "QRCodeScreen.h" +#include "ScreenManager.h" +#include "StatusScreen.h" #include #include diff --git a/examples/lighting-app/esp32/main/Kconfig.projbuild b/examples/lighting-app/esp32/main/Kconfig.projbuild index 5f3c88166c6dda..dcf4f825fc5c9a 100644 --- a/examples/lighting-app/esp32/main/Kconfig.projbuild +++ b/examples/lighting-app/esp32/main/Kconfig.projbuild @@ -26,6 +26,8 @@ menu "Demo" 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. @@ -53,11 +55,14 @@ menu "Demo" 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 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 + 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 @@ -83,7 +88,7 @@ menu "Demo" 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 + 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 @@ -113,10 +118,15 @@ menu "Demo" int range 0 5 default 0 if DEVICE_TYPE_ESP32_DEVKITC - default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM + 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 diff --git a/examples/lighting-app/esp32/main/LEDWidget.cpp b/examples/lighting-app/esp32/main/LEDWidget.cpp index 246b0cec8d2b2d..ffac77546d069f 100644 --- a/examples/lighting-app/esp32/main/LEDWidget.cpp +++ b/examples/lighting-app/esp32/main/LEDWidget.cpp @@ -17,7 +17,9 @@ #include "LEDWidget.h" #include "ColorFormat.h" +#if CONFIG_HAVE_DISPLAY #include "ScreenManager.h" +#endif #include "led_strip.h" static const char * TAG = "LEDWidget"; diff --git a/examples/lighting-app/esp32/main/WiFiWidget.cpp b/examples/lighting-app/esp32/main/WiFiWidget.cpp index 4062cc68e237c7..676dc172a5e28b 100644 --- a/examples/lighting-app/esp32/main/WiFiWidget.cpp +++ b/examples/lighting-app/esp32/main/WiFiWidget.cpp @@ -23,13 +23,13 @@ * connection on display. */ -#include "ScreenManager.h" - #include "WiFiWidget.h" #include "esp_log.h" #include "esp_system.h" - +#if CONFIG_HAVE_DISPLAY +#include "ScreenManager.h" +#endif void WiFiWidget::Init() { #if CONFIG_HAVE_DISPLAY diff --git a/examples/lighting-app/esp32/main/include/QRCodeScreen.h b/examples/lighting-app/esp32/main/include/QRCodeScreen.h index f82ad33d8e35b2..3479c7d0256103 100644 --- a/examples/lighting-app/esp32/main/include/QRCodeScreen.h +++ b/examples/lighting-app/esp32/main/include/QRCodeScreen.h @@ -18,10 +18,11 @@ #pragma once -#include "Screen.h" -#include "ScreenManager.h" +#include "sdkconfig.h" #if CONFIG_HAVE_DISPLAY +#include "Screen.h" +#include "ScreenManager.h" #include #include diff --git a/examples/lighting-app/esp32/main/include/StatusScreen.h b/examples/lighting-app/esp32/main/include/StatusScreen.h index 3aa537ebf0b9ba..7ade3b7b7f6dc9 100644 --- a/examples/lighting-app/esp32/main/include/StatusScreen.h +++ b/examples/lighting-app/esp32/main/include/StatusScreen.h @@ -18,10 +18,11 @@ #pragma once -#include "ListScreen.h" -#include "ScreenManager.h" +#include "sdkconfig.h" #if CONFIG_HAVE_DISPLAY +#include "ListScreen.h" +#include "ScreenManager.h" #include #include diff --git a/examples/lighting-app/esp32/main/include/WiFiWidget.h b/examples/lighting-app/esp32/main/include/WiFiWidget.h index cbc128c5ddfca9..d673e5c25433f9 100644 --- a/examples/lighting-app/esp32/main/include/WiFiWidget.h +++ b/examples/lighting-app/esp32/main/include/WiFiWidget.h @@ -18,8 +18,6 @@ #pragma once -#include "Display.h" - #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 b/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 index 57c480716e0abd..55eaa132157df1 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 +++ b/examples/lighting-app/esp32/sdkconfig.defaults.esp32h2 @@ -25,6 +25,10 @@ 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 @@ -61,6 +65,8 @@ 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 diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 67f033a6391b27..7f2e4a9dd11d09 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -49,7 +49,7 @@ #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_OPENTHREAD_ENABLED #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT -#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CONFIG_OPENTHREAD_DNS_CLIENT #if CONFIG_ENABLE_ETHERNET_TELEMETRY #define CHIP_DEVICE_CONFIG_ENABLE_WIFI 0 diff --git a/src/platform/ESP32/ESP32Utils.cpp b/src/platform/ESP32/ESP32Utils.cpp index 2b22f8ffa9fed7..4a03d08282dcda 100644 --- a/src/platform/ESP32/ESP32Utils.cpp +++ b/src/platform/ESP32/ESP32Utils.cpp @@ -37,7 +37,7 @@ using namespace ::chip::DeviceLayer::Internal; using chip::DeviceLayer::Internal::DeviceNetworkInfo; - +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR ESP32Utils::IsAPEnabled(bool & apEnabled) { #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP @@ -226,27 +226,6 @@ struct netif * ESP32Utils::GetStationNetif(void) return GetNetif("WIFI_STA_DEF"); } -struct netif * ESP32Utils::GetNetif(const char * ifKey) -{ - struct netif * netif = NULL; - esp_netif_t * netif_handle = NULL; - netif_handle = esp_netif_get_handle_from_ifkey(ifKey); - netif = (struct netif *) esp_netif_get_netif_impl(netif_handle); - return netif; -} - -bool ESP32Utils::IsInterfaceUp(const char * ifKey) -{ - struct netif * netif = GetNetif(ifKey); - return netif != NULL && netif_is_up(netif); -} - -bool ESP32Utils::HasIPv6LinkLocalAddress(const char * ifKey) -{ - struct esp_ip6_addr if_ip6_unused; - return esp_netif_get_ip6_linklocal(esp_netif_get_handle_from_ifkey(ifKey), &if_ip6_unused) == ESP_OK; -} - CHIP_ERROR ESP32Utils::GetWiFiStationProvision(Internal::DeviceNetworkInfo & netInfo, bool includeCredentials) { wifi_config_t stationConfig; @@ -381,6 +360,28 @@ CHIP_ERROR ESP32Utils::InitWiFiStack(void) } return CHIP_NO_ERROR; } +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + +struct netif * ESP32Utils::GetNetif(const char * ifKey) +{ + struct netif * netif = NULL; + esp_netif_t * netif_handle = NULL; + netif_handle = esp_netif_get_handle_from_ifkey(ifKey); + netif = (struct netif *) esp_netif_get_netif_impl(netif_handle); + return netif; +} + +bool ESP32Utils::IsInterfaceUp(const char * ifKey) +{ + struct netif * netif = GetNetif(ifKey); + return netif != NULL && netif_is_up(netif); +} + +bool ESP32Utils::HasIPv6LinkLocalAddress(const char * ifKey) +{ + struct esp_ip6_addr if_ip6_unused; + return esp_netif_get_ip6_linklocal(esp_netif_get_handle_from_ifkey(ifKey), &if_ip6_unused) == ESP_OK; +} CHIP_ERROR ESP32Utils::MapError(esp_err_t error) {