diff --git a/data_full/build/bundle.css.gz b/data_full/build/bundle.css.gz
index 1c9cda31..73e37493 100644
Binary files a/data_full/build/bundle.css.gz and b/data_full/build/bundle.css.gz differ
diff --git a/data_full/build/bundle.js.gz b/data_full/build/bundle.js.gz
index eab15d86..e1bfafb2 100644
Binary files a/data_full/build/bundle.js.gz and b/data_full/build/bundle.js.gz differ
diff --git a/data_full/index.html b/data_full/index.html
index 5bfdc1e0..0a91112e 100644
--- a/data_full/index.html
+++ b/data_full/index.html
@@ -4,12 +4,12 @@
-
IoT Manager 4.5.3
+ IoT Manager 4.5.4
-
+
-
+
diff --git a/data_svelte/build/bundle.css.gz b/data_svelte/build/bundle.css.gz
index 1c9cda31..73e37493 100644
Binary files a/data_svelte/build/bundle.css.gz and b/data_svelte/build/bundle.css.gz differ
diff --git a/data_svelte/build/bundle.js.gz b/data_svelte/build/bundle.js.gz
index eab15d86..e1bfafb2 100644
Binary files a/data_svelte/build/bundle.js.gz and b/data_svelte/build/bundle.js.gz differ
diff --git a/data_svelte/index.html b/data_svelte/index.html
index 5bfdc1e0..0a91112e 100644
--- a/data_svelte/index.html
+++ b/data_svelte/index.html
@@ -4,12 +4,12 @@
- IoT Manager 4.5.3
+ IoT Manager 4.5.4
-
+
-
+
diff --git a/data_svelte/ota.json b/data_svelte/ota.json
new file mode 100644
index 00000000..9e26dfee
--- /dev/null
+++ b/data_svelte/ota.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/include/Const.h b/include/Const.h
index 85c0276c..2865cd60 100644
--- a/include/Const.h
+++ b/include/Const.h
@@ -2,7 +2,7 @@
#include "BuildTime.h"
// Версия прошивки
-#define FIRMWARE_VERSION 453
+#define FIRMWARE_VERSION 454
#ifdef esp8266_1mb_ota
#define FIRMWARE_NAME "esp8266_1mb_ota"
@@ -45,7 +45,7 @@
#endif
// Размер буфера json
-#define JSON_BUFFER_SIZE 4096 // держим 2 кб не меняем
+#define JSON_BUFFER_SIZE 4096 // держим 2 кб не меняем
/*
WEB_SOCKETS_FRAME_SIZE создан для того что бы не загружать оперативку.
@@ -74,22 +74,24 @@ WEB_SOCKETS_FRAME_SIZE создан для того что бы не загру
#define USE_LITTLEFS true
-#define START_DATETIME 1661990400 // 01.09.2022 00:00:00 константа для сокращения unix time
+#define START_DATETIME 1661990400 // 01.09.2022 00:00:00 константа для сокращения unix time
#define MIN_DATETIME 1575158400
#define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400)))
// задачи таскера
-enum TimerTask_t { WIFI_SCAN,
+enum TimerTask_t {
+ WIFI_SCAN,
WIFI_MQTT_CONNECTION_CHECK,
TIME,
TIME_SYNC,
UPTIME,
- UDP, // UDPP
- TIMES, // периодические секундные проверки
+ UDP, // UDPP
+ TIMES, // периодические секундные проверки
PTASK,
ST,
- END };
+ END
+};
// задачи которые надо протащить через loop
enum NotAsyncActions {
@@ -99,15 +101,7 @@ enum NotAsyncActions {
};
// состояния обновления
-enum UpdateStates { NOT_STARTED,
- UPDATE_FS_IN_PROGRESS,
- UPDATE_FS_COMPLETED,
- UPDATE_FS_FAILED,
- UPDATE_BUILD_IN_PROGRESS,
- UPDATE_BUILD_COMPLETED,
- UPDATE_BUILD_FAILED,
- PATH_ERROR
-};
+enum UpdateStates { UPDATE_COMPLETED, UPDATE_FAILED, PATH_ERROR };
enum distination {
TO_MQTT,
diff --git a/include/UpgradeFirm.h b/include/UpgradeFirm.h
index 63ddb167..c7b8d120 100644
--- a/include/UpgradeFirm.h
+++ b/include/UpgradeFirm.h
@@ -25,4 +25,4 @@ extern void restartEsp();
extern const String getBinPath(String file);
extern void putUserDataToRam();
extern void saveUserDataToFlash();
-extern void handleUpdateStatus(bool send, int state);
\ No newline at end of file
+extern void saveUpdeteStatus(String key, int val);
\ No newline at end of file
diff --git a/platformio.ini b/platformio.ini
index 4f69bddc..15dbd04f 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -552,7 +552,6 @@ build_src_filter =
+
+
+
- +
+
+
+
@@ -584,7 +583,7 @@ build_src_filter =
+
+
+
- +
+ +
+
+
diff --git a/src/UpgradeFirm.cpp b/src/UpgradeFirm.cpp
index 05934011..37f3fe9c 100644
--- a/src/UpgradeFirm.cpp
+++ b/src/UpgradeFirm.cpp
@@ -4,6 +4,8 @@ updateFirm update;
void upgrade_firmware(int type, String path) {
putUserDataToRam();
+ // сбросим файл статуса последнего обновления
+ writeFile("ota.json", "{}");
// only build
if (type == 1) {
@@ -36,10 +38,10 @@ bool upgradeFS(String path) {
bool ret = false;
WiFiClient wifiClient;
SerialPrint("!!!", F("Update"), "Start upgrade FS... " + path);
- handleUpdateStatus(true, UPDATE_FS_IN_PROGRESS);
+
if (path == "") {
SerialPrint("E", F("Update"), F("FS Path error"));
- handleUpdateStatus(true, PATH_ERROR);
+ saveUpdeteStatus("fs", PATH_ERROR);
return ret;
}
#ifdef ESP8266
@@ -55,10 +57,10 @@ bool upgradeFS(String path) {
// если FS обновилась успешно
if (retFS == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
- handleUpdateStatus(true, UPDATE_FS_COMPLETED);
+ saveUpdeteStatus("fs", UPDATE_COMPLETED);
ret = true;
} else {
- handleUpdateStatus(true, UPDATE_FS_FAILED);
+ saveUpdeteStatus("fs", UPDATE_FAILED);
if (retFS == HTTP_UPDATE_FAILED) {
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
} else if (retFS == HTTP_UPDATE_NO_UPDATES) {
@@ -72,10 +74,10 @@ bool upgradeBuild(String path) {
bool ret = false;
WiFiClient wifiClient;
SerialPrint("!!!", F("Update"), "Start upgrade BUILD... " + path);
- handleUpdateStatus(true, UPDATE_BUILD_IN_PROGRESS);
+
if (path == "") {
SerialPrint("E", F("Update"), F("Build Path error"));
- handleUpdateStatus(true, PATH_ERROR);
+ saveUpdeteStatus("build", PATH_ERROR);
return ret;
}
#if defined(esp8266_4mb) || defined(esp8266_16mb) || defined(esp8266_1mb) || defined(esp8266_1mb_ota) || defined(esp8266_2mb) || defined(esp8266_2mb_ota)
@@ -90,10 +92,10 @@ bool upgradeBuild(String path) {
// если BUILD обновился успешно
if (retBuild == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
- handleUpdateStatus(true, UPDATE_BUILD_COMPLETED);
+ saveUpdeteStatus("build", UPDATE_COMPLETED);
ret = true;
} else {
- handleUpdateStatus(true, UPDATE_BUILD_FAILED);
+ saveUpdeteStatus("build", UPDATE_FAILED);
if (retBuild == HTTP_UPDATE_FAILED) {
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
} else if (retBuild == HTTP_UPDATE_NO_UPDATES) {
@@ -132,7 +134,7 @@ void putUserDataToRam() {
update.settingsFlashJson = readFile("settings.json", 4096);
update.layoutJson = readFile("layout.json", 4096);
update.scenarioTxt = readFile("scenario.txt", 4096);
- update.chartsData = createDataBaseSting();
+ // update.chartsData = createDataBaseSting();
}
void saveUserDataToFlash() {
@@ -140,10 +142,13 @@ void saveUserDataToFlash() {
writeFile("/settings.json", update.settingsFlashJson);
writeFile("/layout.json", update.layoutJson);
writeFile("/scenario.txt", update.scenarioTxt);
- writeDataBaseSting(update.chartsData);
+ // writeDataBaseSting(update.chartsData);
}
-void handleUpdateStatus(bool send, int state) {
- jsonWriteInt_(errorsHeapJson, F("upd"), state);
- if (send) sendStringToWs("errors", errorsHeapJson, -1);
+void saveUpdeteStatus(String key, int val) {
+ const String path = "ota.json";
+ String json = readFile(path, 1024);
+ if (json == "failed") json = "{}";
+ jsonWriteInt_(json, key, val);
+ writeFile(path, json);
}
\ No newline at end of file
diff --git a/src/WsServer.cpp b/src/WsServer.cpp
index 95593e87..0965338d 100644
--- a/src/WsServer.cpp
+++ b/src/WsServer.cpp
@@ -219,6 +219,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
//----------------------------------------------------------------------//
if (headerStr == "/profile|") {
// для версии 451 отдаем myProfile.json
+ sendFileToWsByFrames("/ota.json", "otaupd", "", num, WEB_SOCKETS_FRAME_SIZE);
if (FileFS.exists("/myProfile.json")) {
sendFileToWsByFrames("/myProfile.json", "prfile", "", num, WEB_SOCKETS_FRAME_SIZE);
// для версии 452 и более отдаем flashProfile.json
diff --git a/src/modules/virtual/owmWeather/modinfo.json b/src/modules/virtual/owmWeather/modinfo.json
index bcfea101..2a4c8af0 100644
--- a/src/modules/virtual/owmWeather/modinfo.json
+++ b/src/modules/virtual/owmWeather/modinfo.json
@@ -65,14 +65,6 @@
"usedLibs": {
"esp32_4mb": [],
"esp32s2_4mb": [],
- "esp32_16mb": [],
- "esp8266_4mb": [],
- "esp8266_16mb": [],
- "esp8266_1mb": [],
- "esp8266_1mb_ota": [],
- "esp8285_1mb": [],
- "esp8285_1mb_ota": [],
- "esp8266_2mb": [],
- "esp8266_2mb_ota": []
+ "esp32_16mb": []
}
}
\ No newline at end of file
diff --git a/src/utils/FileUtils.cpp b/src/utils/FileUtils.cpp
index f59316d5..c12bffbe 100644
--- a/src/utils/FileUtils.cpp
+++ b/src/utils/FileUtils.cpp
@@ -124,8 +124,8 @@ const String readFile(const String& filename, size_t max_size) {
size_t size = file.size();
if (size > max_size) {
file.close();
- if (path == "/config.json")
- return "[]";
+ // что это за бред!
+ if (path == "/config.json") return "[]";
return "large";
}
String temp = file.readString();
@@ -133,9 +133,7 @@ const String readFile(const String& filename, size_t max_size) {
return temp;
}
-const String filepath(const String& filename) {
- return filename.startsWith("/") ? filename : "/" + filename;
-}
+const String filepath(const String& filename) { return filename.startsWith("/") ? filename : "/" + filename; }
bool cutFile(const String& src, const String& dst) {
String srcPath = filepath(src);
@@ -288,9 +286,7 @@ String getFilesList(String& directory) {
}
#if defined(ESP8266)
-bool getInfo(FSInfo& info) {
- return FileFS.info(info);
-}
+bool getInfo(FSInfo& info) { return FileFS.info(info); }
// Информация о ФС
IoTFSInfo getFSInfo() {
diff --git a/src/utils/JsonUtils.cpp b/src/utils/JsonUtils.cpp
index 845c1179..9a616d26 100644
--- a/src/utils/JsonUtils.cpp
+++ b/src/utils/JsonUtils.cpp
@@ -2,13 +2,9 @@
#include "utils/FileUtils.h"
// new================================================================================
-String jsonReadStrDoc(DynamicJsonDocument &doc, String name) {
- return doc[name].as();
-}
+String jsonReadStrDoc(DynamicJsonDocument &doc, String name) { return doc[name].as(); }
-void jsonWriteStrDoc(DynamicJsonDocument &doc, String name, String value) {
- doc[name] = value;
-}
+void jsonWriteStrDoc(DynamicJsonDocument &doc, String name, String value) { doc[name] = value; }
// new==============================================================================
bool jsonRead(const String &json, String key, long &value, bool e) {
@@ -114,21 +110,14 @@ bool jsonReadArray(const String &json, String key, std::vector &jArray,
}
return false;
}
- // SerialPrint("E", F("jsonReadArray"), key + " doc " + doc[key].as());
+
if (doc[key].is()) {
- for (int8_t i = 0; i < doc[key].size(); i++)
- jArray.push_back(doc[key][i].as());
- // SerialPrint("E", F("jsonReadArray"), "isArray"+key + " doc " + doc[key].as());
+ for (int8_t i = 0; i < doc[key].size(); i++) jArray.push_back(doc[key][i].as());
+
} else {
jArray.push_back(doc[key].as());
- // DynamicJsonDocument docArr(JSON_BUFFER_SIZE/5);
- // jArray = doc[key].as();
- // String tmp = doc[key].as();
- // jArray.add("dsdsd");
- // SerialPrint("E", F("jsonReadArray"), "notArray"+key + " doc " + doc[key].as());
- // SerialPrint("E", F("jsonReadArray"), "count: " + String(jArray.size()) +" key: " + key + " arr " + jArray[0]);
}
- // SerialPrint("E", F("jsonReadArray"), "count: " + String(jArray.size()) +" key: " + key + " doc " + jArray[0].as());
+
return true;
}