From afd76b85fee456056448aad8d78de64d4816f2ab Mon Sep 17 00:00:00 2001 From: xiaqilin Date: Wed, 12 Jul 2023 20:49:11 +0800 Subject: [PATCH] fix(openthread): call sleep api only in native radio --- components/openthread/CMakeLists.txt | 3 ++- components/openthread/src/esp_openthread.cpp | 12 ++++++------ examples/openthread/.build-test-rules.yml | 2 +- examples/openthread/ot_sleepy_device/README.md | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index 7b02627731..782e2f5dab 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -121,7 +121,8 @@ if(CONFIG_OPENTHREAD_ENABLED) ) elseif(CONFIG_OPENTHREAD_RADIO_SPINEL_UART OR CONFIG_OPENTHREAD_RADIO_SPINEL_SPI) list(APPEND exclude_srcs - "src/port/esp_openthread_radio.c") + "src/port/esp_openthread_radio.c" + "src/port/esp_openthread_sleep.c") endif() if(CONFIG_OPENTHREAD_BORDER_ROUTER) diff --git a/components/openthread/src/esp_openthread.cpp b/components/openthread/src/esp_openthread.cpp index 8c03dc212a..1e543699d8 100644 --- a/components/openthread/src/esp_openthread.cpp +++ b/components/openthread/src/esp_openthread.cpp @@ -58,10 +58,10 @@ static size_t hex_string_to_binary(const char *hex_string, uint8_t *buf, size_t esp_err_t esp_openthread_init(const esp_openthread_platform_config_t *config) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE ESP_RETURN_ON_ERROR(esp_openthread_sleep_init(), OT_PLAT_LOG_TAG, "Failed to initialize OpenThread esp pm_lock"); -#endif +#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE */ ESP_RETURN_ON_ERROR(esp_openthread_platform_init(config), OT_PLAT_LOG_TAG, "Failed to initialize OpenThread platform driver"); esp_openthread_lock_acquire(portMAX_DELAY); @@ -164,17 +164,17 @@ esp_err_t esp_openthread_launch_mainloop(void) mainloop.timeout.tv_sec = 0; mainloop.timeout.tv_usec = 0; } -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE esp_openthread_sleep_process(); -#endif +#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE */ esp_openthread_lock_release(); if (select(mainloop.max_fd + 1, &mainloop.read_fds, &mainloop.write_fds, &mainloop.error_fds, &mainloop.timeout) >= 0) { esp_openthread_lock_acquire(portMAX_DELAY); -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE esp_openthread_wakeup_process(); -#endif +#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE && CONFIG_OPENTHREAD_RADIO_NATIVE */ error = esp_openthread_platform_process(instance, &mainloop); while (otTaskletsArePending(instance)) { otTaskletsProcess(instance); diff --git a/examples/openthread/.build-test-rules.yml b/examples/openthread/.build-test-rules.yml index 875b5eecd6..708b984373 100644 --- a/examples/openthread/.build-test-rules.yml +++ b/examples/openthread/.build-test-rules.yml @@ -52,7 +52,7 @@ examples/openthread/ot_rcp: examples/openthread/ot_sleepy_device: enable: - - if: IDF_TARGET == "esp32c6" + - if: IDF_TARGET in ["esp32h2", "esp32c6"] disable_test: - if: IDF_TARGET in ["esp32h2", "esp32c6"] temporary: true diff --git a/examples/openthread/ot_sleepy_device/README.md b/examples/openthread/ot_sleepy_device/README.md index 22da2be610..a41def3d99 100644 --- a/examples/openthread/ot_sleepy_device/README.md +++ b/examples/openthread/ot_sleepy_device/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-C6 | -| ----------------- | -------- | +| Supported Targets | ESP32-C6 | ESP32-H2 | +| ----------------- | -------- | -------- | # OpenThread Sleepy Device Example