refactor: name release assets from the board's chip model

Review follow-up for #72.

- releaseAssetName() takes ConfigSettings::chipModel ("", "s3", "c3", "c6"),
  so GitOTA no longer keeps its own chip switch. C3 keeps its name for when
  the build comes back.
- hasFS is set only when this board's own LittleFS image is in the release.
  isFsAsset() is gone; it also matched the old unsuffixed littlefs.bin, which
  the updater no longer asks for.
- releaseAssetName() returns void: no caller checked the result and every
  name fits currentFile.
- Both manual-upload hints name this board's file.
- KNOWN_ISSUES: the "Main" install can't work, the repo holds no .bin files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-20 21:34:16 +02:00
parent ab7eae3d94
commit 8196bd20e6
6 changed files with 35 additions and 55 deletions

View file

@ -3,7 +3,6 @@
#include <Update.h>
#include <HTTPClient.h>
#include <esp_task_wdt.h>
#include <esp_chip_info.h>
#include "esp_log.h"
#include "ConfigSettings.h"
#include "GitOTA.h"
@ -43,7 +42,9 @@ 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(isFsAsset(val)) this->hasFS = true;
char fsFile[64];
releaseAssetName(fsFile, sizeof(fsFile), "littlefs", settings.chipModel);
if(strcmp(val, fsFile) == 0) this->hasFS = true;
else if(strstr(val, "ino.esp32.bin")) {
if(strlen(this->hwVersions)) strcat(this->hwVersions, ",");
strcat(this->hwVersions, "32");
@ -353,19 +354,6 @@ void GitUpdater::emitDownloadProgress(uint8_t num, size_t total, size_t loaded,
sockEmit.loop();
webServer.loop();
}
// 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: 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";
}
}
bool GitUpdater::beginUpdate(const char *version) {
ESP_LOGI(TAG, "Begin update called...");
if(strcmp(version, "Main") == 0) strcpy(this->baseUrl, "https://raw.githubusercontent.com/cjkas/ESPSomfy-RTS/master/");
@ -373,14 +361,14 @@ bool GitUpdater::beginUpdate(const char *version) {
strcpy(this->targetRelease, version);
this->emitUpdateCheck();
releaseAssetName(this->currentFile, sizeof(this->currentFile), "ino", chipName());
releaseAssetName(this->currentFile, sizeof(this->currentFile), "ino", settings.chipModel);
this->partition = U_FLASH;
this->lockFS = this->cancelled = false;
this->error = 0;
this->error = this->downloadFile();
if(this->error == 0 && !this->cancelled) {
somfy.commit();
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", chipName());
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", settings.chipModel);
this->partition = U_SPIFFS;
this->lockFS = true;
this->error = this->downloadFile();
@ -400,7 +388,7 @@ bool GitUpdater::beginUpdate(const char *version) {
}
bool GitUpdater::recoverFilesystem() {
sprintf(this->baseUrl, "https://github.com/cjkas/ESPSomfy-RTS/releases/download/%s/", settings.fwVersion.name);
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", chipName());
releaseAssetName(this->currentFile, sizeof(this->currentFile), "littlefs", settings.chipModel);
this->status = GIT_UPDATING;
this->partition = U_SPIFFS;
this->lockFS = true;

View file

@ -150,13 +150,8 @@ 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;
void releaseAssetName(char *buf, size_t size, const char *kind, const char *chipModel) {
snprintf(buf, size, "SomfyController.%s.esp32%s.bin", kind, chipModel);
}
const char *wifiAuthModeName(uint8_t authMode) {
switch(authMode) {

View file

@ -86,12 +86,10 @@ 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);
// A release asset's name: "SomfyController.<kind>.esp32<chipModel>.bin", kind
// "ino" for the firmware or "littlefs" for the web UI image, chipModel as in
// ConfigSettings ("" for the ESP32, "s3", "c3", "c6").
void releaseAssetName(char *buf, size_t size, const char *kind, const char *chipModel);
// 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