Progress of renew of class

This commit is contained in:
Dmitry Borisenko
2020-11-17 01:01:42 +03:00
parent a20c2b8564
commit 06df1f17b6
33 changed files with 266 additions and 259 deletions

View File

@@ -26,23 +26,28 @@ void upgradeInit() {
getLastVersion();
if (lastVersion > 0) {
SerialPrint("I", "Update", "available version: " + String(lastVersion));
if (lastVersion > FIRMWARE_VERSION) {
jsonWriteStr(configSetupJson, "warning2", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Вышла новая версия прошивки, нажмите <b>обновить прошивку</b></p></font></div>"));
}
}
};
}
void getLastVersion() {
if ((WiFi.status() == WL_CONNECTED)) {
#ifdef ESP8266
String tmp = getURL( serverIP + F("/projects/iotmanager/esp8266/esp8266ver/esp8266ver.txt"));
#else
String tmp = getURL( serverIP + F("/projects/iotmanager/esp32/esp32ver/esp32ver.txt"));
#endif
#ifdef ESP8266
String tmp = getURL(serverIP + F("/projects/iotmanager/esp8266/esp8266ver/esp8266ver.txt"));
#else
String tmp = getURL(serverIP + F("/projects/iotmanager/esp32/esp32ver/esp32ver.txt"));
#endif
if (tmp == "error") {
lastVersion = -1;
} else {
}
else {
lastVersion = tmp.toInt();
}
} else {
}
else {
lastVersion = -2;
}
jsonWriteInt(configSetupJson, "last_version", lastVersion);
@@ -89,15 +94,15 @@ bool upgradeFS() {
Serial.println("Start upgrade LittleFS, please wait...");
#ifdef ESP8266
ESPhttpUpdate.rebootOnUpdate(false);
t_httpUpdate_return retFS = ESPhttpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp8266/littlefs/littlefs.bin"));
t_httpUpdate_return retFS = ESPhttpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp8266/littlefs/littlefs.bin"));
#else
httpUpdate.rebootOnUpdate(false);
HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp32/littlefs/spiffs.bin"));
HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp32/littlefs/spiffs.bin"));
#endif
if (retFS == HTTP_UPDATE_OK) { //если FS обновилась успешно
SerialPrint("I", "Update", "LittleFS upgrade done!");
ret = true;
}
}
return ret;
}
@@ -108,16 +113,16 @@ bool upgradeBuild() {
#ifdef ESP8266
ESPhttpUpdate.rebootOnUpdate(false);
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp8266/firmware/firmware.bin"));
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp8266/firmware/firmware.bin"));
#else
httpUpdate.rebootOnUpdate(false);
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp32/firmware/firmware.bin"));
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp32/firmware/firmware.bin"));
#endif
if (retBuild == HTTP_UPDATE_OK) { //если BUILD обновился успешно
SerialPrint("I", "Update", "BUILD upgrade done!");
ret = true;
}
}
return ret;
}