fix(openthread): call sleep api only in native radio

This commit is contained in:
xiaqilin 2023-07-12 20:49:11 +08:00
parent a300e79589
commit 5492f382f9
4 changed files with 11 additions and 10 deletions

View File

@ -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)

View File

@ -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);

View File

@ -28,7 +28,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

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-C6 |
| ----------------- | -------- |
| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |
# OpenThread Sleepy Device Example