diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index f11af8b98..c0a326f94 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -311,6 +311,10 @@ int http_fn_index(http_request_t* request) { poststr(request, "
Module will restart soon
"); RESET_ScheduleModuleReset(3); } + if (http_getArg(request->url, "unsafe", tmpA, sizeof(tmpA))) { + poststr(request, "
Will try to do unsafe init in few seconds
"); + MAIN_ScheduleUnsafeInit(3); + } poststr(request, ""); // end div#change poststr(request, "
"); // replaceable content follows } @@ -780,7 +784,12 @@ int http_fn_index(http_request_t* request) { hprintf255(request, "
OTA In Progress. Downloaded: %i B Flashed: %06lXh
", ota_total_bytes(), ota_progress()); } #endif - + if (bSafeMode) { + hprintf255(request, "
You are in safe mode (AP mode) because full reboot failed %i times.", + Main_GetLastRebootBootFailures()); + hprintf255(request, "Pins, relays, etc are disabled.
"); + + } // for normal page loads, show the rest of the HTML if (!http_getArg(request->url, "state", tmpA, sizeof(tmpA))) { poststr(request, "
"); // end div#state @@ -793,6 +802,13 @@ int http_fn_index(http_request_t* request) { "" ""); + if (bSafeMode) { + poststr(request, "
" + "" + "" + "
"); + } poststr(request, "
"); poststr(request, "
"); diff --git a/src/new_common.h b/src/new_common.h index 4b64e397b..02ffc38a5 100644 --- a/src/new_common.h +++ b/src/new_common.h @@ -408,6 +408,7 @@ typedef enum WIFI_RSSI_LEVEL wifi_rssi_scale(int8_t rssi_value); extern const char *str_rssi[]; +extern int bSafeMode; #endif /* __NEW_COMMON_H__ */ diff --git a/src/user_main.c b/src/user_main.c index aef95a66b..548c14517 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -44,19 +44,19 @@ static int g_secondsElapsed = 0; static int g_openAP = 0; // connect to wifi after this number of seconds static int g_connectToWiFi = 0; -// many boots failed? do not run pins or anything risky -static int bSafeMode = 0; // reset after this number of seconds static int g_reset = 0; // is connected to WiFi? static int g_bHasWiFiConnected = 0; // is Open Access point or a client? static int g_bOpenAccessPointMode = 0; - -static int g_bootFailures = 0; - +// in safe mode, user can press a button to enter the unsafe one +static int g_doUnsafeInitIn = 0; +int g_bootFailures = 0; static int g_saveCfgAfter = 0; static int g_startPingWatchDogAfter = 0; +// many boots failed? do not run pins or anything risky +int bSafeMode = 0; // not really