mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22: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 charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<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="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>
|
</head>
|
||||||
|
|
||||||
<body></body>
|
<body></body>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -4,12 +4,12 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<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="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>
|
</head>
|
||||||
|
|
||||||
<body></body>
|
<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"
|
#include "BuildTime.h"
|
||||||
|
|
||||||
// Версия прошивки
|
// Версия прошивки
|
||||||
#define FIRMWARE_VERSION 453
|
#define FIRMWARE_VERSION 454
|
||||||
|
|
||||||
#ifdef esp8266_1mb_ota
|
#ifdef esp8266_1mb_ota
|
||||||
#define FIRMWARE_NAME "esp8266_1mb_ota"
|
#define FIRMWARE_NAME "esp8266_1mb_ota"
|
||||||
@@ -80,7 +80,8 @@ WEB_SOCKETS_FRAME_SIZE создан для того что бы не загру
|
|||||||
#define LEAP_YEAR(Y) (((1970 + Y) > 0) && !((1970 + Y) % 4) && (((1970 + Y) % 100) || !((1970 + Y) % 400)))
|
#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,
|
WIFI_MQTT_CONNECTION_CHECK,
|
||||||
TIME,
|
TIME,
|
||||||
TIME_SYNC,
|
TIME_SYNC,
|
||||||
@@ -89,7 +90,8 @@ enum TimerTask_t { WIFI_SCAN,
|
|||||||
TIMES, // периодические секундные проверки
|
TIMES, // периодические секундные проверки
|
||||||
PTASK,
|
PTASK,
|
||||||
ST,
|
ST,
|
||||||
END };
|
END
|
||||||
|
};
|
||||||
|
|
||||||
// задачи которые надо протащить через loop
|
// задачи которые надо протащить через loop
|
||||||
enum NotAsyncActions {
|
enum NotAsyncActions {
|
||||||
@@ -99,15 +101,7 @@ enum NotAsyncActions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// состояния обновления
|
// состояния обновления
|
||||||
enum UpdateStates { NOT_STARTED,
|
enum UpdateStates { UPDATE_COMPLETED, UPDATE_FAILED, PATH_ERROR };
|
||||||
UPDATE_FS_IN_PROGRESS,
|
|
||||||
UPDATE_FS_COMPLETED,
|
|
||||||
UPDATE_FS_FAILED,
|
|
||||||
UPDATE_BUILD_IN_PROGRESS,
|
|
||||||
UPDATE_BUILD_COMPLETED,
|
|
||||||
UPDATE_BUILD_FAILED,
|
|
||||||
PATH_ERROR
|
|
||||||
};
|
|
||||||
|
|
||||||
enum distination {
|
enum distination {
|
||||||
TO_MQTT,
|
TO_MQTT,
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ extern void restartEsp();
|
|||||||
extern const String getBinPath(String file);
|
extern const String getBinPath(String file);
|
||||||
extern void putUserDataToRam();
|
extern void putUserDataToRam();
|
||||||
extern void saveUserDataToFlash();
|
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/Cron>
|
||||||
+<modules/virtual/Loging>
|
+<modules/virtual/Loging>
|
||||||
+<modules/virtual/LogingDaily>
|
+<modules/virtual/LogingDaily>
|
||||||
+<modules/virtual/owmWeather>
|
|
||||||
+<modules/virtual/Timer>
|
+<modules/virtual/Timer>
|
||||||
+<modules/virtual/Variable>
|
+<modules/virtual/Variable>
|
||||||
+<modules/virtual/VariableColor>
|
+<modules/virtual/VariableColor>
|
||||||
@@ -584,7 +583,7 @@ build_src_filter =
|
|||||||
+<modules/exec/Pwm32>
|
+<modules/exec/Pwm32>
|
||||||
+<modules/exec/TelegramLT>
|
+<modules/exec/TelegramLT>
|
||||||
+<modules/display/Lcd2004>
|
+<modules/display/Lcd2004>
|
||||||
+<modules/display/Oled648266/Oled648266>
|
+<modules/display/Oled64>
|
||||||
+<modules/display/Smi2_m>
|
+<modules/display/Smi2_m>
|
||||||
+<modules/display/TM16XX>
|
+<modules/display/TM16XX>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ updateFirm update;
|
|||||||
|
|
||||||
void upgrade_firmware(int type, String path) {
|
void upgrade_firmware(int type, String path) {
|
||||||
putUserDataToRam();
|
putUserDataToRam();
|
||||||
|
// сбросим файл статуса последнего обновления
|
||||||
|
writeFile("ota.json", "{}");
|
||||||
|
|
||||||
// only build
|
// only build
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
@@ -36,10 +38,10 @@ bool upgradeFS(String path) {
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
WiFiClient wifiClient;
|
WiFiClient wifiClient;
|
||||||
SerialPrint("!!!", F("Update"), "Start upgrade FS... " + path);
|
SerialPrint("!!!", F("Update"), "Start upgrade FS... " + path);
|
||||||
handleUpdateStatus(true, UPDATE_FS_IN_PROGRESS);
|
|
||||||
if (path == "") {
|
if (path == "") {
|
||||||
SerialPrint("E", F("Update"), F("FS Path error"));
|
SerialPrint("E", F("Update"), F("FS Path error"));
|
||||||
handleUpdateStatus(true, PATH_ERROR);
|
saveUpdeteStatus("fs", PATH_ERROR);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@@ -55,10 +57,10 @@ bool upgradeFS(String path) {
|
|||||||
// если FS обновилась успешно
|
// если FS обновилась успешно
|
||||||
if (retFS == HTTP_UPDATE_OK) {
|
if (retFS == HTTP_UPDATE_OK) {
|
||||||
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
|
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
|
||||||
handleUpdateStatus(true, UPDATE_FS_COMPLETED);
|
saveUpdeteStatus("fs", UPDATE_COMPLETED);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
handleUpdateStatus(true, UPDATE_FS_FAILED);
|
saveUpdeteStatus("fs", UPDATE_FAILED);
|
||||||
if (retFS == HTTP_UPDATE_FAILED) {
|
if (retFS == HTTP_UPDATE_FAILED) {
|
||||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
||||||
} else if (retFS == HTTP_UPDATE_NO_UPDATES) {
|
} else if (retFS == HTTP_UPDATE_NO_UPDATES) {
|
||||||
@@ -72,10 +74,10 @@ bool upgradeBuild(String path) {
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
WiFiClient wifiClient;
|
WiFiClient wifiClient;
|
||||||
SerialPrint("!!!", F("Update"), "Start upgrade BUILD... " + path);
|
SerialPrint("!!!", F("Update"), "Start upgrade BUILD... " + path);
|
||||||
handleUpdateStatus(true, UPDATE_BUILD_IN_PROGRESS);
|
|
||||||
if (path == "") {
|
if (path == "") {
|
||||||
SerialPrint("E", F("Update"), F("Build Path error"));
|
SerialPrint("E", F("Update"), F("Build Path error"));
|
||||||
handleUpdateStatus(true, PATH_ERROR);
|
saveUpdeteStatus("build", PATH_ERROR);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#if defined(esp8266_4mb) || defined(esp8266_16mb) || defined(esp8266_1mb) || defined(esp8266_1mb_ota) || defined(esp8266_2mb) || defined(esp8266_2mb_ota)
|
#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 обновился успешно
|
// если BUILD обновился успешно
|
||||||
if (retBuild == HTTP_UPDATE_OK) {
|
if (retBuild == HTTP_UPDATE_OK) {
|
||||||
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
|
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
|
||||||
handleUpdateStatus(true, UPDATE_BUILD_COMPLETED);
|
saveUpdeteStatus("build", UPDATE_COMPLETED);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
handleUpdateStatus(true, UPDATE_BUILD_FAILED);
|
saveUpdeteStatus("build", UPDATE_FAILED);
|
||||||
if (retBuild == HTTP_UPDATE_FAILED) {
|
if (retBuild == HTTP_UPDATE_FAILED) {
|
||||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
||||||
} else if (retBuild == HTTP_UPDATE_NO_UPDATES) {
|
} else if (retBuild == HTTP_UPDATE_NO_UPDATES) {
|
||||||
@@ -132,7 +134,7 @@ void putUserDataToRam() {
|
|||||||
update.settingsFlashJson = readFile("settings.json", 4096);
|
update.settingsFlashJson = readFile("settings.json", 4096);
|
||||||
update.layoutJson = readFile("layout.json", 4096);
|
update.layoutJson = readFile("layout.json", 4096);
|
||||||
update.scenarioTxt = readFile("scenario.txt", 4096);
|
update.scenarioTxt = readFile("scenario.txt", 4096);
|
||||||
update.chartsData = createDataBaseSting();
|
// update.chartsData = createDataBaseSting();
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveUserDataToFlash() {
|
void saveUserDataToFlash() {
|
||||||
@@ -140,10 +142,13 @@ void saveUserDataToFlash() {
|
|||||||
writeFile("/settings.json", update.settingsFlashJson);
|
writeFile("/settings.json", update.settingsFlashJson);
|
||||||
writeFile("/layout.json", update.layoutJson);
|
writeFile("/layout.json", update.layoutJson);
|
||||||
writeFile("/scenario.txt", update.scenarioTxt);
|
writeFile("/scenario.txt", update.scenarioTxt);
|
||||||
writeDataBaseSting(update.chartsData);
|
// writeDataBaseSting(update.chartsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUpdateStatus(bool send, int state) {
|
void saveUpdeteStatus(String key, int val) {
|
||||||
jsonWriteInt_(errorsHeapJson, F("upd"), state);
|
const String path = "ota.json";
|
||||||
if (send) sendStringToWs("errors", errorsHeapJson, -1);
|
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|") {
|
if (headerStr == "/profile|") {
|
||||||
// для версии 451 отдаем myProfile.json
|
// для версии 451 отдаем myProfile.json
|
||||||
|
sendFileToWsByFrames("/ota.json", "otaupd", "", num, WEB_SOCKETS_FRAME_SIZE);
|
||||||
if (FileFS.exists("/myProfile.json")) {
|
if (FileFS.exists("/myProfile.json")) {
|
||||||
sendFileToWsByFrames("/myProfile.json", "prfile", "", num, WEB_SOCKETS_FRAME_SIZE);
|
sendFileToWsByFrames("/myProfile.json", "prfile", "", num, WEB_SOCKETS_FRAME_SIZE);
|
||||||
// для версии 452 и более отдаем flashProfile.json
|
// для версии 452 и более отдаем flashProfile.json
|
||||||
|
|||||||
@@ -65,14 +65,6 @@
|
|||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": []
|
||||||
"esp8266_4mb": [],
|
|
||||||
"esp8266_16mb": [],
|
|
||||||
"esp8266_1mb": [],
|
|
||||||
"esp8266_1mb_ota": [],
|
|
||||||
"esp8285_1mb": [],
|
|
||||||
"esp8285_1mb_ota": [],
|
|
||||||
"esp8266_2mb": [],
|
|
||||||
"esp8266_2mb_ota": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,8 +124,8 @@ const String readFile(const String& filename, size_t max_size) {
|
|||||||
size_t size = file.size();
|
size_t size = file.size();
|
||||||
if (size > max_size) {
|
if (size > max_size) {
|
||||||
file.close();
|
file.close();
|
||||||
if (path == "/config.json")
|
// что это за бред!
|
||||||
return "[]";
|
if (path == "/config.json") return "[]";
|
||||||
return "large";
|
return "large";
|
||||||
}
|
}
|
||||||
String temp = file.readString();
|
String temp = file.readString();
|
||||||
@@ -133,9 +133,7 @@ const String readFile(const String& filename, size_t max_size) {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String filepath(const String& filename) {
|
const String filepath(const String& filename) { return filename.startsWith("/") ? filename : "/" + filename; }
|
||||||
return filename.startsWith("/") ? filename : "/" + filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cutFile(const String& src, const String& dst) {
|
bool cutFile(const String& src, const String& dst) {
|
||||||
String srcPath = filepath(src);
|
String srcPath = filepath(src);
|
||||||
@@ -288,9 +286,7 @@ String getFilesList(String& directory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
bool getInfo(FSInfo& info) {
|
bool getInfo(FSInfo& info) { return FileFS.info(info); }
|
||||||
return FileFS.info(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Информация о ФС
|
// Информация о ФС
|
||||||
IoTFSInfo getFSInfo() {
|
IoTFSInfo getFSInfo() {
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
#include "utils/FileUtils.h"
|
#include "utils/FileUtils.h"
|
||||||
|
|
||||||
// new================================================================================
|
// new================================================================================
|
||||||
String jsonReadStrDoc(DynamicJsonDocument &doc, String name) {
|
String jsonReadStrDoc(DynamicJsonDocument &doc, String name) { return doc[name].as<String>(); }
|
||||||
return doc[name].as<String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void jsonWriteStrDoc(DynamicJsonDocument &doc, String name, String value) {
|
void jsonWriteStrDoc(DynamicJsonDocument &doc, String name, String value) { doc[name] = value; }
|
||||||
doc[name] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// new==============================================================================
|
// new==============================================================================
|
||||||
bool jsonRead(const String &json, String key, long &value, bool e) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
// SerialPrint("E", F("jsonReadArray"), key + " doc " + doc[key].as<String>());
|
|
||||||
if (doc[key].is<JsonArray>()) {
|
if (doc[key].is<JsonArray>()) {
|
||||||
for (int8_t i = 0; i < doc[key].size(); i++)
|
for (int8_t i = 0; i < doc[key].size(); i++) jArray.push_back(doc[key][i].as<String>());
|
||||||
jArray.push_back(doc[key][i].as<String>());
|
|
||||||
// SerialPrint("E", F("jsonReadArray"), "isArray"+key + " doc " + doc[key].as<String>());
|
|
||||||
} else {
|
} else {
|
||||||
jArray.push_back(doc[key].as<String>());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user