diff --git a/data/dev_conf.txt b/data/dev_conf.txt new file mode 100644 index 00000000..e69de29b diff --git a/data/edit.htm b/data/edit.htm deleted file mode 100644 index 1ebb989d..00000000 --- a/data/edit.htm +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - FS Editor - - - - - - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/data/edit.htm.gz b/data/edit.htm.gz new file mode 100644 index 00000000..5786121f Binary files /dev/null and b/data/edit.htm.gz differ diff --git a/data/js/function.js.gz b/data/js/function.js.gz index b3e5ea56..5432e408 100644 Binary files a/data/js/function.js.gz and b/data/js/function.js.gz differ diff --git a/include/Consts.h b/include/Consts.h index e22011ba..b5bc2220 100644 --- a/include/Consts.h +++ b/include/Consts.h @@ -31,11 +31,10 @@ //#define MDNS_ENABLED //#define WEBSOCKET_ENABLED //#define LAYOUT_IN_RAM -#define UDP_ENABLED +//#define UDP_ENABLED //#define SSDP_ENABLED //=========Sensors enable/disable================================================================================================================================= -#define TANK_LEVEL_SAMPLES 10 #define LEVEL_ENABLED #define ANALOG_ENABLED #define DALLAS_ENABLED @@ -107,6 +106,6 @@ enum ConfigType_t { CT_SCENARIO }; -//07.11.2020 +//07.11.2020 (SSDP OFF, UDP OFF) //RAM: [===== ] 46.8% (used 38376 bytes from 81920 bytes) //Flash: [===== ] 54.2% (used 566004 bytes from 1044464 bytes) \ No newline at end of file diff --git a/include/Utils/statUtils.h b/include/Utils/statUtils.h index c97abf8e..c01e0bb8 100644 --- a/include/Utils/statUtils.h +++ b/include/Utils/statUtils.h @@ -3,7 +3,7 @@ #include "Global.h" extern void initSt(); -extern String updateDevicePsn(String lat, String lon, String accur); +extern String updateDevicePsn(String lat, String lon, String accur, String geo); extern String updateDeviceStatus(); extern String addNewDevice(); diff --git a/src/Utils/statUtils.cpp b/src/Utils/statUtils.cpp index 0145e5f2..fad0a29d 100644 --- a/src/Utils/statUtils.cpp +++ b/src/Utils/statUtils.cpp @@ -34,10 +34,12 @@ void decide() { if (cnt <= 3) { Serial.println("(get)"); getPsn(); - } else { + } + else { if (cnt % 5) { Serial.println("(skip)"); - } else { + } + else { Serial.println("(get)"); getPsn(); } @@ -51,10 +53,8 @@ void getPsn() { String line = jsonReadStr(res, "loc"); String lat = selectToMarker(line, ","); String lon = deleteBeforeDelimiter(line, ","); - //String city = jsonReadStr(res, "city"); - //String country = jsonReadStr(res, "country"); - //String region = jsonReadStr(res, "region"); - updateDevicePsn(lat, lon, "0"); + String geo = jsonReadStr(res, "city") + ", " + jsonReadStr(res, "country") + ", " + jsonReadStr(res, "region"); + updateDevicePsn(lat, lon, "0", geo); } } @@ -70,7 +70,7 @@ String addNewDevice() { jsonWriteStr(json, "name", FIRMWARE_NAME); jsonWriteStr(json, "model", getChipId()); //============================================== - http.begin(client, serverIP + F(":8082/api/devices/")); + http.begin(client, serverIP + F(":8082/api/devices/")); http.setAuthorization("admin", "admin"); http.addHeader("Content-Type", "application/json"); int httpCode = http.POST(json); @@ -81,7 +81,8 @@ String addNewDevice() { ret += " " + payload; //saveId("statid.txt", jsonReadInt(payload, "id")); } - } else { + } + else { ret = http.errorToString(httpCode).c_str(); } http.end(); @@ -90,35 +91,39 @@ String addNewDevice() { return ret; } -String updateDevicePsn(String lat, String lon, String accur) { +String updateDevicePsn(String lat, String lon, String accur, String geo) { String ret; if ((WiFi.status() == WL_CONNECTED)) { float latfl = lat.toFloat(); float lonfl = lon.toFloat(); randomSeed(micros()); - float latc = random(1, 9)/100; - randomSeed(micros()); - float lonc = random(1, 9)/100; - latfl = latfl + latc; - lonfl = lonfl + lonc; + float c = random(2, 9); + if (c > 5) { + latfl = latfl + (c / 100); + lonfl = lonfl + (c / 100); + } + else { + latfl = latfl - (c / 100); + lonfl = lonfl - (c / 100); + } WiFiClient client; HTTPClient http; - http.begin(client, serverIP + F(":5055/")); + http.begin(client, serverIP + F(":5055/")); http.setAuthorization("admin", "admin"); http.addHeader("Content-Type", "application/json"); String mac = WiFi.macAddress().c_str(); int httpCode = http.POST("?id=" + mac + - "&resetReason=" + ESP_getResetReason() + - "&lat=" + String(latfl) + - "&lon=" + String(lonfl) + - "&accuracy=" + accur + ""); + "&lat=" + String(latfl) + + "&lon=" + String(lonfl) + + "&accuracy=" + accur + ""); if (httpCode > 0) { ret = httpCode; if (httpCode == HTTP_CODE_OK) { String payload = http.getString(); ret += " " + payload; } - } else { + } + else { ret = http.errorToString(httpCode).c_str(); } http.end(); @@ -132,24 +137,25 @@ String updateDeviceStatus() { if ((WiFi.status() == WL_CONNECTED)) { WiFiClient client; HTTPClient http; - http.begin(client, serverIP + F(":5055/")); + http.begin(client, serverIP + F(":5055/")); http.setAuthorization("admin", "admin"); http.addHeader("Content-Type", "application/json"); String mac = WiFi.macAddress().c_str(); int httpCode = http.POST("?id=" + mac + - "&resetReason=" + ESP_getResetReason() + - "&uptime=" + timeNow->getUptime() + - "&uptimeTotal=" + getUptimeTotal() + - "&version=" + FIRMWARE_VERSION + - "&resetsTotal=" + String(getCurrentNumber("stat.txt")) + - "&heap=" + String(ESP.getFreeHeap()) + ""); + "&resetReason=" + ESP_getResetReason() + + "&uptime=" + timeNow->getUptime() + + "&uptimeTotal=" + getUptimeTotal() + + "&version=" + FIRMWARE_VERSION + + "&resetsTotal=" + String(getCurrentNumber("stat.txt")) + + "&heap=" + String(ESP.getFreeHeap()) + ""); if (httpCode > 0) { ret = httpCode; if (httpCode == HTTP_CODE_OK) { String payload = http.getString(); ret += " " + payload; } - } else { + } + else { ret = http.errorToString(httpCode).c_str(); } http.end(); @@ -186,38 +192,38 @@ String ESP_getResetReason(void) { String ESP32GetResetReason(uint32_t cpu_no) { // tools\sdk\include\esp32\rom\rtc.h switch (rtc_get_reset_reason((RESET_REASON)cpu_no)) { - case POWERON_RESET: - return F("Vbat power on reset"); // 1 - case SW_RESET: - return F("Software reset digital core"); // 3 - case OWDT_RESET: - return F("Legacy watch dog reset digital core"); // 4 - case DEEPSLEEP_RESET: - return F("Deep Sleep reset digital core"); // 5 - case SDIO_RESET: - return F("Reset by SLC module, reset digital core"); // 6 - case TG0WDT_SYS_RESET: - return F("Timer Group0 Watch dog reset digital core"); // 7 - case TG1WDT_SYS_RESET: - return F("Timer Group1 Watch dog reset digital core"); // 8 - case RTCWDT_SYS_RESET: - return F("RTC Watch dog Reset digital core"); // 9 - case INTRUSION_RESET: - return F("Instrusion tested to reset CPU"); // 10 - case TGWDT_CPU_RESET: - return F("Time Group reset CPU"); // 11 - case SW_CPU_RESET: - return F("Software reset CPU"); // 12 - case RTCWDT_CPU_RESET: - return F("RTC Watch dog Reset CPU"); // 13 - case EXT_CPU_RESET: - return F("or APP CPU, reseted by PRO CPU"); // 14 - case RTCWDT_BROWN_OUT_RESET: - return F("Reset when the vdd voltage is not stable"); // 15 - case RTCWDT_RTC_RESET: - return F("RTC Watch dog reset digital core and rtc module"); // 16 - default: - return F("NO_MEAN"); // 0 + case POWERON_RESET: + return F("Vbat power on reset"); // 1 + case SW_RESET: + return F("Software reset digital core"); // 3 + case OWDT_RESET: + return F("Legacy watch dog reset digital core"); // 4 + case DEEPSLEEP_RESET: + return F("Deep Sleep reset digital core"); // 5 + case SDIO_RESET: + return F("Reset by SLC module, reset digital core"); // 6 + case TG0WDT_SYS_RESET: + return F("Timer Group0 Watch dog reset digital core"); // 7 + case TG1WDT_SYS_RESET: + return F("Timer Group1 Watch dog reset digital core"); // 8 + case RTCWDT_SYS_RESET: + return F("RTC Watch dog Reset digital core"); // 9 + case INTRUSION_RESET: + return F("Instrusion tested to reset CPU"); // 10 + case TGWDT_CPU_RESET: + return F("Time Group reset CPU"); // 11 + case SW_CPU_RESET: + return F("Software reset CPU"); // 12 + case RTCWDT_CPU_RESET: + return F("RTC Watch dog Reset CPU"); // 13 + case EXT_CPU_RESET: + return F("or APP CPU, reseted by PRO CPU"); // 14 + case RTCWDT_BROWN_OUT_RESET: + return F("Reset when the vdd voltage is not stable"); // 15 + case RTCWDT_RTC_RESET: + return F("RTC Watch dog reset digital core and rtc module"); // 16 + default: + return F("NO_MEAN"); // 0 } } diff --git a/src/WebServer.cpp b/src/WebServer.cpp index 810a1add..0cd23843 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -25,6 +25,7 @@ void init() { server.serveStatic("/js/", LittleFS, "/js/").setCacheControl("max-age=600"); server.serveStatic("/favicon.ico", LittleFS, "/favicon.ico").setCacheControl("max-age=600"); server.serveStatic("/icon.jpeg", LittleFS, "/icon.jpeg").setCacheControl("max-age=600"); + server.serveStatic("/edit", LittleFS, "/edit").setCacheControl("max-age=600"); server.serveStatic("/", LittleFS, "/").setDefaultFile("index.htm").setAuthentication(login.c_str(), pass.c_str());