Browse Source
Merge pull request #2765 from fizzyfuzzle/ESP32-Reset-Reason
Add ESP32 Reset Reason to existing pwrmgt.bootreason cli command
pull/2435/merge
ripplebiz
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
36 additions and
4 deletions
-
src/helpers/CommonCLI.cpp
-
src/helpers/ESP32Board.h
|
|
|
@ -953,13 +953,9 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep |
|
|
|
strcpy(reply, "ERROR: Power management not supported"); |
|
|
|
#endif |
|
|
|
} else if (memcmp(config, "pwrmgt.bootreason", 17) == 0) { |
|
|
|
#ifdef NRF52_POWER_MANAGEMENT |
|
|
|
sprintf(reply, "> Reset: %s; Shutdown: %s", |
|
|
|
_board->getResetReasonString(_board->getResetReason()), |
|
|
|
_board->getShutdownReasonString(_board->getShutdownReason())); |
|
|
|
#else |
|
|
|
strcpy(reply, "ERROR: Power management not supported"); |
|
|
|
#endif |
|
|
|
} else if (memcmp(config, "pwrmgt.bootmv", 13) == 0) { |
|
|
|
#ifdef NRF52_POWER_MANAGEMENT |
|
|
|
sprintf(reply, "> %u mV", _board->getBootVoltage()); |
|
|
|
|
|
|
|
@ -155,6 +155,42 @@ public: |
|
|
|
void setInhibitSleep(bool inhibit) { |
|
|
|
inhibit_sleep = inhibit; |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t getResetReason() const override { |
|
|
|
return esp_reset_reason(); |
|
|
|
} |
|
|
|
|
|
|
|
// https://docs.espressif.com/projects/esp-idf/en/v4.4.7/esp32/api-reference/system/system.html
|
|
|
|
const char* getResetReasonString(uint32_t reason) { |
|
|
|
switch (reason) { |
|
|
|
case ESP_RST_UNKNOWN: |
|
|
|
return "Unknown or first boot"; |
|
|
|
case ESP_RST_POWERON: |
|
|
|
return "Power-on reset"; |
|
|
|
case ESP_RST_EXT: |
|
|
|
return "External reset"; |
|
|
|
case ESP_RST_SW: |
|
|
|
return "Software reset"; |
|
|
|
case ESP_RST_PANIC: |
|
|
|
return "Panic / exception reset"; |
|
|
|
case ESP_RST_INT_WDT: |
|
|
|
return "Interrupt watchdog reset"; |
|
|
|
case ESP_RST_TASK_WDT: |
|
|
|
return "Task watchdog reset"; |
|
|
|
case ESP_RST_WDT: |
|
|
|
return "Other watchdog reset"; |
|
|
|
case ESP_RST_DEEPSLEEP: |
|
|
|
return "Wake from deep sleep"; |
|
|
|
case ESP_RST_BROWNOUT: |
|
|
|
return "Brownout (low voltage)"; |
|
|
|
case ESP_RST_SDIO: |
|
|
|
return "SDIO reset"; |
|
|
|
default: |
|
|
|
static char buf[40]; |
|
|
|
snprintf(buf, sizeof(buf), "Unknown reset reason (%d)", reason); |
|
|
|
return buf; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
class ESP32RTCClock : public mesh::RTCClock { |
|
|
|
|