diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1482c0c0b..f8fb0cc0b 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2464,10 +2464,11 @@ void WiFiManager::handleClose(){ void WiFiManager::reportStatus(String &page){ // updateConxResult(WiFi.status()); // @todo: this defeats the purpose of last result, update elsewhere or add logic here DEBUG_WM(DEBUG_DEV,F("[WIFI] reportStatus prev:"),getWLStatusString(_lastconxresult)); - DEBUG_WM(DEBUG_DEV,F("[WIFI] reportStatus current:"),getWLStatusString(WiFi.status())); + uint8_t current_status = WiFi.status(); + DEBUG_WM(DEBUG_DEV,F("[WIFI] reportStatus current:"),getWLStatusString(current_status)); String str; if (WiFi_SSID() != ""){ - if (WiFi.status()==WL_CONNECTED){ + if (current_status==WL_CONNECTED){ str = FPSTR(HTTP_STATUS_ON); str.replace(FPSTR(T_i),WiFi.localIP().toString()); str.replace(FPSTR(T_v),htmlEntities(WiFi_SSID())); @@ -2475,24 +2476,35 @@ void WiFiManager::reportStatus(String &page){ else { str = FPSTR(HTTP_STATUS_OFF); str.replace(FPSTR(T_v),htmlEntities(WiFi_SSID())); - if(_lastconxresult == WL_STATION_WRONG_PASSWORD){ + if(current_status == WL_STATION_WRONG_PASSWORD){ // wrong password str.replace(FPSTR(T_c),"D"); // class str.replace(FPSTR(T_r),FPSTR(HTTP_STATUS_OFFPW)); } - else if(_lastconxresult == WL_NO_SSID_AVAIL){ + else if(current_status == WL_NO_SSID_AVAIL){ // connect failed, or ap not found str.replace(FPSTR(T_c),"D"); str.replace(FPSTR(T_r),FPSTR(HTTP_STATUS_OFFNOAP)); } - else if(_lastconxresult == WL_CONNECT_FAILED){ + else if(current_status == WL_CONNECT_FAILED){ // connect failed str.replace(FPSTR(T_c),"D"); str.replace(FPSTR(T_r),FPSTR(HTTP_STATUS_OFFFAIL)); } + else if(current_status == WL_CONNECTION_LOST){ + // was reboot, initializing + str.replace(FPSTR(T_c),"D"); + str.replace(FPSTR(T_r),FPSTR(HTTP_STATUS_CONNECTION_LOST)); + } + else if(current_status == WL_IDLE_STATUS){ + // was reboot, initializing + str.replace(FPSTR(T_c),"D"); + str.replace(FPSTR(T_r),FPSTR(HTTP_STATUS_IDLE_STATUS)); + } else{ - str.replace(FPSTR(T_c),""); - str.replace(FPSTR(T_r),""); + String s = F("код: ") + String(current_status); + str.replace(FPSTR(T_c),"D"); + str.replace(FPSTR(T_r), s); } } } diff --git a/WiFiManager.h b/WiFiManager.h index 26189b201..c0228fa3b 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -738,6 +738,7 @@ class WiFiManager String getIpForm(String id, String title, String value); public: void getScanItemOut(String &page); + void reportStatus(String &page); private: void getStaticOut(String &page); String getHTTPHead(const String &title); @@ -749,7 +750,6 @@ class WiFiManager String toStringIp(IPAddress ip); boolean validApPassword(); String encryptionTypeStr(uint8_t authmode); - void reportStatus(String &page); String getInfoData(String id); // flags diff --git a/wm_strings_en.h b/wm_strings_en.h index e6310b950..c529dcb0b 100644 --- a/wm_strings_en.h +++ b/wm_strings_en.h @@ -72,8 +72,11 @@ const char HTTP_FORM_SELECT[] PROGMEM = ""; const char HTTP_SCAN_LINK[] PROGMEM = "
"; + + const char HTTP_SAVED[] PROGMEM = "

Настройка

" "

Подключение к Wi-Fi

" +"
Статус:

Подключение...

" "

При успешном подключении через 5–10 секунд погаснет светодиод.

" "

Нажмите коротко на кнопку, чтобы Ватериус отправил показания на сайт.

" "

Если не удалось подключиться, начните с начала.

" @@ -88,12 +91,47 @@ const char HTTP_STATUS_ON[] PROGMEM = "
Под const char HTTP_STATUS_OFF[] PROGMEM = "
Отключен от {v}{r}
"; const char HTTP_STATUS_OFFPW[] PROGMEM = "
Ошибка аутентификации"; // STATION_WRONG_PASSWORD, no eps32 const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
Точка доступа не найдена"; // WL_NO_SSID_AVAIL -const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Нет соединения"; // WL_CONNECT_FAILED +const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Ошибка подключения"; // WL_CONNECT_FAILED +const char HTTP_STATUS_CONNECTION_LOST[] PROGMEM = "
Связь потеряна"; // WL_CONNECTION_LOST +const char HTTP_STATUS_IDLE_STATUS[] PROGMEM = "
Требуется повторная настройка"; // WL_IDLE_STATUS const char HTTP_STATUS_NONE[] PROGMEM = "
Не указана точка доступа
"; const char HTTP_BR[] PROGMEM = "
"; -const char HTTP_END_SCRIPT[] PROGMEM = ""; +// HTTP_END_SCRIPT +/* +function g(n) { + return document.getElementById(n) +} + +function send(n, e, t) { + const o = new XMLHttpRequest; + o.open("GET", n), o.timeout = e, o.onreadystatechange = function(n) { + 4 === o.readyState && 200 === o.status && t(o.responseText) + }, o.send() +} +window.onload = function() { + function n() { + send("/wifistatus", 2e3, (function(n) { + var e = JSON.parse(n); + Object.keys(e).forEach((function(n) { + g(n) && (g(n).innerHTML = e[n]) + })) + })) + } + n(); + setInterval(n, 2e3); + + function a() { + send("/wifisave", 7e3, function(a) { + clearInterval(b) + }) + } + a(); + var b = setInterval(a, 8e3); +}; +*/ +const char HTTP_END_SCRIPT[] PROGMEM = ""; #ifndef WM_NOHELP