Add FS recovery for failed FS updates.

This commit is contained in:
Robert Strouse 2024-01-06 11:28:03 -08:00
parent 2bb23e6d3e
commit a3cb1d63fe
6 changed files with 41 additions and 4 deletions

View file

@ -372,20 +372,38 @@ bool GitUpdater::beginUpdate(const char *version) {
somfy.commit();
strcpy(this->currentFile, "SomfyController.littlefs.bin");
this->partition = U_SPIFFS;
this->lockFS = true;
this->error = this->downloadFile();
this->lockFS = false;
if(this->error == 0) {
settings.fwVersion.parse(version);
delay(100);
Serial.println("Committing Configuration...");
somfy.commit();
rebootDelay.reboot = true;
rebootDelay.rebootTime = millis() + 500;
}
rebootDelay.reboot = true;
rebootDelay.rebootTime = millis() + 500;
}
this->status = GIT_UPDATE_COMPLETE;
this->emitUpdateCheck();
return true;
}
bool GitUpdater::recoverFilesystem() {
sprintf(this->baseUrl, "https://github.com/rstrouse/ESPSomfy-RTS/releases/download/%s/", settings.fwVersion.name);
strcpy(this->currentFile, "SomfyController.littlefs.bin");
this->partition = U_SPIFFS;
this->lockFS = true;
this->error = this->downloadFile();
this->lockFS = false;
if(this->error == 0) {
delay(100);
Serial.println("Committing Configuration...");
somfy.commit();
}
rebootDelay.reboot = true;
rebootDelay.rebootTime = millis() + 500;
return true;
}
bool GitUpdater::endUpdate() { return true; }
int8_t GitUpdater::downloadFile() {
WiFiClientSecure *client = new WiFiClientSecure;
@ -457,7 +475,7 @@ int8_t GitUpdater::downloadFile() {
}
else {
timeouts++;
if(timeouts >= 300) {
if(timeouts >= 500) {
Update.abort();
https.end();
free(buff);