Improved firmware update

This commit is contained in:
Gunnar Skjold
2024-11-29 16:44:56 +01:00
parent b7c2510098
commit 319b534d4f
5 changed files with 64 additions and 22 deletions

View File

@@ -410,7 +410,7 @@ void setup() {
float vcc = hw.getVcc();
debugI_P(PSTR("AMS bridge started"));
debugI_P(PSTR("AMS reader %s started"), FirmwareVersion::VersionString);
debugI_P(PSTR("Voltage: %.2fV"), vcc);
if(updater.relocateOrRepartitionIfNecessary()) {
ESP.restart();
@@ -435,6 +435,12 @@ void setup() {
WiFi.onEvent(WiFiEvent);
#endif
UpgradeInformation upinfo;
if(config.getUpgradeInformation(upinfo)) {
updater.setUpgradeInformation(upinfo);
}
yield();
bool hasFs = false;
#if defined(ESP32)
WiFi.onEvent(WiFiEvent);
@@ -447,6 +453,7 @@ void setup() {
#endif
yield();
if(hasFs) {
#if defined(ESP8266)
LittleFS.gc();
@@ -496,11 +503,6 @@ void setup() {
ea.setPriceService(ps);
ws.setup(&config, &gpioConfig, &meterState, &ds, &ea, &rtp, &updater);
UpgradeInformation upinfo;
if(config.getUpgradeInformation(upinfo)) {
updater.setUpgradeInformation(upinfo);
}
UiConfig ui;
if(config.getUiConfig(ui)) {
if(strlen(ui.language) == 0) {
@@ -703,6 +705,14 @@ void loop() {
updater.getUpgradeInformation(upinfo);
config.setUpgradeInformation(upinfo);
updater.ackUpgradeInformationChanged();
if(upinfo.errorCode == AMS_UPDATE_ERR_SUCCESS_SIGNAL) {
debugW_P(PSTR("Rebooting to firmware version %s"), upinfo.toVersion);
upinfo.errorCode == AMS_UPDATE_ERR_SUCCESS_CONFIRMED;
config.setUpgradeInformation(upinfo);
delay(500);
ESP.restart();
}
}
end = millis();
if(end-start > SLOW_PROC_TRIGGER_MS) {