diff --git a/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c b/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c index 42e53f0f09..ff5812dcd6 100644 --- a/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c +++ b/examples/openthread/ot_sleepy_device/main/esp_ot_sleepy_device.c @@ -28,6 +28,13 @@ #include "openthread/logging.h" #include "openthread/thread.h" +#if CONFIG_ESP_SLEEP_DEBUG +#include "esp_timer.h" +#include "esp_sleep.h" +#include "esp_private/esp_pmu.h" +#include "esp_private/esp_sleep_internal.h" +#endif + #ifdef CONFIG_PM_ENABLE #include "esp_pm.h" #endif @@ -68,6 +75,17 @@ static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t return netif; } +#if CONFIG_ESP_SLEEP_DEBUG +static esp_sleep_context_t s_sleep_ctx; + +static void print_sleep_flag(void *arg) +{ + ESP_LOGD(TAG, "sleep_flags %lu", s_sleep_ctx.sleep_flags); + ESP_LOGD(TAG, "PMU_SLEEP_PD_TOP: %s", (s_sleep_ctx.sleep_flags & PMU_SLEEP_PD_TOP) ? "True":"False"); + ESP_LOGD(TAG, "PMU_SLEEP_PD_MODEM: %s", (s_sleep_ctx.sleep_flags & PMU_SLEEP_PD_MODEM) ? "True":"False"); +} +#endif + static void ot_task_worker(void *aContext) { esp_openthread_platform_config_t config = { @@ -90,6 +108,23 @@ static void ot_task_worker(void *aContext) create_config_network(esp_openthread_get_instance()); +#if CONFIG_ESP_SLEEP_DEBUG + esp_sleep_set_sleep_context(&s_sleep_ctx); + esp_log_level_set(TAG, ESP_LOG_DEBUG); + + // create a timer to print the status of sleepy device + int periods = 2000; + const esp_timer_create_args_t timer_args = { + .name = "print_sleep_flag", + .arg = NULL, + .callback = &print_sleep_flag, + .skip_unhandled_events = true, + }; + esp_timer_handle_t periodic_timer; + ESP_ERROR_CHECK(esp_timer_create(&timer_args, &periodic_timer)); + ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, periods * 1000)); +#endif + // Run the main loop esp_openthread_launch_mainloop(); diff --git a/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_c6 b/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_c6 deleted file mode 100644 index 80eea90801..0000000000 --- a/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_c6 +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG_IDF_TARGET="esp32c6" -CONFIG_IDF_TARGET_ESP32C6=y -CONFIG_OPENTHREAD_NETWORK_CHANNEL=12 -CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899" -CONFIG_ESP_SLEEP_DEBUG=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y diff --git a/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_h2 b/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_h2 index 43b8d650b8..4afe327821 100644 --- a/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_h2 +++ b/examples/openthread/ot_sleepy_device/sdkconfig.ci.sleepy_h2 @@ -3,4 +3,4 @@ CONFIG_IDF_TARGET_ESP32H2=y CONFIG_OPENTHREAD_NETWORK_CHANNEL=12 CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899" CONFIG_ESP_SLEEP_DEBUG=y -CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y +CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y diff --git a/examples/openthread/pytest_otbr.py b/examples/openthread/pytest_otbr.py index 7a95594ac4..349cf19f04 100644 --- a/examples/openthread/pytest_otbr.py +++ b/examples/openthread/pytest_otbr.py @@ -577,14 +577,13 @@ def test_ot_sleepy_device(dut: Tuple[IdfDut, IdfDut]) -> None: leader_para.setextpanid('dead00beef00cafe') leader_para.setnetworkkey('aabbccddeeff00112233445566778899') leader_para.setpskc('104810e2315100afd6bc9215a6bfac53') - ocf.clean_buffer(sleepy_device) ocf.joinThreadNetwork(leader, leader_para) + ocf.wait(leader, 5) ocf.clean_buffer(sleepy_device) sleepy_device.serial.hard_reset() sleepy_device.expect('detached -> child', timeout=20) sleepy_device.expect('PMU_SLEEP_PD_TOP: True', timeout=10) sleepy_device.expect('PMU_SLEEP_PD_MODEM: True', timeout=20) - ocf.clean_buffer(sleepy_device) output = sleepy_device.expect(pexpect.TIMEOUT, timeout=5) assert 'rst:' not in str(output) and 'boot:' not in str(output) finally: