Skip to content

Commit fa4b3a8

Browse files
committed
Merge branch 'fix/deprecated_call_idf6' into 'master'
Fix deprecated wakeup cause retrieval allowing multiple wakeup reasons See merge request ae_group/esp-now!152
2 parents e960a7e + 0e8f1df commit fa4b3a8

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

src/debug/src/commands/cmd_system.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)