Merge branch 'IoTManagerProject:ver4dev' into ver4dev

This commit is contained in:
2022-02-20 22:57:55 +03:00
committed by GitHub
7 changed files with 38 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -14,5 +14,6 @@
"mqttPrefix": "/ver4test",
"mqttUser": "rise",
"mqttPass": "hostel3333",
"serverip": "http://206.189.49.244:8081"
"serverip": "http://206.189.49.244:8081",
"log": 0
}

View File

@@ -1,7 +1,7 @@
#pragma once
//Версия прошивки
#define FIRMWARE_VERSION 405
#define FIRMWARE_VERSION 407
#ifdef esp8266_4mb
#define FIRMWARE_NAME "esp8266_4mb"
@@ -51,3 +51,14 @@ enum NotAsyncActions {
do_MQTTPARAMSCHANGED,
do_LAST,
};
//состояния обновления
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
};

View File

@@ -23,3 +23,4 @@ extern void restartEsp();
extern const String getBinPath(String file);
extern void putUserDataToRam();
extern void saveUserDataToFlash();
extern void handleUpdateStatus(bool send, int state);

View File

@@ -36,8 +36,10 @@ bool upgradeFS() {
bool ret = false;
WiFiClient wifiClient;
SerialPrint("!!!", F("Update"), F("Start upgrade FS..."));
handleUpdateStatus(true, UPDATE_FS_IN_PROGRESS);
if (getBinPath("") == "error") {
SerialPrint("E", F("Update"), F("FS Path error"));
handleUpdateStatus(true, PATH_ERROR);
return ret;
}
#ifdef ESP8266
@@ -52,9 +54,10 @@ bool upgradeFS() {
//если FS обновилась успешно
if (retFS == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
handleUpdateStatus(true, UPDATE_FS_COMPLETED);
ret = true;
}
handleUpdateStatus(true, UPDATE_FS_FAILED);
return ret;
}
@@ -62,8 +65,10 @@ bool upgradeBuild() {
bool ret = false;
WiFiClient wifiClient;
SerialPrint("!!!", F("Update"), F("Start upgrade BUILD..."));
handleUpdateStatus(true, UPDATE_BUILD_IN_PROGRESS);
if (getBinPath("") == "error") {
SerialPrint("E", F("Update"), F("Build Path error"));
handleUpdateStatus(true, PATH_ERROR);
return ret;
}
#ifdef esp8266_4mb
@@ -78,9 +83,10 @@ bool upgradeBuild() {
//если BUILD обновился успешно
if (retBuild == HTTP_UPDATE_OK) {
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
handleUpdateStatus(true, UPDATE_BUILD_COMPLETED);
ret = true;
}
handleUpdateStatus(true, UPDATE_BUILD_FAILED);
return ret;
}
@@ -118,3 +124,8 @@ void saveUserDataToFlash() {
writeFile("/settings.json", update.settingsFlashJson);
writeFile("/layout.json", update.layoutJson);
}
void handleUpdateStatus(bool send, int state) {
jsonWriteInt_(errorsHeapJson, F("upd"), state);
if (!send) standWebSocket.broadcastTXT(errorsHeapJson);
}

View File

@@ -2,8 +2,10 @@
#include "utils/SerialPrint.h"
void SerialPrint(String errorLevel, String module, String msg) {
Serial.println(prettyMillis(millis()) + " [" + errorLevel + "] [" + module + "] " + msg);
String tosend = "[" + errorLevel + "] [" + module + "] " + msg;
String tosend = prettyMillis(millis()) + " [" + errorLevel + "] [" + module + "] " + msg;
Serial.println(tosend);
// ws.textAll(tosend);
if (jsonReadInt(settingsFlashJson, F("log")) != 0) {
standWebSocket.broadcastTXT("/log|" + tosend);
}
}