feat(v2): move web UI into v2, remove legacy MicroPython app

Move the web assets and templates under v2/web, drop the old src/, lib/
and scripts, and update firmware, tools, docs and db files. Add the audio
page, LED test scripts and VPN autoconnect script.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Sonnet 5.5 committed 2026-11-02 20:30:02 +13:00
1 parent 6c16998691
commit 71bd320661
193 files changed
+5605 -18860

No files matched your search

+44 -26
View File
@@ -1,14 +1,12 @@
#include "web.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "esp_log.h"
static const char *TAG = "web";
#define CHUNK 2048
static const struct {
const char *ext;
const char *type;
@@ -34,37 +32,57 @@ static const char *mime_for(const char *path)
return "application/octet-stream";
}
// path is the URL-relative name, e.g. "static/zones.js"; the file on flash is "/www/<path>.gz"
// The web UI is one blob linked into the app image (www_dist/www.pack, see tools/build_web.sh):
// "WWW1", then per file u16 name length, u32 data length, the name, the gzipped data; a zero name
// length ends it.
extern const uint8_t www_pack_start[] asm("_binary_www_pack_start");
extern const uint8_t www_pack_end[] asm("_binary_www_pack_end");
static bool find_file(const char *path, const uint8_t **data, uint32_t *len)
{
const uint8_t *p = www_pack_start, *end = www_pack_end;
if (end - p < 6 || memcmp(p, "WWW1", 4) != 0) {
return false;
}
p += 4;
size_t want = strlen(path);
while (end - p >= 2) {
uint16_t nlen;
memcpy(&nlen, p, 2);
if (nlen == 0 || end - p < 6 + nlen) {
return false;
}
uint32_t dlen;
memcpy(&dlen, p + 2, 4);
const uint8_t *name = p + 6, *body = name + nlen;
if (end - body < (ptrdiff_t)dlen) {
return false;
}
if (nlen == want && memcmp(name, path, want) == 0) {
*data = body;
*len = dlen;
return true;
}
p = body + dlen;
}
return false;
}
// path is the URL-relative name, e.g. "static/zones.js"
static esp_err_t send_gz(httpd_req_t *req, const char *path, bool immutable)
{
char fs[128];
if (strstr(path, "..") || snprintf(fs, sizeof(fs), "/www/%s.gz", path) >= (int)sizeof(fs)) {
const uint8_t *data;
uint32_t len;
if (strstr(path, "..")) {
return httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "bad path");
}
FILE *f = fopen(fs, "rb");
if (!f) {
if (!find_file(path, &data, &len)) {
return httpd_resp_send_404(req);
}
httpd_resp_set_type(req, mime_for(path));
httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
httpd_resp_set_hdr(req, "Cache-Control", immutable ? "public, max-age=86400" : "no-cache");
char *buf = malloc(CHUNK);
if (!buf) {
fclose(f);
return httpd_resp_send_500(req);
}
esp_err_t ret = ESP_OK;
size_t n;
while (ret == ESP_OK && (n = fread(buf, 1, CHUNK, f)) > 0) {
ret = httpd_resp_send_chunk(req, buf, n);
}
if (ret == ESP_OK) {
ret = httpd_resp_send_chunk(req, NULL, 0);
}
free(buf);
fclose(f);
return ret;
return httpd_resp_send(req, (const char *)data, len);
}
esp_err_t web_send_page(httpd_req_t *req, const char *name)