mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-11-21 00:02:12 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
6db449e878
commit
5721d34a34
10 changed files with 55 additions and 5 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue