Working through git filesystem recovery

This commit is contained in:
Robert Strouse 2024-01-06 12:38:12 -08:00
parent a3cb1d63fe
commit 67cd9a3200
5 changed files with 15 additions and 2 deletions

View file

@ -44,6 +44,10 @@ void GitRelease::setAssetProperty(const char *key, const char *val) {
if(strlen(this->hwVersions)) strcat(this->hwVersions, ",");
strcat(this->hwVersions, "s3");
}
else if(strstr(val, "ino.esp32s2.bin")) {
if(strlen(this->hwVersions)) strcat(this->hwVersions, ",");
strcat(this->hwVersions, "s2");
}
else if(strstr(val, "ino.esp32c3.bin")) {
if(strlen(this->hwVersions)) strcat(this->hwVersions, ",");
strcat(this->hwVersions, "c3");
@ -391,6 +395,7 @@ bool GitUpdater::beginUpdate(const char *version) {
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->status = GIT_UPDATING;
this->partition = U_SPIFFS;
this->lockFS = true;
this->error = this->downloadFile();
@ -400,6 +405,7 @@ bool GitUpdater::recoverFilesystem() {
Serial.println("Committing Configuration...");
somfy.commit();
}
this->status = GIT_UPDATE_COMPLETE;
rebootDelay.reboot = true;
rebootDelay.rebootTime = millis() + 500;
return true;

View file

@ -13,6 +13,7 @@
#define GIT_UPDATE_COMPLETE 4
#define GIT_UPDATE_CANCELLING 5
#define GIT_UPDATE_CANCELLED 6
class GitRelease {
public:
uint64_t id = 0;

Binary file not shown.

Binary file not shown.

10
Web.cpp
View file

@ -2449,8 +2449,14 @@ void Web::begin() {
server.on("/recoverFilesystem", [] () {
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
webServer.sendCORSHeaders(server);
git.recoverFilesystem();
server.send(200, "application/json", "{\"status\":\"OK\",\"desc\":\"Recovering filesystem from github please wait!!!\"}");
if(git.status == GIT_UPDATING)
server.send(200, "application/json", "{\"status\":\"OK\",\"desc\":\"Filesystem is updating. Please wait!!!\"}");
else if(git.status != GIT_STATUS_READY)
server.send(200, "application/json", "{\"status\":\"ERROR\",\"desc\":\"Cannot recover file system at this time.\"}");
else {
git.recoverFilesystem();
server.send(200, "application/json", "{\"status\":\"OK\",\"desc\":\"Recovering filesystem from github please wait!!!\"}");
}
});
server.begin();
apiServer.begin();