feat: enabling web-based OTA updates and deployment for frontend

This commit is contained in:
2026-03-03 16:33:01 -05:00
parent 7c537ed4db
commit eafb705eda
7 changed files with 439 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
// SDK
#include "cJSON.h"
#include "esp_http_server.h"
// Project
#include "appstate.hpp"
#include "types.hpp"
internal esp_err_t api_ota_status_handler(httpd_req_t *req)
{
httpd_resp_set_type(req, "application/json");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
cJSON *root = cJSON_CreateObject();
cJSON_AddNumberToObject(root, "active_slot", g_Active_WWW_Partition);
cJSON_AddStringToObject(root, "active_partition",
g_Active_WWW_Partition == 0 ? "www_0" : "www_1");
cJSON_AddStringToObject(root, "target_partition",
g_Active_WWW_Partition == 0 ? "www_1" : "www_0");
const char *status_info = cJSON_Print(root);
httpd_resp_sendstr(req, status_info);
free((void *)status_info);
cJSON_Delete(root);
return ESP_OK;
}
internal const httpd_uri_t api_ota_status_uri = {.uri = "/api/ota/status",
.method = HTTP_GET,
.handler =
api_ota_status_handler,
.user_ctx = NULL};