reset logic fixed, restart counter addes
This commit is contained in:
parent
9060ba2f4c
commit
b0864c45b9
@ -95,8 +95,8 @@ void start_boot_menu(void) {
|
||||
// (because esp_restart() from ISR would trigger the ESP32 task watchdog)
|
||||
xTaskCreate(
|
||||
[](void *p) {
|
||||
vTaskSuspend(NULL);
|
||||
ESP.restart();
|
||||
vTaskSuspend(NULL); // wait for task resume call by watchdog
|
||||
esp_restart();
|
||||
},
|
||||
"Restart", configMINIMAL_STACK_SIZE, NULL, (3 | portPRIVILEGE_BIT),
|
||||
&RestartHandle);
|
||||
@ -148,7 +148,6 @@ void start_boot_menu(void) {
|
||||
[]() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
|
||||
WiFi.disconnect(true);
|
||||
esp_restart();
|
||||
},
|
||||
|
||||
|
13
src/main.cpp
13
src/main.cpp
@ -291,16 +291,15 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if (BOOTMENU)
|
||||
// start local webserver after device powers up or on rcommand request
|
||||
if ((RTC_runmode == RUNMODE_POWERCYCLE) ||
|
||||
(RTC_runmode == RUNMODE_MAINTENANCE))
|
||||
start_boot_menu();
|
||||
#else
|
||||
// start local webserver on rcommand request only
|
||||
if (RTC_runmode == RUNMODE_MAINTENANCE)
|
||||
// start local webserver after each coldstart
|
||||
if (RTC_runmode == RUNMODE_POWERCYCLE)
|
||||
start_boot_menu();
|
||||
#endif
|
||||
|
||||
// start local webserver on rcommand request
|
||||
if (RTC_runmode == RUNMODE_MAINTENANCE)
|
||||
start_boot_menu();
|
||||
|
||||
// start mac processing task
|
||||
ESP_LOGI(TAG, "Starting MAC processor...");
|
||||
macQueueInit();
|
||||
|
@ -10,6 +10,7 @@ static const char TAG[] = __FILE__;
|
||||
|
||||
// RTC_NOINIT_ATTR -> keep value after a software restart or system crash
|
||||
RTC_NOINIT_ATTR runmode_t RTC_runmode;
|
||||
RTC_NOINIT_ATTR uint32_t RTC_restarts;
|
||||
|
||||
// RTC_DATA_ATTR -> keep values after a wakeup from sleep
|
||||
RTC_DATA_ATTR struct timeval RTC_sleep_start_time;
|
||||
@ -17,9 +18,6 @@ RTC_DATA_ATTR unsigned long long RTC_millis = 0;
|
||||
|
||||
timeval sleep_stop_time;
|
||||
|
||||
const char *runmode[6] = {"powercycle", "normal", "wakeup",
|
||||
"update", "sleep", "maintenance"};
|
||||
|
||||
void do_reset(bool warmstart) {
|
||||
if (warmstart) {
|
||||
ESP_LOGI(TAG, "restarting device (warmstart)");
|
||||
@ -46,13 +44,11 @@ void do_after_reset(void) {
|
||||
case RTCWDT_BROWN_OUT_RESET: // 0x0f Reset when the vdd voltage is not
|
||||
// stable
|
||||
RTC_runmode = RUNMODE_POWERCYCLE;
|
||||
RTC_restarts = 0;
|
||||
break;
|
||||
|
||||
case SW_CPU_RESET: // 0x0c Software reset CPU
|
||||
// keep previous runmode, if RTC_runmode has valid value
|
||||
// sets runmode, if RTC_runmode is invalid (i.e. not initialized)
|
||||
if ((RTC_runmode != RUNMODE_UPDATE) && (RTC_runmode != RUNMODE_NORMAL))
|
||||
RTC_runmode = RUNMODE_POWERCYCLE;
|
||||
// keep previous set runmode (update / normal / maintenance)
|
||||
break;
|
||||
|
||||
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
||||
@ -84,8 +80,9 @@ void do_after_reset(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting Software v%s, runmode %s", PROGVERSION,
|
||||
runmode[RTC_runmode]);
|
||||
RTC_restarts++;
|
||||
ESP_LOGI(TAG, "Starting Software v%s (runmode=%d / restarts=%d)", PROGVERSION,
|
||||
RTC_runmode, RTC_restarts);
|
||||
}
|
||||
|
||||
void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
||||
|
Loading…
Reference in New Issue
Block a user