fix(openthread): check state for ot wake

This commit is contained in:
Tan Yan Quan
2025-04-17 10:33:18 +08:00
parent 72c4063d1a
commit 781123eb08
3 changed files with 5 additions and 19 deletions

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -25,16 +25,10 @@ extern "C" {
esp_err_t esp_openthread_sleep_init(void); 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); void esp_openthread_sleep_process(void);
/**
* @brief This function performs the OpenThread wakeup process.
*
*/
void esp_openthread_wakeup_process(void);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -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 * 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, if (select(mainloop.max_fd + 1, &mainloop.read_fds, &mainloop.write_fds, &mainloop.error_fds,
&mainloop.timeout) >= 0) { &mainloop.timeout) >= 0) {
esp_openthread_lock_acquire(portMAX_DELAY); 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); error = esp_openthread_platform_process(instance, &mainloop);
while (otTaskletsArePending(instance)) { while (otTaskletsArePending(instance)) {
otTaskletsProcess(instance); otTaskletsProcess(instance);

View File

@ -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 * 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) { if (s_ot_sleep == false && esp_ieee802154_get_state() == ESP_IEEE802154_RADIO_SLEEP) {
esp_pm_lock_release(s_pm_lock); esp_pm_lock_release(s_pm_lock);
s_ot_sleep = true; s_ot_sleep = true;
} } else if (s_ot_sleep && esp_ieee802154_get_state() != ESP_IEEE802154_RADIO_SLEEP) {
}
void esp_openthread_wakeup_process(void)
{
if (s_ot_sleep) {
esp_pm_lock_acquire(s_pm_lock); esp_pm_lock_acquire(s_pm_lock);
s_ot_sleep = false; s_ot_sleep = false;
} }