From 3d45ba59c16de18f954d3e8a8da8f765c6330b5e Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 21:02:39 +0100 Subject: [PATCH 1/6] fix: restore reads the options the web UI ticks The web UI sends the restore options as the form field "data". The param helpers looked up query parameters only, so /restore never saw them and restored the shades alone, since 3.0.0. The helpers now take a form field too. /restore uses an upload once, and drops the file when the options aren't JSON. e2e: test_restore.py, a probe that the field is read and, with --reboot, a settings-only round trip. Co-Authored-By: Claude Opus 5.5 --- src/entryPoints/HttpRoutes.cpp | 7 +++- src/entryPoints/Web.cpp | 13 +++++--- src/entryPoints/WebRoutes.h | 2 +- test/e2e/README.md | 4 +-- test/e2e/conftest.py | 2 +- test/e2e/test_restore.py | 59 ++++++++++++++++++++++++++++++++++ test/e2e/test_routes.py | 23 +++++++------ test/e2e/test_settings.py | 5 +++ 8 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 test/e2e/test_restore.py diff --git a/src/entryPoints/HttpRoutes.cpp b/src/entryPoints/HttpRoutes.cpp index 440bc6e..bac969e 100644 --- a/src/entryPoints/HttpRoutes.cpp +++ b/src/entryPoints/HttpRoutes.cpp @@ -93,7 +93,11 @@ void registerHttpRoutes(AsyncWebServer &server) { server.on(AsyncURIMatcher::exact("/restore"), HTTP_POST, [](AsyncWebServerRequest *request) { - if(webServer.uploadSuccess) { + // An upload is restored once: a later /restore without a file must not + // find this one. + const bool uploaded = webServer.uploadSuccess; + webServer.uploadSuccess = false; + if(uploaded) { restore_options_t opts; if(asyncHasParam(request, "data")) { String dataStr = asyncParam(request, "data"); @@ -101,6 +105,7 @@ void registerHttpRoutes(AsyncWebServer &server) { JsonDocument doc; DeserializationError err = deserializeJson(doc, dataStr); if(err) { + LittleFS.remove("/shades.tmp"); request->send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"JSON parse error\"}"); return; } diff --git a/src/entryPoints/Web.cpp b/src/entryPoints/Web.cpp index 37db532..69c556c 100644 --- a/src/entryPoints/Web.cpp +++ b/src/entryPoints/Web.cpp @@ -143,13 +143,18 @@ bool Web::createAPIToken(const IPAddress ipAddress, char *token) { // ===================================================== // Async API Handlers // ===================================================== -// Helper: get a query param as String, or empty if missing +// The library keeps query parameters and form fields apart, and looks up only +// the first unless asked. /restore's options come as a form field. +static const AsyncWebParameter *queryOrFormParam(AsyncWebServerRequest *request, const char *name) { + const AsyncWebParameter *p = request->getParam(name); + return p ? p : request->getParam(name, true); +} String asyncParam(AsyncWebServerRequest *request, const char *name) { - if(request->hasParam(name)) return request->getParam(name)->value(); - return String(); + const AsyncWebParameter *p = queryOrFormParam(request, name); + return p ? p->value() : String(); } bool asyncHasParam(AsyncWebServerRequest *request, const char *name) { - return request->hasParam(name); + return queryOrFormParam(request, name) != nullptr; } // -- Serialization helpers -- diff --git a/src/entryPoints/WebRoutes.h b/src/entryPoints/WebRoutes.h index a6af497..7e2c815 100644 --- a/src/entryPoints/WebRoutes.h +++ b/src/entryPoints/WebRoutes.h @@ -18,7 +18,7 @@ extern const char _encoding_json[]; // Hands an item to loop(), which owns the shades. When it can't be the // request is answered with the reason and false is returned. bool queueLoopItem(AsyncWebServerRequest *request, const loop_item_t &item); -// A query parameter, or an empty string when it is missing. +// A query parameter or form field, or an empty string when it is missing. String asyncParam(AsyncWebServerRequest *request, const char *name); bool asyncHasParam(AsyncWebServerRequest *request, const char *name); #endif diff --git a/test/e2e/README.md b/test/e2e/README.md index 6e9ed68..f2086f1 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -12,11 +12,11 @@ Runs against a real device on your network, by hand, never in CI. It checks sock | `--password`, `--username` / `--pin` | the credentials of a Secured device | | `--radio --shade ` | also send real commands: that shade moves a little and back | | `--edit` | also add a room and delete it again | -| `--reboot` | also reboot the device and wait for it to come back | +| `--reboot` | also reboot the device and wait for it to come back, and restore the settings from a backup taken a moment before (it changes the NTP server, which the restore puts back) | | `--lockout` | on a Secured device, also fail `/login` until this PC is refused, then wait out the 30 s lockout | | `--record` | save hello, the sync and the schema to `test/fixtures/proto2/`, for the web UI and Home Assistant tests | -A plain run sends nothing on air, changes no setting (it saves only values the device already has) and doesn't reboot the device. The command tests send ops that are refused before they reach the radio, and one `setPositions` that sets a shade to the position the sync gave: that drops the fraction of a percent the shade's believed position may have had. The edit tests send edits that are refused, and one shade sort order set to the order it has, which saves the shades again unchanged. The settings tests send saves that are refused, and one that saves the NTP server and time zone the device already has. The frequency scan test pauses the radio's sending for a second or two, as a scan does. It does fill every socket slot for a few seconds, and replays a page load. +A plain run sends nothing on air, changes no setting (it saves only values the device already has) and doesn't reboot the device. The command tests send ops that are refused before they reach the radio, and one `setPositions` that sets a shade to the position the sync gave: that drops the fraction of a percent the shade's believed position may have had. The edit tests send edits that are refused, and one shade sort order set to the order it has, which saves the shades again unchanged. The settings tests send saves that are refused, and one that saves the NTP server and time zone the device already has. The restore test sends options that aren't JSON with a file that isn't a backup, so nothing is restored. The frequency scan test pauses the radio's sending for a second or two, as a scan does. It does fill every socket slot for a few seconds, and replays a page load. The web UI holds one of the device's 5 socket slots for each open tab, and Home Assistant holds one. The tests that fill every slot fill the ones left, so close the UI's tabs for the full load. diff --git a/test/e2e/conftest.py b/test/e2e/conftest.py index 23e564b..1b47f1e 100644 --- a/test/e2e/conftest.py +++ b/test/e2e/conftest.py @@ -18,7 +18,7 @@ def pytest_addoption(parser): parser.addoption("--radio", action="store_true", help="also run the tests that send commands on air") parser.addoption("--shade", type=int, default=None, help="with --radio: the id of the shade the commands may move") parser.addoption("--edit", action="store_true", help="also run the edits that change the shade model, then undo them") - parser.addoption("--reboot", action="store_true", help="also run the test that reboots the device") + parser.addoption("--reboot", action="store_true", help="also run the tests that reboot the device") parser.addoption("--lockout", action="store_true", help="also run the test that locks this PC out of /login for 30 s") diff --git a/test/e2e/test_restore.py b/test/e2e/test_restore.py new file mode 100644 index 0000000..bfe0445 --- /dev/null +++ b/test/e2e/test_restore.py @@ -0,0 +1,59 @@ +"""/restore and the options the web UI sends with the backup file. + +The round trip restores a backup and reboots the device: pass --reboot. +""" +import json + +import pytest + +from proto_client import run_sync +from test_commands import is_ok, op, synced_model +from test_routes import http, upload +from test_settings import desc, settings, uptime, wait_for_restart + +# Saved for the round trip and put back by the restore. .invalid never resolves. +CHANGED_NTP_SERVER = "restore.e2e.invalid" + + +def auth(token): + return {"apikey": token} if token else {} + + +def test_restore_reads_the_options_sent_as_a_form_field(host, token): + """The options come as the form field "data", next to the file. + + They are read before the file is checked, so options that aren't JSON + are refused, and this file, which isn't a backup, restores nothing + either way. /restore once looked up only query parameters, missed the + field and restored the shades alone, whatever was ticked. + """ + status, _, body = upload(host, "/restore", auth(token), fields={"data": "{"}) + assert status == 500, body + assert json.loads(body)["desc"] == "JSON parse error" + + +def test_a_restore_brings_back_the_parts_that_were_ticked(request, host, token, connect, schema): + if not request.config.getoption("--reboot"): + pytest.skip("restores a backup and reboots the device: pass --reboot") + c = connect(schema=schema.hash) + _, frames, _ = run_sync(c) + uptime_before = uptime(schema, frames) + general = settings(c, schema, "general") + ntp = {name: general.get(name, schema.default(name)) for name in ("ntpServer", "posixZone")} + assert ntp["ntpServer"] != CHANGED_NTP_SERVER + status, _, backup = http(host, "/backup", headers=auth(token)) + assert status == 200 + + reply = op(c, schema, "saveSettings", dict(ntp, ntpServer=CHANGED_NTP_SERVER, section="general")) + assert is_ok(schema, reply), desc(schema, reply) + try: + options = json.dumps({"shades": False, "settings": True}) + status, _, body = upload(host, "/restore", auth(token), content=backup, fields={"data": options}) + assert status == 200, body + wait_for_restart(host, token, schema, uptime_before) + finally: + c, _, _ = synced_model(connect, schema) + restored = settings(c, schema, "general").get("ntpServer", schema.default("ntpServer")) + if restored != ntp["ntpServer"]: + op(c, schema, "saveSettings", dict(ntp, section="general")) + assert restored == ntp["ntpServer"] diff --git a/test/e2e/test_routes.py b/test/e2e/test_routes.py index 9072568..c3e6e36 100644 --- a/test/e2e/test_routes.py +++ b/test/e2e/test_routes.py @@ -38,16 +38,21 @@ def http(host, path, method="GET", body=None, headers=None): return e.code, e.headers, e.read() -def upload(host, path, headers=None, with_file=True): - """Posts a small file that isn't a backup or an image, or a form without a file.""" +def upload(host, path, headers=None, content=b"\0" * 256, fields=None): + """Posts a form as the web UI does: the file, then the fields. + + The file is by default a small one that isn't a backup or an image, and + content=None leaves it out. + """ boundary = "e2e-upload" - if with_file: - part = ( + parts = [] + if content is not None: + parts.append( f"--{boundary}\r\nContent-Disposition: form-data; name=\"file\"; filename=\"e2e.bin\"\r\n" - "Content-Type: application/octet-stream\r\n\r\n").encode() + b"\0" * 256 - else: - part = f"--{boundary}\r\nContent-Disposition: form-data; name=\"e2e\"\r\n\r\n1".encode() - body = part + f"\r\n--{boundary}--\r\n".encode() + "Content-Type: application/octet-stream\r\n\r\n".encode() + content) + for name, value in (fields or {}).items(): + parts.append(f"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"\r\n\r\n{value}".encode()) + body = b"\r\n".join(parts) + f"\r\n--{boundary}--\r\n".encode() return http(host, path, "POST", body, {"Content-Type": f"multipart/form-data; boundary={boundary}", **(headers or {})}) @@ -104,7 +109,7 @@ def test_secured_refuses_an_upload_without_a_token(host, secured, path): def restore_without_a_file(host, token): - status, _, body = upload(host, "/restore", {"apikey": token}, with_file=False) + status, _, body = upload(host, "/restore", {"apikey": token}, content=None, fields={"e2e": "1"}) return status, json.loads(body or b"{}").get("desc", "") diff --git a/test/e2e/test_settings.py b/test/e2e/test_settings.py index 414cdeb..45d23f9 100644 --- a/test/e2e/test_settings.py +++ b/test/e2e/test_settings.py @@ -123,6 +123,11 @@ def test_reboot(request, host, token, connect, schema): uptime_before = uptime(schema, frames) assert is_ok(schema, op(c, schema, "reboot", {})) assert c.closed.wait(15), "the socket stayed open" + wait_for_restart(host, token, schema, uptime_before) + + +def wait_for_restart(host, token, schema, uptime_before): + """Waits until the device is back, and checks it restarted.""" # The device closes its sockets just before it restarts, and may still # take a connection in between: that one never gets its hello. time.sleep(3) From d968f7e70c571951bfe467136b8af7268d632c4f Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 21:10:47 +0100 Subject: [PATCH 2/6] fix: review fixes for the restore fix - A restore of the repeaters alone saves them before the reboot, instead of leaving that to somfy.loop(). - e2e: a refused restore leaves no upload behind, tested on its own. - e2e: auth() sits next to upload(), whose file part is now file=. Co-Authored-By: Claude Opus 5.5 --- src/ConfigFile.cpp | 4 +++- test/e2e/test_restore.py | 17 +++++++++++------ test/e2e/test_routes.py | 17 +++++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/ConfigFile.cpp b/src/ConfigFile.cpp index 2d606e4..e7854ca 100644 --- a/src/ConfigFile.cpp +++ b/src/ConfigFile.cpp @@ -608,7 +608,9 @@ bool ShadeConfigFile::restoreFile(SomfyShadeController *s, const char *filename, else { this->file.seek(this->file.position() + this->header.netRecordSize, SeekSet); } - if(opts.shades) s->commit(); + // The repeaters are saved in shades.cfg too. Left to somfy.loop(), they + // race the reboot. + if(opts.shades || opts.repeaters) s->commit(); if(opts.transceiver) { // Read into a copy so the radio task never transmits on a half restored config. diff --git a/test/e2e/test_restore.py b/test/e2e/test_restore.py index bfe0445..e4b1e25 100644 --- a/test/e2e/test_restore.py +++ b/test/e2e/test_restore.py @@ -8,17 +8,13 @@ import pytest from proto_client import run_sync from test_commands import is_ok, op, synced_model -from test_routes import http, upload +from test_routes import auth, http, restore_without_a_file, upload from test_settings import desc, settings, uptime, wait_for_restart # Saved for the round trip and put back by the restore. .invalid never resolves. CHANGED_NTP_SERVER = "restore.e2e.invalid" -def auth(token): - return {"apikey": token} if token else {} - - def test_restore_reads_the_options_sent_as_a_form_field(host, token): """The options come as the form field "data", next to the file. @@ -32,6 +28,15 @@ def test_restore_reads_the_options_sent_as_a_form_field(host, token): assert json.loads(body)["desc"] == "JSON parse error" +def test_a_refused_restore_leaves_no_upload_behind(host, token): + """A later /restore without a file must not find the refused one's upload.""" + status, _, _ = upload(host, "/restore", auth(token), fields={"data": "{"}) + assert status == 500 + status, reason = restore_without_a_file(host, token) + assert status == 400 + assert "didn't complete" in reason, reason + + def test_a_restore_brings_back_the_parts_that_were_ticked(request, host, token, connect, schema): if not request.config.getoption("--reboot"): pytest.skip("restores a backup and reboots the device: pass --reboot") @@ -48,7 +53,7 @@ def test_a_restore_brings_back_the_parts_that_were_ticked(request, host, token, assert is_ok(schema, reply), desc(schema, reply) try: options = json.dumps({"shades": False, "settings": True}) - status, _, body = upload(host, "/restore", auth(token), content=backup, fields={"data": options}) + status, _, body = upload(host, "/restore", auth(token), file=backup, fields={"data": options}) assert status == 200, body wait_for_restart(host, token, schema, uptime_before) finally: diff --git a/test/e2e/test_routes.py b/test/e2e/test_routes.py index c3e6e36..8bf4859 100644 --- a/test/e2e/test_routes.py +++ b/test/e2e/test_routes.py @@ -38,18 +38,23 @@ def http(host, path, method="GET", body=None, headers=None): return e.code, e.headers, e.read() -def upload(host, path, headers=None, content=b"\0" * 256, fields=None): +def auth(token): + """The header that carries the token, if there is one.""" + return {"apikey": token} if token else {} + + +def upload(host, path, headers=None, file=b"\0" * 256, fields=None): """Posts a form as the web UI does: the file, then the fields. The file is by default a small one that isn't a backup or an image, and - content=None leaves it out. + file=None leaves it out. """ boundary = "e2e-upload" parts = [] - if content is not None: + if file is not None: parts.append( f"--{boundary}\r\nContent-Disposition: form-data; name=\"file\"; filename=\"e2e.bin\"\r\n" - "Content-Type: application/octet-stream\r\n\r\n".encode() + content) + "Content-Type: application/octet-stream\r\n\r\n".encode() + file) for name, value in (fields or {}).items(): parts.append(f"--{boundary}\r\nContent-Disposition: form-data; name=\"{name}\"\r\n\r\n{value}".encode()) body = b"\r\n".join(parts) + f"\r\n--{boundary}--\r\n".encode() @@ -95,7 +100,7 @@ def test_secured_refuses_a_web_asset_name_below_a_route(host, secured, method, p def test_secured_accepts_the_token_on_a_route(host, secured, token): if not secured: pytest.skip("the device's security is None") - status, _, _ = http(host, "/backup", headers={"apikey": token}) + status, _, _ = http(host, "/backup", headers=auth(token)) assert status == 200 @@ -109,7 +114,7 @@ def test_secured_refuses_an_upload_without_a_token(host, secured, path): def restore_without_a_file(host, token): - status, _, body = upload(host, "/restore", {"apikey": token}, content=None, fields={"e2e": "1"}) + status, _, body = upload(host, "/restore", auth(token), file=None, fields={"e2e": "1"}) return status, json.loads(body or b"{}").get("desc", "") From 51e15f341e1f036ef5b7cee59a0e5d1dfd09acbf Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 21:19:22 +0100 Subject: [PATCH 3/6] fix: refuse a restore with no part chosen It rebooted the device and restored nothing. Co-Authored-By: Claude Opus 5.5 --- src/entryPoints/HttpRoutes.cpp | 9 ++++++++- test/e2e/test_restore.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/entryPoints/HttpRoutes.cpp b/src/entryPoints/HttpRoutes.cpp index bac969e..14f1bac 100644 --- a/src/entryPoints/HttpRoutes.cpp +++ b/src/entryPoints/HttpRoutes.cpp @@ -118,6 +118,13 @@ void registerHttpRoutes(AsyncWebServer &server) { ESP_LOGD(TAG, "No restore options sent. Using defaults..."); opts.shades = true; } + // Otherwise the device would reboot having restored nothing. + const uint8_t parts = restoreParts(opts); + if(parts == 0) { + LittleFS.remove("/shades.tmp"); + request->send(400, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"No part of the backup was chosen, so nothing was restored.\"}")); + return; + } // Checked here so the client hears about a bad file. It only reads // the file; the shades are still changed on loop() alone. if(!ShadeConfigFile::validateFile("/shades.tmp")) { @@ -129,7 +136,7 @@ void registerHttpRoutes(AsyncWebServer &server) { // codes, and then reboots. loop_item_t item; item.type = loop_item_type_t::restore_shades; - item.restoreParts = restoreParts(opts); + item.restoreParts = parts; if(!queueLoopItem(request, item)) return; request->send(200, _encoding_json, "{\"status\":\"Success\",\"desc\":\"Restoring Shade settings\"}"); } diff --git a/test/e2e/test_restore.py b/test/e2e/test_restore.py index e4b1e25..96593b7 100644 --- a/test/e2e/test_restore.py +++ b/test/e2e/test_restore.py @@ -28,6 +28,14 @@ def test_restore_reads_the_options_sent_as_a_form_field(host, token): assert json.loads(body)["desc"] == "JSON parse error" +def test_a_restore_with_no_part_chosen_is_refused(host, token): + """Checked before the file, so this file, which isn't a backup, restores nothing either way.""" + options = json.dumps({"shades": False}) + status, _, body = upload(host, "/restore", auth(token), fields={"data": options}) + assert status == 400, body + assert json.loads(body)["desc"] == "No part of the backup was chosen, so nothing was restored." + + def test_a_refused_restore_leaves_no_upload_behind(host, token): """A later /restore without a file must not find the refused one's upload.""" status, _, _ = upload(host, "/restore", auth(token), fields={"data": "{"}) From 5721d34a3496c4e1b43d1aaa9e4b012a71ec22e8 Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 22:06:26 +0100 Subject: [PATCH 4/6] feat: say when the firmware is flashed over USB Builds with one app slot (C6, debug, and the C5 to come) have nowhere for /updateFirmware to write. It answered "Error updating firmware: " and rebooted. - ConfigSettings::otaSlot, from esp_ota_get_next_update_partition(). - The header sends otaSlot, default 1, so only those builds send it. - /updateFirmware refuses with 400 and a reason, and doesn't stop the radio or reboot. - The web UI's Update Firmware says to flash the onboard image over USB, with a backup first. Firmware before the field leaves it undefined, which keeps the uploader. Co-Authored-By: Claude Opus 5.5 --- data-src/index.js | 7 ++++++- data-src/js/model.js | 2 +- docs/PROTOCOL.md | 2 +- src/ConfigSettings.cpp | 2 ++ src/ConfigSettings.h | 3 +++ src/ProtoSchema.h | 1 + src/entryPoints/HttpRoutes.cpp | 7 ++++++- src/outputs/ProtoSocket.cpp | 1 + test/e2e/test_routes.py | 22 +++++++++++++++++++++- test/js/model.test.js | 13 +++++++++++++ 10 files changed, 55 insertions(+), 5 deletions(-) diff --git a/data-src/index.js b/data-src/index.js index 0c3b735..c7a3f3c 100644 --- a/data-src/index.js +++ b/data-src/index.js @@ -4169,9 +4169,14 @@ class Firmware { div.style.display = ''; } updateFirmware() { + let chip = document.getElementById('divContainer').getAttribute('data-chipmodel') || ''; + // Firmware from before the field leaves it out: undefined, not false. + if (proto.model.header.otaSlot === false) { + ui.infoMessage(`This device has no OTA slot, so its firmware is flashed over USB with SomfyController.onboard.esp32${chip}.bin. That image holds the web UI and an empty configuration too, so take a backup first and restore it afterwards.`); + return; + } let div = this.createFileUploader('/updateFirmware'); let inst = div.querySelector('div[id=divInstText]'); - let chip = document.getElementById('divContainer').getAttribute('data-chipmodel') || ''; let html = `
Select a binary file [SomfyController.ino.esp32${chip}.bin] containing the device firmware then press the Upload File button.
`; if (this.isMobile()) { html += `
WARNING
`; diff --git a/data-src/js/model.js b/data-src/js/model.js index 2411996..df80ea1 100644 --- a/data-src/js/model.js +++ b/data-src/js/model.js @@ -140,7 +140,7 @@ ProtoModel.ITEMS = [ // have it. ProtoModel.FIELDS = { header: ['maxRooms', 'maxShades', 'maxGroups', 'maxGroupedShades', 'maxLinkedRemotes', 'startingAddress', 'bitLength', - 'proto', 'serverId', 'hostname', 'model', 'chipModel', 'fw', 'connType'], + 'proto', 'serverId', 'hostname', 'model', 'chipModel', 'otaSlot', 'fw', 'connType'], room: ['roomId', 'name', 'sortOrder'], shadeState: ['shadeId', 'position', 'target', 'direction', 'myPos', 'tiltPosition', 'tiltTarget', 'tiltDirection', 'myTiltPos', 'flags', 'lastRollingCode'], diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 1937f23..3e5d18d 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -53,7 +53,7 @@ A number is never reused. A retired type stays reserved. - `F`: fields, as `[key, name, kind, default]`, kind being `b` bool, `i` integer, `n` number, `s` string, `l` list, `o` object - `E`: error codes, as `[number, name]` - `Q`: feeds, as `[number, name]` -3. Then the device: `header` (limits, starting address, what a new shade gets, server id, hostname, model, chip, firmware, connection type), `rooms`, `shades`, `groups`, `repeaters` and `status` (memory, and WiFi or Ethernet). A frame is at most 4 KB, an item is never split across frames, and several sections can share one. +3. Then the device: `header` (limits, starting address, what a new shade gets, server id, hostname, model, chip, whether it has an OTA slot (`otaSlot`, left out when it has), firmware, connection type), `rooms`, `shades`, `groups`, `repeaters` and `status` (memory, and WiFi or Ethernet). A frame is at most 4 KB, an item is never split across frames, and several sections can share one. 4. The client sends `next` after each `sync` frame, and the device answers with the following one. With no `next` for 30 s the device closes the socket. 5. `syncEnd` follows the last `sync` frame. diff --git a/src/ConfigSettings.cpp b/src/ConfigSettings.cpp index 42def2d..3424e66 100644 --- a/src/ConfigSettings.cpp +++ b/src/ConfigSettings.cpp @@ -7,6 +7,7 @@ #include "Utils.h" #include "Secrets.h" #include "esp_chip_info.h" +#include "esp_ota_ops.h" #include "esp_log.h" static const char *TAG = "Config"; @@ -144,6 +145,7 @@ bool ConfigSettings::begin() { break; } ESP_LOGD(TAG, "Chip Model ESP32-%s", this->chipModel); + this->otaSlot = esp_ota_get_next_update_partition(nullptr) != nullptr; this->fwVersion.parse(FW_VERSION); uint64_t mac = ESP.getEfuseMac(); for(int i=0; i<17; i=i+8) { diff --git a/src/ConfigSettings.h b/src/ConfigSettings.h index 043ebe4..1aa5946 100644 --- a/src/ConfigSettings.h +++ b/src/ConfigSettings.h @@ -163,6 +163,9 @@ class ConfigSettings: BaseSettings { char serverId[10] = ""; char hostname[32] = "ESPSomfyRTS"; char chipModel[10] = "ESP32"; + // Whether the partition table has a second app slot for /updateFirmware + // to write. Builds with one 3 MB slot (C5, C6, debug) are flashed over USB. + bool otaSlot = true; conn_types_t connType = conn_types_t::unset; appver_t fwVersion; appver_t appVersion; diff --git a/src/ProtoSchema.h b/src/ProtoSchema.h index dc5a853..a46644e 100644 --- a/src/ProtoSchema.h +++ b/src/ProtoSchema.h @@ -169,6 +169,7 @@ FIELD(hostname, "hn", 's', 0) \ FIELD(model, "md", 's', 0) \ FIELD(chipModel, "cp", 's', 0) \ + FIELD(otaSlot, "os", 'b', 1) \ FIELD(connType, "ct", 's', 0) \ /* memory, wifi and ethernet */ \ FIELD(freeHeap, "fr", 'i', 0) \ diff --git a/src/entryPoints/HttpRoutes.cpp b/src/entryPoints/HttpRoutes.cpp index 14f1bac..5379de4 100644 --- a/src/entryPoints/HttpRoutes.cpp +++ b/src/entryPoints/HttpRoutes.cpp @@ -164,6 +164,11 @@ void registerHttpRoutes(AsyncWebServer &server) { // updateFirmware - file upload server.on(AsyncURIMatcher::exact("/updateFirmware"), HTTP_POST, [](AsyncWebServerRequest *request) { + // Nothing was written or stopped, so there is nothing to reboot for. + if(!settings.otaSlot) { + request->send(400, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"This device has no OTA slot, so its firmware is flashed over USB.\"}")); + return; + } if(Update.hasError()) request->send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: \"}"); else @@ -172,7 +177,7 @@ void registerHttpRoutes(AsyncWebServer &server) { rebootDelay.rebootTime = millis() + 500; }, [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - if(!uploadAllowed(request, index)) return; + if(!uploadAllowed(request, index) || !settings.otaSlot) return; if(index == 0) { webServer.uploadSuccess = false; ESP_LOGI(TAG, "Update: %s", filename.c_str()); diff --git a/src/outputs/ProtoSocket.cpp b/src/outputs/ProtoSocket.cpp index 81c5533..9c381e8 100644 --- a/src/outputs/ProtoSocket.cpp +++ b/src/outputs/ProtoSocket.cpp @@ -77,6 +77,7 @@ static void writeHeader(ProtoWriter &w) { w.add(proto_field_t::hostname, settings.hostname); w.add(proto_field_t::model, "ESPSomfyRTS"); w.add(proto_field_t::chipModel, settings.chipModel); + w.add(proto_field_t::otaSlot, settings.otaSlot); w.add(proto_field_t::fw, settings.fwVersion.name); w.add(proto_field_t::connType, net.connTypeName()); } diff --git a/test/e2e/test_routes.py b/test/e2e/test_routes.py index 8bf4859..d6df206 100644 --- a/test/e2e/test_routes.py +++ b/test/e2e/test_routes.py @@ -11,7 +11,8 @@ import urllib.request import pytest -from proto_client import ProtoClient +from proto_client import ProtoClient, run_sync +from test_settings import uptime # Every route that needs the token under Secured, sent without a body or # parameters, so a route that let one through would still change nothing. @@ -169,3 +170,22 @@ def test_a_socket_from_the_page_the_device_served_is_accepted(host, token): c.close() # The device frees the slot when it sees the disconnect. time.sleep(0.5) + + +def test_a_firmware_upload_without_an_ota_slot_is_refused(host, token, connect, schema): + """Builds with one app slot (C5, C6, debug) say so in the header, and + refuse the upload without stopping the radio or rebooting.""" + c = connect(schema=schema.hash) + _, frames, _ = run_sync(c) + key = schema.keys["header"] + header = next(schema.expand(f["d"][key]) for f in frames if key in f["d"]) + if header.get("otaSlot", schema.default("otaSlot")): + pytest.skip("the device has an OTA slot: an upload would start an update") + uptime_before = uptime(schema, frames) + status, _, body = upload(host, "/updateFirmware", auth(token)) + assert status == 400, body + assert json.loads(body)["desc"] == "This device has no OTA slot, so its firmware is flashed over USB." + # The old reply rebooted half a second later. + time.sleep(2) + _, frames, _ = run_sync(connect(schema=schema.hash)) + assert uptime(schema, frames) > uptime_before, "the device restarted" diff --git a/test/js/model.test.js b/test/js/model.test.js index 3d8cd4e..d48fadb 100644 --- a/test/js/model.test.js +++ b/test/js/model.test.js @@ -37,6 +37,19 @@ test('a field the sync left out is its default', () => { for (const g of m.groupList()) assert.ok(Array.isArray(g.linkedShades)); }); +test('otaSlot is false only when the device says so', () => { + // The recording is from firmware before the field. + assert.equal(synced().header.otaSlot, undefined); + const schema = recordedSchema(); + schema.add({ F: [['os', 'otaSlot', 'b', 1]] }); + const header = deviceSections(schema).find((d) => d.header).header; + const m = new ProtoModel(schema); + m.applySync({ header: header }); + assert.equal(m.header.otaSlot, true); + m.applySync({ header: schema.expand(Object.assign({ os: 0 }, schema.pack(header))) }); + assert.equal(m.header.otaSlot, false); +}); + test('the lists come in their sort order', () => { const m = synced(); const orders = m.shadeList().map((s) => s.sortOrder); From 657b345eafbf0aea6b9468cfa367650f95c5b987 Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 22:19:27 +0100 Subject: [PATCH 5/6] fix: review fixes for the OTA slot - The field is hasOtaSlot, like hasEthernet and the other "has" bools. - The web UI shows the device's reason for any failed upload, not only for /restore, so it shows "no OTA slot" from a page that missed the header. The update routes' 500 replies give Update.errorString() instead of an empty reason. - Native: the writer leaves hasOtaSlot out when true and writes "os":0. - e2e: header() next to uptime(); the test skips on firmware without the field instead of failing, and matches the reason loosely. The README says what the test sends. - PROTOCOL.md and the comments name only the builds that exist. Co-Authored-By: Claude Opus 5.5 --- data-src/index.js | 15 ++++++--------- data-src/js/model.js | 2 +- docs/PROTOCOL.md | 2 +- src/ConfigSettings.cpp | 2 +- src/ConfigSettings.h | 4 ++-- src/ProtoSchema.h | 2 +- src/entryPoints/HttpRoutes.cpp | 9 +++++---- src/outputs/ProtoSocket.cpp | 2 +- test/e2e/README.md | 2 +- test/e2e/test_routes.py | 16 +++++++--------- test/e2e/test_settings.py | 9 +++++++-- test/js/model.test.js | 10 +++++----- test/test_proto/test_proto.cpp | 4 +++- 13 files changed, 41 insertions(+), 38 deletions(-) diff --git a/data-src/index.js b/data-src/index.js index c7a3f3c..a7a6dc3 100644 --- a/data-src/index.js +++ b/data-src/index.js @@ -4171,7 +4171,7 @@ class Firmware { updateFirmware() { let chip = document.getElementById('divContainer').getAttribute('data-chipmodel') || ''; // Firmware from before the field leaves it out: undefined, not false. - if (proto.model.header.otaSlot === false) { + if (proto.model.header.hasOtaSlot === false) { ui.infoMessage(`This device has no OTA slot, so its firmware is flashed over USB with SomfyController.onboard.esp32${chip}.bin. That image holds the web UI and an empty configuration too, so take a backup first and restore it afterwards.`); return; } @@ -4307,18 +4307,15 @@ class Firmware { security.tokenRefused(); return; } - if (service !== '/restore' && (xhr.status < 200 || xhr.status >= 300)) { - ui.errorMessage(el, `The upload failed (${xhr.status}).`); + if (xhr.status < 200 || xhr.status >= 300) { + // The device's reason, when it sent one. + let desc = `The upload failed (${xhr.status}).`; + try { desc = JSON.parse(xhr.responseText).desc || desc; } catch (e) { } + ui.errorMessage(el, desc); return; } switch (service) { case '/restore': - if (xhr.status < 200 || xhr.status >= 300) { - let desc = 'The restore failed.'; - try { desc = JSON.parse(xhr.responseText).desc || desc; } catch (e) { } - ui.errorMessage(el, desc); - break; - } (async () => { await somfy.init(); if (document.getElementById('divUploadFile')) document.getElementById('divUploadFile').remove(); diff --git a/data-src/js/model.js b/data-src/js/model.js index df80ea1..b23c370 100644 --- a/data-src/js/model.js +++ b/data-src/js/model.js @@ -140,7 +140,7 @@ ProtoModel.ITEMS = [ // have it. ProtoModel.FIELDS = { header: ['maxRooms', 'maxShades', 'maxGroups', 'maxGroupedShades', 'maxLinkedRemotes', 'startingAddress', 'bitLength', - 'proto', 'serverId', 'hostname', 'model', 'chipModel', 'otaSlot', 'fw', 'connType'], + 'proto', 'serverId', 'hostname', 'model', 'chipModel', 'hasOtaSlot', 'fw', 'connType'], room: ['roomId', 'name', 'sortOrder'], shadeState: ['shadeId', 'position', 'target', 'direction', 'myPos', 'tiltPosition', 'tiltTarget', 'tiltDirection', 'myTiltPos', 'flags', 'lastRollingCode'], diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 3e5d18d..0f27463 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -53,7 +53,7 @@ A number is never reused. A retired type stays reserved. - `F`: fields, as `[key, name, kind, default]`, kind being `b` bool, `i` integer, `n` number, `s` string, `l` list, `o` object - `E`: error codes, as `[number, name]` - `Q`: feeds, as `[number, name]` -3. Then the device: `header` (limits, starting address, what a new shade gets, server id, hostname, model, chip, whether it has an OTA slot (`otaSlot`, left out when it has), firmware, connection type), `rooms`, `shades`, `groups`, `repeaters` and `status` (memory, and WiFi or Ethernet). A frame is at most 4 KB, an item is never split across frames, and several sections can share one. +3. Then the device: `header` (limits, starting address, what a new shade gets, server id, hostname, model, chip, whether it has an OTA slot, firmware, connection type), `rooms`, `shades`, `groups`, `repeaters` and `status` (memory, and WiFi or Ethernet). A frame is at most 4 KB, an item is never split across frames, and several sections can share one. 4. The client sends `next` after each `sync` frame, and the device answers with the following one. With no `next` for 30 s the device closes the socket. 5. `syncEnd` follows the last `sync` frame. diff --git a/src/ConfigSettings.cpp b/src/ConfigSettings.cpp index 3424e66..8b23346 100644 --- a/src/ConfigSettings.cpp +++ b/src/ConfigSettings.cpp @@ -145,7 +145,7 @@ bool ConfigSettings::begin() { break; } ESP_LOGD(TAG, "Chip Model ESP32-%s", this->chipModel); - this->otaSlot = esp_ota_get_next_update_partition(nullptr) != nullptr; + this->hasOtaSlot = esp_ota_get_next_update_partition(nullptr) != nullptr; this->fwVersion.parse(FW_VERSION); uint64_t mac = ESP.getEfuseMac(); for(int i=0; i<17; i=i+8) { diff --git a/src/ConfigSettings.h b/src/ConfigSettings.h index 1aa5946..81c5838 100644 --- a/src/ConfigSettings.h +++ b/src/ConfigSettings.h @@ -164,8 +164,8 @@ class ConfigSettings: BaseSettings { char hostname[32] = "ESPSomfyRTS"; char chipModel[10] = "ESP32"; // Whether the partition table has a second app slot for /updateFirmware - // to write. Builds with one 3 MB slot (C5, C6, debug) are flashed over USB. - bool otaSlot = true; + // to write. Builds with one 3 MB slot (C6, debug) are flashed over USB. + bool hasOtaSlot = true; conn_types_t connType = conn_types_t::unset; appver_t fwVersion; appver_t appVersion; diff --git a/src/ProtoSchema.h b/src/ProtoSchema.h index a46644e..85ae094 100644 --- a/src/ProtoSchema.h +++ b/src/ProtoSchema.h @@ -169,7 +169,7 @@ FIELD(hostname, "hn", 's', 0) \ FIELD(model, "md", 's', 0) \ FIELD(chipModel, "cp", 's', 0) \ - FIELD(otaSlot, "os", 'b', 1) \ + FIELD(hasOtaSlot, "os", 'b', 1) \ FIELD(connType, "ct", 's', 0) \ /* memory, wifi and ethernet */ \ FIELD(freeHeap, "fr", 'i', 0) \ diff --git a/src/entryPoints/HttpRoutes.cpp b/src/entryPoints/HttpRoutes.cpp index 5379de4..2e2e21d 100644 --- a/src/entryPoints/HttpRoutes.cpp +++ b/src/entryPoints/HttpRoutes.cpp @@ -165,19 +165,20 @@ void registerHttpRoutes(AsyncWebServer &server) { server.on(AsyncURIMatcher::exact("/updateFirmware"), HTTP_POST, [](AsyncWebServerRequest *request) { // Nothing was written or stopped, so there is nothing to reboot for. - if(!settings.otaSlot) { + if(!settings.hasOtaSlot) { request->send(400, _encoding_json, F("{\"status\":\"ERROR\",\"desc\":\"This device has no OTA slot, so its firmware is flashed over USB.\"}")); return; } + // errorString() is one of the updater's fixed messages, none with a quote. if(Update.hasError()) - request->send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: \"}"); + request->send(500, _encoding_json, String("{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: ") + Update.errorString() + "\"}"); else request->send(200, _encoding_json, "{\"status\":\"SUCCESS\",\"desc\":\"Successfully updated firmware\"}"); rebootDelay.reboot = true; rebootDelay.rebootTime = millis() + 500; }, [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - if(!uploadAllowed(request, index) || !settings.otaSlot) return; + if(!uploadAllowed(request, index) || !settings.hasOtaSlot) return; if(index == 0) { webServer.uploadSuccess = false; ESP_LOGI(TAG, "Update: %s", filename.c_str()); @@ -212,7 +213,7 @@ void registerHttpRoutes(AsyncWebServer &server) { server.on(AsyncURIMatcher::exact("/updateApplication"), HTTP_POST, [](AsyncWebServerRequest *request) { if(Update.hasError()) - request->send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating application: \"}"); + request->send(500, _encoding_json, String("{\"status\":\"ERROR\",\"desc\":\"Error updating application: ") + Update.errorString() + "\"}"); else request->send(200, _encoding_json, "{\"status\":\"SUCCESS\",\"desc\":\"Successfully updated application\"}"); rebootDelay.reboot = true; diff --git a/src/outputs/ProtoSocket.cpp b/src/outputs/ProtoSocket.cpp index 9c381e8..8a979cd 100644 --- a/src/outputs/ProtoSocket.cpp +++ b/src/outputs/ProtoSocket.cpp @@ -77,7 +77,7 @@ static void writeHeader(ProtoWriter &w) { w.add(proto_field_t::hostname, settings.hostname); w.add(proto_field_t::model, "ESPSomfyRTS"); w.add(proto_field_t::chipModel, settings.chipModel); - w.add(proto_field_t::otaSlot, settings.otaSlot); + w.add(proto_field_t::hasOtaSlot, settings.hasOtaSlot); w.add(proto_field_t::fw, settings.fwVersion.name); w.add(proto_field_t::connType, net.connTypeName()); } diff --git a/test/e2e/README.md b/test/e2e/README.md index f2086f1..1467e54 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -16,7 +16,7 @@ Runs against a real device on your network, by hand, never in CI. It checks sock | `--lockout` | on a Secured device, also fail `/login` until this PC is refused, then wait out the 30 s lockout | | `--record` | save hello, the sync and the schema to `test/fixtures/proto2/`, for the web UI and Home Assistant tests | -A plain run sends nothing on air, changes no setting (it saves only values the device already has) and doesn't reboot the device. The command tests send ops that are refused before they reach the radio, and one `setPositions` that sets a shade to the position the sync gave: that drops the fraction of a percent the shade's believed position may have had. The edit tests send edits that are refused, and one shade sort order set to the order it has, which saves the shades again unchanged. The settings tests send saves that are refused, and one that saves the NTP server and time zone the device already has. The restore test sends options that aren't JSON with a file that isn't a backup, so nothing is restored. The frequency scan test pauses the radio's sending for a second or two, as a scan does. It does fill every socket slot for a few seconds, and replays a page load. +A plain run sends nothing on air, changes no setting (it saves only values the device already has) and doesn't reboot the device. The command tests send ops that are refused before they reach the radio, and one `setPositions` that sets a shade to the position the sync gave: that drops the fraction of a percent the shade's believed position may have had. The edit tests send edits that are refused, and one shade sort order set to the order it has, which saves the shades again unchanged. The settings tests send saves that are refused, and one that saves the NTP server and time zone the device already has. The restore test sends options that aren't JSON with a file that isn't a backup, so nothing is restored. A firmware upload goes only to a device without an OTA slot, which refuses it. The frequency scan test pauses the radio's sending for a second or two, as a scan does. It does fill every socket slot for a few seconds, and replays a page load. The web UI holds one of the device's 5 socket slots for each open tab, and Home Assistant holds one. The tests that fill every slot fill the ones left, so close the UI's tabs for the full load. diff --git a/test/e2e/test_routes.py b/test/e2e/test_routes.py index d6df206..a992284 100644 --- a/test/e2e/test_routes.py +++ b/test/e2e/test_routes.py @@ -12,7 +12,7 @@ import urllib.request import pytest from proto_client import ProtoClient, run_sync -from test_settings import uptime +from test_settings import header, uptime # Every route that needs the token under Secured, sent without a body or # parameters, so a route that let one through would still change nothing. @@ -173,18 +173,16 @@ def test_a_socket_from_the_page_the_device_served_is_accepted(host, token): def test_a_firmware_upload_without_an_ota_slot_is_refused(host, token, connect, schema): - """Builds with one app slot (C5, C6, debug) say so in the header, and - refuse the upload without stopping the radio or rebooting.""" - c = connect(schema=schema.hash) - _, frames, _ = run_sync(c) - key = schema.keys["header"] - header = next(schema.expand(f["d"][key]) for f in frames if key in f["d"]) - if header.get("otaSlot", schema.default("otaSlot")): + """Builds with one app slot (C6, debug) say so in the header, and refuse + the upload without stopping the radio or rebooting.""" + _, frames, _ = run_sync(connect(schema=schema.hash)) + # Left out at its default, true, as is a field older firmware doesn't have. + if header(schema, frames).get("hasOtaSlot", True): pytest.skip("the device has an OTA slot: an upload would start an update") uptime_before = uptime(schema, frames) status, _, body = upload(host, "/updateFirmware", auth(token)) assert status == 400, body - assert json.loads(body)["desc"] == "This device has no OTA slot, so its firmware is flashed over USB." + assert "no OTA slot" in json.loads(body)["desc"] # The old reply rebooted half a second later. time.sleep(2) _, frames, _ = run_sync(connect(schema=schema.hash)) diff --git a/test/e2e/test_settings.py b/test/e2e/test_settings.py index 45d23f9..7f06154 100644 --- a/test/e2e/test_settings.py +++ b/test/e2e/test_settings.py @@ -86,9 +86,8 @@ def test_a_save_tells_the_other_clients(connect, schema): def test_a_wifi_scan_lists_the_networks(connect, schema): c = connect(schema=schema.hash) _, frames, _ = run_sync(c) - header = next(schema.expand(f["d"][schema.keys["header"]]) for f in frames if schema.keys["header"] in f["d"]) # The connection in use: Ethernet with WiFi as the fallback may be on either. - if header.get("connType") != "Wifi": + if header(schema, frames).get("connType") != "Wifi": pytest.skip("the device isn't on WiFi") assert is_ok(schema, op(c, schema, "scanWifi", {})) found = c.recv_until(lambda f: f["t"] == schema.type_numbers["wifiNetworks"], timeout=20)[-1] @@ -152,6 +151,12 @@ def wait_for_restart(host, token, schema, uptime_before): time.sleep(2) +def header(schema, frames): + """The header a sync starts with.""" + key = schema.keys["header"] + return next(schema.expand(f["d"][key]) for f in frames if key in f["d"]) + + def uptime(schema, frames): """The uptime, in ms, from the status a sync ends with.""" key = schema.keys["status"] diff --git a/test/js/model.test.js b/test/js/model.test.js index d48fadb..cf58bad 100644 --- a/test/js/model.test.js +++ b/test/js/model.test.js @@ -37,17 +37,17 @@ test('a field the sync left out is its default', () => { for (const g of m.groupList()) assert.ok(Array.isArray(g.linkedShades)); }); -test('otaSlot is false only when the device says so', () => { +test('the device has an OTA slot unless it says it has none', () => { // The recording is from firmware before the field. - assert.equal(synced().header.otaSlot, undefined); + assert.equal(synced().header.hasOtaSlot, undefined); const schema = recordedSchema(); - schema.add({ F: [['os', 'otaSlot', 'b', 1]] }); + schema.add({ F: [['os', 'hasOtaSlot', 'b', 1]] }); const header = deviceSections(schema).find((d) => d.header).header; const m = new ProtoModel(schema); m.applySync({ header: header }); - assert.equal(m.header.otaSlot, true); + assert.equal(m.header.hasOtaSlot, true); m.applySync({ header: schema.expand(Object.assign({ os: 0 }, schema.pack(header))) }); - assert.equal(m.header.otaSlot, false); + assert.equal(m.header.hasOtaSlot, false); }); test('the lists come in their sort order', () => { diff --git a/test/test_proto/test_proto.cpp b/test/test_proto/test_proto.cpp index 17f2259..f548966 100644 --- a/test/test_proto/test_proto.cpp +++ b/test/test_proto/test_proto.cpp @@ -119,15 +119,17 @@ static void test_values_at_their_default_are_left_out() { w.add(proto_field_t::myPos, (int8_t)-1); w.add(proto_field_t::repeats, (uint8_t)1); w.add(proto_field_t::paired, false); + w.add(proto_field_t::hasOtaSlot, true); // a bool whose default is true w.add(proto_field_t::name, ""); w.add(proto_field_t::name, (const char *)nullptr); }).c_str()); } static void test_values_off_their_default_are_written_by_key() { - TEST_ASSERT_EQUAL_STRING("{\"p\":50,\"m\":0,\"i\":1,\"n\":\"Office\",\"a\":4294967295,\"q\":-5}", writeObject([](ProtoWriter &w) { + TEST_ASSERT_EQUAL_STRING("{\"p\":50,\"m\":0,\"i\":1,\"os\":0,\"n\":\"Office\",\"a\":4294967295,\"q\":-5}", writeObject([](ProtoWriter &w) { w.add(proto_field_t::position, (int8_t)50); w.add(proto_field_t::myPos, (int8_t)0); w.add(proto_field_t::paired, true); + w.add(proto_field_t::hasOtaSlot, false); w.add(proto_field_t::name, "Office"); w.add(proto_field_t::remoteAddress, (uint32_t)0xFFFFFFFF); w.add(proto_field_t::tiltPosition, (int8_t)-5); From b3d00b0bf5de476f84abde497b5ab40b83341870 Mon Sep 17 00:00:00 2001 From: cjkas Date: Wed, 28 Oct 2026 22:52:20 +0100 Subject: [PATCH 6/6] fix: name the release file the onboard image comes in The release publishes SomfyController.onboard.esp32.bin inside a .bin.zip, so the USB message names both. Co-Authored-By: Claude Opus 5.5 --- data-src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-src/index.js b/data-src/index.js index a7a6dc3..be90fed 100644 --- a/data-src/index.js +++ b/data-src/index.js @@ -4172,7 +4172,7 @@ class Firmware { let chip = document.getElementById('divContainer').getAttribute('data-chipmodel') || ''; // Firmware from before the field leaves it out: undefined, not false. if (proto.model.header.hasOtaSlot === false) { - ui.infoMessage(`This device has no OTA slot, so its firmware is flashed over USB with SomfyController.onboard.esp32${chip}.bin. That image holds the web UI and an empty configuration too, so take a backup first and restore it afterwards.`); + ui.infoMessage(`This device has no OTA slot, so its firmware is flashed over USB with SomfyController.onboard.esp32${chip}.bin, from the release's SomfyController.onboard.esp32${chip}.bin.zip. That image holds the web UI and an empty configuration too, so take a backup first and restore it afterwards.`); return; } let div = this.createFileUploader('/updateFirmware');