feat: main's import/export, zones, audio API and web UI
Profiles, presets and sequences export and import as main's bundles. Zones carry group_ids, preset_group_ids, sequence_ids, content_kind and brightness; profiles seed rainbow as colour_cycle, and deleting a profile also deletes its sequences. Groups, zones and sequences written by older versions are migrated at boot. /api/audio (status, event stream, start/stop, reset, anchor-bar, devices) maps main's audio detector onto the mic's beat detector. Audio start/stop picks whether mic beats or the BPM clock time sequences; the clock's beats also go to the drivers while the mic is off. /ws now greets from a post-handshake callback (httpd does not call the handler for the upgrade). The web UI is main's, plus v2's outputs editor, list search and hostname/static IP settings; the bridge, Wi-Fi AP and led-tool parts are gone. API tests follow main's behaviour (119 pass on the board). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04b56c6ef2
commit
bfeeb958df
44 files changed
+8709
-2338
No files matched your search
@@ -45,17 +45,20 @@ static void forward(httpd_req_t *req, const char *text)
|
||||
}
|
||||
}
|
||||
|
||||
// Right after the upgrade: the v1 greeting. The controller keeps no Wi-Fi driver connections, so the
|
||||
// snapshot is always empty.
|
||||
static esp_err_t on_open(httpd_req_t *req)
|
||||
{
|
||||
send_text(req, "{\"type\":\"device_tcp_snapshot\",\"connected_ips\":[]}");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t ws_handler(httpd_req_t *req)
|
||||
{
|
||||
if (req->method == HTTP_GET) {
|
||||
if (httpd_ws_get_fd_info(req->handle, httpd_req_to_sockfd(req)) != HTTPD_WS_CLIENT_WEBSOCKET) {
|
||||
httpd_resp_set_status(req, "426 Upgrade Required");
|
||||
httpd_resp_set_hdr(req, "Upgrade", "websocket");
|
||||
return httpd_resp_sendstr(req, "websocket only");
|
||||
}
|
||||
// The controller keeps no Wi-Fi driver connections, so the v1 snapshot is always empty
|
||||
send_text(req, "{\"type\":\"device_tcp_snapshot\",\"connected_ips\":[]}");
|
||||
return ESP_OK;
|
||||
if (req->method == HTTP_GET) { // only a plain GET reaches the handler; the upgrade is answered by httpd
|
||||
httpd_resp_set_status(req, "426 Upgrade Required");
|
||||
httpd_resp_set_hdr(req, "Upgrade", "websocket");
|
||||
return httpd_resp_sendstr(req, "websocket only");
|
||||
}
|
||||
httpd_ws_frame_t f = { 0 };
|
||||
esp_err_t err = httpd_ws_recv_frame(req, &f, 0);
|
||||
@@ -85,6 +88,8 @@ static esp_err_t ws_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t ws_register(httpd_handle_t server)
|
||||
{
|
||||
const httpd_uri_t u = { .uri = "/ws", .method = HTTP_GET, .handler = ws_handler, .is_websocket = true };
|
||||
const httpd_uri_t u = {
|
||||
.uri = "/ws", .method = HTTP_GET, .handler = ws_handler, .is_websocket = true, .ws_post_handshake_cb = on_open
|
||||
};
|
||||
return httpd_register_uri_handler(server, &u);
|
||||
}
|
||||
Reference in new issue
Block a user