File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -408,21 +408,24 @@ static int light_sleep(int argc, char **argv)
408408 fflush (stdout );
409409 fsync (fileno (stdout ));
410410 esp_light_sleep_start ();
411- esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause ();
412- const char * cause_str ;
413- switch (cause ) {
414- case ESP_SLEEP_WAKEUP_GPIO :
415- cause_str = "GPIO" ;
416- break ;
417- case ESP_SLEEP_WAKEUP_UART :
418- cause_str = "UART" ;
419- break ;
420- case ESP_SLEEP_WAKEUP_TIMER :
421- cause_str = "timer" ;
422- break ;
423- default :
424- cause_str = "unknown" ;
425- printf ("%d\n" , cause );
411+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL (6 , 0 , 0 )
412+ const uint32_t causes = esp_sleep_get_wakeup_causes ();
413+ #else
414+ const uint32_t causes = BIT (esp_sleep_get_wakeup_cause ());
415+ #endif
416+ char cause_str [32 ] = "" ;
417+ if (causes & BIT (ESP_SLEEP_WAKEUP_GPIO )) {
418+ strcat (cause_str , "GPIO " );
419+ }
420+ if (causes & BIT (ESP_SLEEP_WAKEUP_UART )) {
421+ strcat (cause_str , "UART " );
422+ }
423+ if (causes & BIT (ESP_SLEEP_WAKEUP_TIMER )) {
424+ strcat (cause_str , "TIMER " );
425+ }
426+ if (cause_str [0 ] == '\0' ) {
427+ strcpy (cause_str , "UNKNOWN" );
428+ printf ("%d\n" , causes );
426429 }
427430 ESP_LOGI (TAG , "Woke up from: %s" , cause_str );
428431 return 0 ;
You can’t perform that action at this time.
0 commit comments