mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
fix: download the per-chip LittleFS image in online updates
Releases publish SomfyController.littlefs.<chip>.bin, but the updater asked for SomfyController.littlefs.bin. The download 404'd and the device rebooted into the new firmware with the old web UI. Also: hasFS now matches per-chip images, C6 picks its own firmware file, and recoverFilesystem() points at cjkas instead of rstrouse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a1622e652d
commit
ab7eae3d94
6 changed files with 59 additions and 20 deletions
|
|
@ -43,7 +43,7 @@ void GitRelease::setReleaseProperty(const char *key, const char *val) {
|
|||
void GitRelease::setAssetProperty(const char *key, const char *val) {
|
||||
if(strcmp(key, "name") == 0) {
|
||||
//Serial.println(val);
|
||||
if(strstr(val, "littlefs.bin")) this->hasFS = true;
|
||||
if(isFsAsset(val)) this->hasFS = true;
|
||||
else if(strstr(val, "ino.esp32.bin")) {
|
||||
if(strlen(this->hwVersions)) strcat(this->hwVersions, ",");
|
||||
strcat(this->hwVersions, "32");
|
||||
|
|
@ -353,22 +353,16 @@ void GitUpdater::emitDownloadProgress(uint8_t num, size_t total, size_t loaded,
|
|||
sockEmit.loop();
|
||||
webServer.loop();
|
||||
}
|
||||
void GitUpdater::setFirmwareFile() {
|
||||
// The chip part of this board's release asset names.
|
||||
static const char *chipName() {
|
||||
esp_chip_info_t ci;
|
||||
esp_chip_info(&ci);
|
||||
switch(ci.model) {
|
||||
case esp_chip_model_t::CHIP_ESP32S3:
|
||||
strcpy(this->currentFile, "SomfyController.ino.esp32s3.bin");
|
||||
break;
|
||||
case esp_chip_model_t::CHIP_ESP32S2:
|
||||
strcpy(this->currentFile, "SomfyController.ino.esp32s2.bin");
|
||||
break;
|
||||
case esp_chip_model_t::CHIP_ESP32C3:
|
||||
strcpy(this->currentFile, "SomfyController.ino.esp32c3.bin");
|
||||
break;
|
||||
default:
|
||||
strcpy(this->currentFile, "SomfyController.ino.esp32.bin");
|
||||
break;
|
||||
case esp_chip_model_t::CHIP_ESP32S3: return "esp32s3";
|
||||
case esp_chip_model_t::CHIP_ESP32S2: return "esp32s2";
|
||||
case esp_chip_model_t::CHIP_ESP32C3: return "esp32c3";
|
||||
case esp_chip_model_t::CHIP_ESP32C6: return "esp32c6";
|
||||
default: return "esp32";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -379,14 +373,14 @@ bool GitUpdater::beginUpdate(const char *version) {
|
|||
|
||||
strcpy(this->targetRelease, version);
|
||||
this->emitUpdateCheck();
|
||||
this->setFirmwareFile();
|
||||
releaseAssetName(this->currentFile, sizeof(this->currentFile), "ino", chipName());
|
||||
this->partition = U_FLASH;
|
||||
this->lockFS = this->cancelled = false;
|
||||
this->error = 0;
|
||||
this->error = this->downloadFile();
|
||||
if(this->error == 0 && !this->cancelled) {
|
||||
somfy.commit();
|
||||
strcpy(this->currentFile, "SomfyController.littlefs.bin");
|
||||
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", chipName());
|
||||
this->partition = U_SPIFFS;
|
||||
this->lockFS = true;
|
||||
this->error = this->downloadFile();
|
||||
|
|
@ -405,8 +399,8 @@ bool GitUpdater::beginUpdate(const char *version) {
|
|||
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");
|
||||
sprintf(this->baseUrl, "https://github.com/cjkas/ESPSomfy-RTS/releases/download/%s/", settings.fwVersion.name);
|
||||
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", chipName());
|
||||
this->status = GIT_UPDATING;
|
||||
this->partition = U_SPIFFS;
|
||||
this->lockFS = true;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ class GitUpdater {
|
|||
bool beginUpdate(const char *release);
|
||||
bool endUpdate();
|
||||
int8_t downloadFile();
|
||||
void setFirmwareFile();
|
||||
void setCurrentRelease(GitRepo &repo);
|
||||
void loop();
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,14 @@ bool worthRoaming(bool connected, int currentRssi, int apRssi, int minGain) {
|
|||
bool otaProven(bool networkUp, unsigned long uptimeMs, unsigned long minUptimeMs) {
|
||||
return networkUp && uptimeMs >= minUptimeMs;
|
||||
}
|
||||
bool releaseAssetName(char *buf, size_t size, const char *kind, const char *chip) {
|
||||
int n = snprintf(buf, size, "SomfyController.%s.%s.bin", kind, chip);
|
||||
return n >= 0 && (size_t)n < size;
|
||||
}
|
||||
bool isFsAsset(const char *name) {
|
||||
size_t len = strlen(name);
|
||||
return strstr(name, ".littlefs.") && len >= 4 && strcmp(name + len - 4, ".bin") == 0;
|
||||
}
|
||||
const char *wifiAuthModeName(uint8_t authMode) {
|
||||
switch(authMode) {
|
||||
case 0: return "OPEN";
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ heap_emit_t heapEmitTarget(uint8_t num, uint32_t sinceLastMs, uint32_t intervalM
|
|||
// update has proven itself: it has run for minUptimeMs and the network is
|
||||
// up. Until then a reset rolls back to the previous firmware.
|
||||
bool otaProven(bool networkUp, unsigned long uptimeMs, unsigned long minUptimeMs);
|
||||
// A release asset's name: "SomfyController.<kind>.<chip>.bin", kind "ino" for
|
||||
// the firmware or "littlefs" for the web UI image, chip e.g. "esp32s3". False
|
||||
// when it doesn't fit in size.
|
||||
bool releaseAssetName(char *buf, size_t size, const char *kind, const char *chip);
|
||||
// Whether a release asset is a LittleFS image, for any chip.
|
||||
bool isFsAsset(const char *name);
|
||||
// How well loop() keeps up: the passes it made per second and its longest
|
||||
// pass, over the window since the last memStatus broadcast. Only the loop
|
||||
// task calls record(), rate(), maxUs() and publish(). publish() closes the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue