Skip to content

Commit

Permalink
fix(openthread): call sleep api only in native radio
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaqilin committed Jul 12, 2023
1 parent 5995cab commit afd76b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion components/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions components/openthread/src/esp_openthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/openthread/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/openthread/ot_sleepy_device/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
| Supported Targets | ESP32-C6 |
| ----------------- | -------- |
| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |

# OpenThread Sleepy Device Example

Expand Down

0 comments on commit afd76b8

Please sign in to comment.