mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
5721d34a34
commit
657b345eaf
13 changed files with 41 additions and 38 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue