Skip to content

Commit 7f02707

Browse files
committed
Fix printing of ESP reset reason
1 parent 09c5b8b commit 7f02707

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/Wippersnapper.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,9 +2644,34 @@ void Wippersnapper::publish(const char *topic, uint8_t *payload, uint16_t bLen,
26442644
}
26452645
}
26462646

2647+
#ifdef ARDUINO_ARCH_ESP32
2648+
2649+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
2650+
#include "esp32/rom/rtc.h"
2651+
#elif CONFIG_IDF_TARGET_ESP32S2
2652+
#include "esp32s2/rom/rtc.h"
2653+
#elif CONFIG_IDF_TARGET_ESP32C2
2654+
#include "esp32c2/rom/rtc.h"
2655+
#elif CONFIG_IDF_TARGET_ESP32C3
2656+
#include "esp32c3/rom/rtc.h"
2657+
#elif CONFIG_IDF_TARGET_ESP32S3
2658+
#include "esp32s3/rom/rtc.h"
2659+
#elif CONFIG_IDF_TARGET_ESP32C6
2660+
#include "esp32c6/rom/rtc.h"
2661+
#elif CONFIG_IDF_TARGET_ESP32H2
2662+
#include "esp32h2/rom/rtc.h"
2663+
#else
2664+
#error Target CONFIG_IDF_TARGET is not supported
2665+
#endif
2666+
2667+
void get_and_print_reset_reason_for_cpu(int cpuCore) {
2668+
print_reset_reason(rtc_get_reset_reason(cpuCore));
2669+
}
2670+
2671+
26472672
/**************************************************************/
26482673
/*!
2649-
@brief Prints last reset reason of ESP32
2674+
@brief Prints string reset reason of ESP32
26502675
@param reason
26512676
The return code of rtc_get_reset_reason(coreNum)
26522677
*/
@@ -2704,6 +2729,7 @@ void print_reset_reason(int reason) {
27042729
WS_DEBUG_PRINTLN("NO_MEAN");
27052730
}
27062731
}
2732+
#endif
27072733

27082734
/**************************************************************************/
27092735
/*!
@@ -2731,9 +2757,9 @@ void printDeviceInfo() {
27312757
// (ESP32-Only) Print reason why device was reset
27322758
#ifdef ARDUINO_ARCH_ESP32
27332759
WS_DEBUG_PRINT("ESP32 CPU0 RESET REASON: ");
2734-
print_reset_reason(0);
2760+
get_and_print_reset_reason_for_cpu(0);
27352761
WS_DEBUG_PRINT("ESP32 CPU1 RESET REASON: ");
2736-
print_reset_reason(1);
2762+
get_and_print_reset_reason_for_cpu(1);
27372763
#endif
27382764
}
27392765

0 commit comments

Comments
 (0)