From 83dbaf579516066bbbcc0e330962b22454d72e47 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Tue, 11 Jan 2022 14:29:28 +0800 Subject: [PATCH] Fix ESP32H2 errors after refactor --- .../common => components}/app_openthread/CMakeLists.txt | 0 .../app_openthread/app_openthread.c | 0 .../app_openthread/app_openthread.h | 0 .../app_openthread/app_openthread_config.h | 0 components/esp_matter/CMakeLists.txt | 4 ++++ components/esp_matter/esp_matter_core.cpp | 5 +++++ .../device/esp32c3_devkit_m/esp_matter_device.cmake | 3 +-- examples/light/CMakeLists.txt | 2 +- examples/light/main/CMakeLists.txt | 2 +- examples/light/main/app_main.cpp | 9 +-------- examples/light/sdkconfig.defaults.esp32h2 | 1 + examples/zap_light/CMakeLists.txt | 2 +- examples/zap_light/main/CMakeLists.txt | 2 +- examples/zap_light/main/app_main.cpp | 9 --------- examples/zap_light/sdkconfig.defaults.esp32h2 | 1 + 15 files changed, 17 insertions(+), 23 deletions(-) rename {examples/common => components}/app_openthread/CMakeLists.txt (100%) rename {examples/common => components}/app_openthread/app_openthread.c (100%) rename {examples/common => components}/app_openthread/app_openthread.h (100%) rename {examples/common => components}/app_openthread/app_openthread_config.h (100%) diff --git a/examples/common/app_openthread/CMakeLists.txt b/components/app_openthread/CMakeLists.txt similarity index 100% rename from examples/common/app_openthread/CMakeLists.txt rename to components/app_openthread/CMakeLists.txt diff --git a/examples/common/app_openthread/app_openthread.c b/components/app_openthread/app_openthread.c similarity index 100% rename from examples/common/app_openthread/app_openthread.c rename to components/app_openthread/app_openthread.c diff --git a/examples/common/app_openthread/app_openthread.h b/components/app_openthread/app_openthread.h similarity index 100% rename from examples/common/app_openthread/app_openthread.h rename to components/app_openthread/app_openthread.h diff --git a/examples/common/app_openthread/app_openthread_config.h b/components/app_openthread/app_openthread_config.h similarity index 100% rename from examples/common/app_openthread/app_openthread_config.h rename to components/app_openthread/app_openthread_config.h diff --git a/components/esp_matter/CMakeLists.txt b/components/esp_matter/CMakeLists.txt index 07806eeee..b30cd8cb0 100644 --- a/components/esp_matter/CMakeLists.txt +++ b/components/esp_matter/CMakeLists.txt @@ -35,6 +35,10 @@ set(INCLUDE_DIRS_LIST "." set(REQUIRES_LIST chip bt) +if ("${IDF_TARGET}" STREQUAL "esp32h2") + list(APPEND REQUIRES_LIST openthread app_openthread) +endif() + idf_component_register( SRC_DIRS ${SRC_DIRS_LIST} INCLUDE_DIRS ${INCLUDE_DIRS_LIST} REQUIRES ${REQUIRES_LIST}) diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index 60d299a6e..0d5d6e5c9 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -15,11 +15,15 @@ #include #include +#include #include #include #include #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +#include +#endif using chip::Credentials::SetDeviceAttestationCredentialsProvider; using chip::Credentials::Examples::GetExampleDACProvider; @@ -211,6 +215,7 @@ esp_err_t esp_matter_chip_init(esp_matter_event_callback_t callback) } PlatformMgr().AddEventHandler(callback, static_cast(NULL)); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD + app_openthread_launch_task(); if (ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR) { ESP_LOGE(TAG, "Failed to initialize Thread stack"); return ESP_FAIL; diff --git a/device_hal/device/esp32c3_devkit_m/esp_matter_device.cmake b/device_hal/device/esp32c3_devkit_m/esp_matter_device.cmake index 27a7bf4ad..0088c1c4f 100644 --- a/device_hal/device/esp32c3_devkit_m/esp_matter_device.cmake +++ b/device_hal/device/esp32c3_devkit_m/esp_matter_device.cmake @@ -10,5 +10,4 @@ SET(button_type hollow) SET(used_driver light_driver button_driver) SET(extra_components_dirs_append "${device_hal_path}/light_driver" "${device_hal_path}/button_driver" - "$ENV{IDF_PATH}/examples/common_components/led_strip" - "$ENV{IDF_PATH}/examples/peripherals/rmt/led_strip/components") + "$ENV{IDF_PATH}/examples/common_components/led_strip") diff --git a/examples/light/CMakeLists.txt b/examples/light/CMakeLists.txt index d984bd0de..0add5289e 100644 --- a/examples/light/CMakeLists.txt +++ b/examples/light/CMakeLists.txt @@ -30,7 +30,7 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake) set(EXTRA_COMPONENT_DIRS "../common" - "${IDF_PATH}/examples/common_components" + "${IDF_PATH}/examples/common_components/qrcode" "${MATTER_SDK_PATH}/config/esp32/components" "${ESP_MATTER_PATH}/components" "${ESP_MATTER_PATH}/device_hal/device" diff --git a/examples/light/main/CMakeLists.txt b/examples/light/main/CMakeLists.txt index 9c4748960..da58b3cb6 100644 --- a/examples/light/main/CMakeLists.txt +++ b/examples/light/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_openthread app_update) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_update) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 06d0937e9..2d4d9c229 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -14,9 +14,6 @@ #include #include -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -#include -#endif #include #include #include @@ -72,13 +69,9 @@ extern "C" void app_main() /* Initialize driver */ app_driver_init(); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - /* Initialize OpenThread */ - app_openthread_launch_task(); -#endif - /* Matter start */ err = esp_matter_start(app_event_cb); + if (err != ESP_OK) { ESP_LOGE(TAG, "Matter start failed: %d", err); } diff --git a/examples/light/sdkconfig.defaults.esp32h2 b/examples/light/sdkconfig.defaults.esp32h2 index 83b25c6e8..37e4d1470 100644 --- a/examples/light/sdkconfig.defaults.esp32h2 +++ b/examples/light/sdkconfig.defaults.esp32h2 @@ -54,6 +54,7 @@ CONFIG_USE_MINIMAL_MDNS=n # Increase stacks size CONFIG_NIMBLE_CONTROLLER_TASK_STACK_SIZE=5120 CONFIG_NIMBLE_HOST_TASK_STACK_SIZE=5120 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 # ESP32H2 BLE using a ext 32k crystal CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y diff --git a/examples/zap_light/CMakeLists.txt b/examples/zap_light/CMakeLists.txt index b9f8d18d1..9669f4251 100644 --- a/examples/zap_light/CMakeLists.txt +++ b/examples/zap_light/CMakeLists.txt @@ -30,7 +30,7 @@ include($ENV{ESP_MATTER_DEVICE_PATH}/esp_matter_device.cmake) set(EXTRA_COMPONENT_DIRS "../common" - "${IDF_PATH}/examples/common_components" + "${IDF_PATH}/examples/common_components/qrcode" "${MATTER_SDK_PATH}/config/esp32/components" "${ESP_MATTER_PATH}/components" "${ESP_MATTER_PATH}/device_hal/device" diff --git a/examples/zap_light/main/CMakeLists.txt b/examples/zap_light/main/CMakeLists.txt index eb7cb7079..0f321ec39 100644 --- a/examples/zap_light/main/CMakeLists.txt +++ b/examples/zap_light/main/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_openthread) +set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index 3d764c70f..8c0b6e1f7 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -13,10 +13,6 @@ #include #include #include - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -#include -#endif #include #include @@ -61,11 +57,6 @@ extern "C" void app_main() /* Initialize driver */ app_driver_init(); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - /* Initialize OpenThread */ - app_openthread_launch_task(); -#endif - /* Matter start */ err = esp_matter_start(app_event_cb); if (err != ESP_OK) { diff --git a/examples/zap_light/sdkconfig.defaults.esp32h2 b/examples/zap_light/sdkconfig.defaults.esp32h2 index dc8f0e2c5..b2d38397c 100644 --- a/examples/zap_light/sdkconfig.defaults.esp32h2 +++ b/examples/zap_light/sdkconfig.defaults.esp32h2 @@ -21,6 +21,7 @@ CONFIG_NEWTOS_ENABLE=n CONFIG_BLE_50_FEATURE_SUPPORT=y CONFIG_BLE_HCI_UART_BAUD=921600 CONFIG_BLE_EXT_ADV=n +CONFIG_BLE_LOG_LEVEL=1 # Enable OpenThread CONFIG_OPENTHREAD_ENABLED=y