First Version to be updateable over API
All checks were successful
Test compiling project / test (push) Successful in 2m34s

This commit is contained in:
2025-02-17 21:46:20 +01:00
parent 6c4dc144d8
commit 6cec8f0a11
7 changed files with 57 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
#include <ArduinoJson.h>
#include <ArduinoLog.h>
#include "json_builder.h"
#include "../tools/tools.h"
extern WaterData water_data;
extern DeviceTelemetry telemetry;
@@ -42,5 +43,22 @@ void setup_api_endpoints(){
String output;
serializeJson(build_ota_json(ota_status), output);
request->send(200, "application/json", output);
});
});
server.on("/run_ota_update", HTTP_GET, [](AsyncWebServerRequest* request) {
if (ota_status.update_progress > -1) {
request->send(200, "text/plain", "OTA Update already in progress");
return;
} else if (!ota_status.update_available) {
request->send(200, "text/plain", "No update available");
return;
}
static TaskArgs_t args = {
.ota_status = ota_status
};
xTaskCreate(run_ota_update_task, "RunOTAUpdate", 1024 * 8, (void *)&args, 1, NULL);
request->send(200, "text/plain", "OTA Update started");
});
}