feat: Implement Svelte frontend with OTA update support, build tooling, and deployment documentation.

This commit is contained in:
2026-03-03 17:29:06 -05:00
parent c357c76af6
commit 046f353d7e
7 changed files with 218 additions and 100 deletions

View File

@@ -1,6 +1,8 @@
// SDK
#include "cJSON.h"
#include "esp_http_server.h"
#include "esp_littlefs.h"
#include "esp_partition.h"
// Project
#include "appstate.hpp"
@@ -14,6 +16,37 @@ internal esp_err_t api_ota_status_handler(httpd_req_t *req)
cJSON *root = cJSON_CreateObject();
cJSON_AddNumberToObject(root, "active_slot", g_Active_WWW_Partition);
const char *partitions[] = {"www_0", "www_1"};
cJSON *parts_arr = cJSON_AddArrayToObject(root, "partitions");
for (int i = 0; i < 2; i++)
{
cJSON *p_obj = cJSON_CreateObject();
cJSON_AddStringToObject(p_obj, "label", partitions[i]);
const esp_partition_t *p = esp_partition_find_first(
ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, partitions[i]);
if (p)
{
cJSON_AddNumberToObject(p_obj, "size", p->size);
size_t total = 0, used = 0;
if (esp_littlefs_info(partitions[i], &total, &used) == ESP_OK)
{
cJSON_AddNumberToObject(p_obj, "used", used);
cJSON_AddNumberToObject(p_obj, "free", total - used);
}
else
{
// Not mounted or not LFS
cJSON_AddNumberToObject(p_obj, "used", 0);
cJSON_AddNumberToObject(p_obj, "free", p->size);
}
}
cJSON_AddItemToArray(parts_arr, p_obj);
}
cJSON_AddStringToObject(root, "active_partition",
g_Active_WWW_Partition == 0 ? "www_0" : "www_1");
cJSON_AddStringToObject(root, "target_partition",