1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-20 10:24:18 +03:00

Added getResetReason in human readable form

This commit is contained in:
Charles
2016-01-25 00:43:57 +01:00
parent e455315bbf
commit d9a51f9fa1
2 changed files with 23 additions and 0 deletions

View File

@ -329,6 +329,28 @@ bool EspClass::checkFlashConfig(bool needsEquals) {
return false; return false;
} }
String EspClass::getResetReason(void) {
char buff[32];
if (resetInfo.reason == REASON_DEFAULT_RST) { // normal startup by power on
strcpy_P(buff, PSTR("Power on"));
} else if (resetInfo.reason == REASON_WDT_RST) { // hardware watch dog reset
strcpy_P(buff, PSTR("Hardware Watchdog"));
} else if (resetInfo.reason == REASON_EXCEPTION_RST) { // exception reset, GPIO status wont change
strcpy_P(buff, PSTR("Exception"));
} else if (resetInfo.reason == REASON_SOFT_WDT_RST) { // software watch dog reset, GPIO status wont change
strcpy_P(buff, PSTR("Software Watchdog"));
} else if (resetInfo.reason == REASON_SOFT_RESTART) { // software restart ,system_restart , GPIO status wont change
strcpy_P(buff, PSTR("Software/System restart"));
} else if (resetInfo.reason == REASON_DEEP_SLEEP_AWAKE) { // wake up from deep-sleep
strcpy_P(buff, PSTR("Deep-Sleep Wake"));
} else if (resetInfo.reason == REASON_EXT_SYS_RST) { // external system reset
strcpy_P(buff, PSTR("External System"));
} else {
strcpy_P(buff, PSTR("Unknown"));
}
return String(buff);
}
String EspClass::getResetInfo(void) { String EspClass::getResetInfo(void) {
if(resetInfo.reason != 0) { if(resetInfo.reason != 0) {
char buff[200]; char buff[200];

View File

@ -131,6 +131,7 @@ class EspClass {
uint32_t getFreeSketchSpace(); uint32_t getFreeSketchSpace();
bool updateSketch(Stream& in, uint32_t size, bool restartOnFail = false, bool restartOnSuccess = true); bool updateSketch(Stream& in, uint32_t size, bool restartOnFail = false, bool restartOnSuccess = true);
String getResetReason();
String getResetInfo(); String getResetInfo();
struct rst_info * getResetInfoPtr(); struct rst_info * getResetInfoPtr();