mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
local sever ota
This commit is contained in:
@@ -44,6 +44,8 @@ bool upgradeFS(String path) {
|
||||
SerialPrint("E", F("Update"), F("FS Path error"));
|
||||
saveUpdeteStatus("fs", PATH_ERROR);
|
||||
return ret;
|
||||
} else if (path == "local"){
|
||||
path = getBinPath();
|
||||
}
|
||||
#ifdef ESP8266
|
||||
ESPhttpUpdate.rebootOnUpdate(false);
|
||||
@@ -58,14 +60,17 @@ bool upgradeFS(String path) {
|
||||
// если FS обновилась успешно
|
||||
if (retFS == HTTP_UPDATE_OK) {
|
||||
SerialPrint("!!!", F("Update"), F("FS upgrade done!"));
|
||||
//HTTP.send(200, "text/plain", "FS upgrade done!");
|
||||
saveUpdeteStatus("fs", UPDATE_COMPLETED);
|
||||
ret = true;
|
||||
} else {
|
||||
saveUpdeteStatus("fs", UPDATE_FAILED);
|
||||
if (retFS == HTTP_UPDATE_FAILED) {
|
||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
||||
HTTP.send(200, "text/plain", "FS UPDATE_FAILED! DELETE /localota !!!");
|
||||
} else if (retFS == HTTP_UPDATE_NO_UPDATES) {
|
||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_NO_UPDATES");
|
||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_NO_UPDATES! DELETE /localota !!!");
|
||||
//HTTP.send(200, "text/plain", "NO_UPDATES");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -82,6 +87,8 @@ bool upgradeBuild(String path) {
|
||||
SerialPrint("E", F("Update"), F("Build Path error"));
|
||||
saveUpdeteStatus("build", PATH_ERROR);
|
||||
return ret;
|
||||
} else if (path == "local"){
|
||||
path = getBinPath();
|
||||
}
|
||||
#if defined(esp8266_4mb) || defined(esp8266_16mb) || defined(esp8266_1mb) || defined(esp8266_1mb_ota) || defined(esp8266_2mb) || defined(esp8266_2mb_ota)
|
||||
ESPhttpUpdate.rebootOnUpdate(false);
|
||||
@@ -95,14 +102,17 @@ bool upgradeBuild(String path) {
|
||||
// если BUILD обновился успешно
|
||||
if (retBuild == HTTP_UPDATE_OK) {
|
||||
SerialPrint("!!!", F("Update"), F("BUILD upgrade done!"));
|
||||
HTTP.send(200, "text/plain", "BUILD upgrade done! DELETE /localota !!!");
|
||||
saveUpdeteStatus("build", UPDATE_COMPLETED);
|
||||
ret = true;
|
||||
} else {
|
||||
saveUpdeteStatus("build", UPDATE_FAILED);
|
||||
if (retBuild == HTTP_UPDATE_FAILED) {
|
||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_FAILED");
|
||||
HTTP.send(200, "text/plain", "UPDATE_FAILED! DELETE /localota !!!");
|
||||
} else if (retBuild == HTTP_UPDATE_NO_UPDATES) {
|
||||
SerialPrint("E", F("Update"), "HTTP_UPDATE_NO_UPDATES");
|
||||
HTTP.send(200, "text/plain", "NO_UPDATES! DELETE /localota !!!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -115,23 +125,23 @@ void restartEsp() {
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
// теперь путь к обнавленю прошивки мы получаем из веб интерфейса
|
||||
// const String getBinPath(String file) {
|
||||
// String path = "error";
|
||||
// int targetVersion = 0;
|
||||
// String serverip;
|
||||
// if (jsonRead(errorsHeapJson, F("chver"), targetVersion)) {
|
||||
// if (targetVersion >= 400) {
|
||||
// if (jsonRead(settingsFlashJson, F("serverip"), serverip)) {
|
||||
// if (serverip != "") {
|
||||
// path = jsonReadStr(settingsFlashJson, F("serverip")) + "/iotm/" + String(FIRMWARE_NAME) + "/" + String(targetVersion) + "/" + file;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// SerialPrint("i", F("Update"), "path: " + path);
|
||||
// return path;
|
||||
// }
|
||||
//теперь путь к обнавленю прошивки мы получаем из веб интерфейса
|
||||
const String getBinPath() {
|
||||
String path = "error";
|
||||
int targetVersion = 400; //HACKFUCK local OTA version in PrepareServer.py
|
||||
String serverip;
|
||||
// if (jsonRead(errorsHeapJson, F("chver"), targetVersion)) {
|
||||
if (targetVersion >= 400) {
|
||||
if (jsonRead(settingsFlashJson, F("serverlocal"), serverip)) {
|
||||
if (serverip != "") {
|
||||
path = jsonReadStr(settingsFlashJson, F("serverlocal")) + "/iotm/" + String(FIRMWARE_NAME) + "/" + String(targetVersion) + "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
SerialPrint("i", F("Update"), "server local: " + path);
|
||||
return path;
|
||||
}
|
||||
|
||||
// https://t.me/IoTmanager/128814/164752 - убрал ограничение
|
||||
void putUserDataToRam() {
|
||||
|
||||
Reference in New Issue
Block a user