mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
версия 454 - исправлены баги, добавлена обратная связь на ota
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -4,12 +4,12 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IoT Manager 4.5.3</title>
|
||||
<title>IoT Manager 4.5.4</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?4531" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?4540" />
|
||||
|
||||
<script defer src="/build/bundle.js?4531"></script>
|
||||
<script defer src="/build/bundle.js?4540"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,12 +4,12 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
|
||||
<title>IoT Manager 4.5.3</title>
|
||||
<title>IoT Manager 4.5.4</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?4531" />
|
||||
<link rel="stylesheet" href="/build/bundle.css?4540" />
|
||||
|
||||
<script defer src="/build/bundle.js?4531"></script>
|
||||
<script defer src="/build/bundle.js?4540"></script>
|
||||
</head>
|
||||
|
||||
<body></body>
|
||||
|
||||
1
data_svelte/ota.json
Normal file
1
data_svelte/ota.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
extern void saveUpdeteStatus(String key, int val);
|
||||
@@ -552,7 +552,6 @@ build_src_filter =
|
||||
+<modules/virtual/Cron>
|
||||
+<modules/virtual/Loging>
|
||||
+<modules/virtual/LogingDaily>
|
||||
+<modules/virtual/owmWeather>
|
||||
+<modules/virtual/Timer>
|
||||
+<modules/virtual/Variable>
|
||||
+<modules/virtual/VariableColor>
|
||||
@@ -584,7 +583,7 @@ build_src_filter =
|
||||
+<modules/exec/Pwm32>
|
||||
+<modules/exec/TelegramLT>
|
||||
+<modules/display/Lcd2004>
|
||||
+<modules/display/Oled648266/Oled648266>
|
||||
+<modules/display/Oled64>
|
||||
+<modules/display/Smi2_m>
|
||||
+<modules/display/TM16XX>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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": []
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
#include "utils/FileUtils.h"
|
||||
|
||||
// new================================================================================
|
||||
String jsonReadStrDoc(DynamicJsonDocument &doc, String name) {
|
||||
return doc[name].as<String>();
|
||||
}
|
||||
String jsonReadStrDoc(DynamicJsonDocument &doc, String name) { return doc[name].as<String>(); }
|
||||
|
||||
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<String> &jArray,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// SerialPrint("E", F("jsonReadArray"), key + " doc " + doc[key].as<String>());
|
||||
|
||||
if (doc[key].is<JsonArray>()) {
|
||||
for (int8_t i = 0; i < doc[key].size(); i++)
|
||||
jArray.push_back(doc[key][i].as<String>());
|
||||
// SerialPrint("E", F("jsonReadArray"), "isArray"+key + " doc " + doc[key].as<String>());
|
||||
for (int8_t i = 0; i < doc[key].size(); i++) jArray.push_back(doc[key][i].as<String>());
|
||||
|
||||
} else {
|
||||
jArray.push_back(doc[key].as<String>());
|
||||
// DynamicJsonDocument docArr(JSON_BUFFER_SIZE/5);
|
||||
// jArray = doc[key].as<JsonArray>();
|
||||
// String tmp = doc[key].as<String>();
|
||||
// jArray.add("dsdsd");
|
||||
// SerialPrint("E", F("jsonReadArray"), "notArray"+key + " doc " + doc[key].as<String>());
|
||||
// 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<String>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user