Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code size optimisation of ESP.getResetReason() #7029

Merged
merged 2 commits into from
Jan 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,23 +468,24 @@ bool EspClass::checkFlashCRC() {


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 won’t change
strcpy_P(buff, PSTR("Exception"));
} else if (resetInfo.reason == REASON_SOFT_WDT_RST) { // software watch dog reset, GPIO status won’t change
strcpy_P(buff, PSTR("Software Watchdog"));
} else if (resetInfo.reason == REASON_SOFT_RESTART) { // software restart ,system_restart , GPIO status won’t 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"));
const __FlashStringHelper* buff;

switch(resetInfo.reason) {
// normal startup by power on
case REASON_DEFAULT_RST: buff = F("Power On"); break;
// hardware watch dog reset
case REASON_WDT_RST: buff = F("Hardware Watchdog"); break;
// exception reset, GPIO status won’t change
case REASON_EXCEPTION_RST: buff = F("Exception"); break;
// software watch dog reset, GPIO status won’t change
case REASON_SOFT_WDT_RST: buff = F("Software Watchdog"); break;
// software restart ,system_restart , GPIO status won’t change
case REASON_SOFT_RESTART: buff = F("Software/System restart"); break;
// wake up from deep-sleep
case REASON_DEEP_SLEEP_AWAKE: buff = F("Deep-Sleep Wake"); break;
// // external system reset
case REASON_EXT_SYS_RST: buff = F("External System"); break;
default: buff = F("Unknown"); break;
}
return String(buff);
}
Expand Down