From 781123eb08eee63bc9f996fe221e1ce2a07978bf Mon Sep 17 00:00:00 2001 From: Tan Yan Quan Date: Thu, 17 Apr 2025 10:33:18 +0800 Subject: [PATCH] fix(openthread): check state for ot wake --- .../openthread/private_include/esp_openthread_sleep.h | 10 ++-------- components/openthread/src/esp_openthread.cpp | 5 +---- components/openthread/src/port/esp_openthread_sleep.c | 9 ++------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/components/openthread/private_include/esp_openthread_sleep.h b/components/openthread/private_include/esp_openthread_sleep.h index e8b2679514..9cec96342a 100644 --- a/components/openthread/private_include/esp_openthread_sleep.h +++ b/components/openthread/private_include/esp_openthread_sleep.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,16 +25,10 @@ extern "C" { esp_err_t esp_openthread_sleep_init(void); /** - * @brief This function performs the OpenThread sleep process. + * @brief This function performs the OpenThread sleep and wake process. * */ void esp_openthread_sleep_process(void); - -/** - * @brief This function performs the OpenThread wakeup process. - * - */ -void esp_openthread_wakeup_process(void); #endif #ifdef __cplusplus diff --git a/components/openthread/src/esp_openthread.cpp b/components/openthread/src/esp_openthread.cpp index 87c7b4986e..73018e2d3f 100644 --- a/components/openthread/src/esp_openthread.cpp +++ b/components/openthread/src/esp_openthread.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -187,9 +187,6 @@ esp_err_t esp_openthread_launch_mainloop(void) 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 && CONFIG_OPENTHREAD_RADIO_NATIVE - esp_openthread_wakeup_process(); -#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/components/openthread/src/port/esp_openthread_sleep.c b/components/openthread/src/port/esp_openthread_sleep.c index 0077253eab..a5381625ca 100644 --- a/components/openthread/src/port/esp_openthread_sleep.c +++ b/components/openthread/src/port/esp_openthread_sleep.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,12 +37,7 @@ void esp_openthread_sleep_process(void) if (s_ot_sleep == false && esp_ieee802154_get_state() == ESP_IEEE802154_RADIO_SLEEP) { esp_pm_lock_release(s_pm_lock); s_ot_sleep = true; - } -} - -void esp_openthread_wakeup_process(void) -{ - if (s_ot_sleep) { + } else if (s_ot_sleep && esp_ieee802154_get_state() != ESP_IEEE802154_RADIO_SLEEP) { esp_pm_lock_acquire(s_pm_lock); s_ot_sleep = false; }