feat: browser simulator served by the controller, desktop build, browser bridge

- led-simulator: the rig runs the C++ led-driver as WebAssembly (sim-driver/),
  one single-threaded worker per bar, no cross-origin isolation needed. Rooms
  (one JSON per room) with an on-page editor, and a pattern gallery. The
  Python server, Pyodide boot and ring buffer are removed.
- sim-controller sim_rig.c: serves /sim/ from an embedded pack, the page's
  WebSocket and the rooms/flash API. The desktop build embeds it too.
- bridge.c: a "browser" bridge kind that carries ESP-NOW frames to the page;
  devices announced through it are marked sim.
- UI: Simulator in the Menu, split view with resize and pop-out, swipe
  between controller and rig on phones; SIM/REAL badges in Devices.
- Fades: preset pushes and Wi-Fi driver bodies always carry fade and
  beat_time, so "off" no longer inherits an earlier fade.
- Also the sequences-v2 work in progress: desktop port, bridge firmware,
  serial bridge, Wi-Fi drivers, sequence timeline, audio and API changes.
- led-driver: ESP-NOW link, beat sync, control messages, sim hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-16 19:32:46 +13:00
1 parent 698c1463c0
commit 581b751904
506 files changed
+42336 -3599

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
"""Patch the vendored ESP-IDF httpd so it needs no mbedTLS or PSA.
The WebSocket handshake hashes the client key with SHA-1 and base64-encodes it. The desktop build uses its
own SHA-1 and base64 (desktop/port/src/desktop_crypto.c), so only that block changes. Idempotent.
"""
import re
import sys
from pathlib import Path
root = Path(sys.argv[1])
# esp_http_server.h uses the heap capability flags without including their header (ESP-IDF gets them
# from its own include order), so include it here
hdr = root / "esp_http_server" / "include" / "esp_http_server.h"
h = hdr.read_text()
if '#include "esp_heap_caps.h"' not in h:
h = h.replace("#include ", '#include "esp_heap_caps.h"\n#include ', 1)
hdr.write_text(h)
print("patched", hdr)
ws = root / "esp_http_server" / "src" / "httpd_ws.c"
s = ws.read_text()
if "desktop_crypto.h" not in s:
s = s.replace("#include <psa/crypto.h>\n", "")
s = s.replace("#include <mbedtls/base64.h>\n", '#include "desktop_crypto.h"\n')
s = s.replace("#include <mbedtls/error.h>\n", "")
start = s.index(" /* Generate SHA-1 hash */")
end_marker = "server_key_hash, sizeof(server_key_hash));\n"
end = s.index(end_marker, start) + len(end_marker)
s = s[:start] + (
" /* Generate SHA-1 hash, then base64 (desktop build: desktop_crypto.c) */\n"
" desktop_sha1((const uint8_t *)server_raw_text, strlen(server_raw_text), server_key_hash);\n"
" size_t encoded_len = desktop_base64_encode(server_key_encoded, sizeof(server_key_encoded),\n"
" server_key_hash, sizeof(server_key_hash));\n"
) + s[end:]
ws.write_text(s)
print("patched", ws)
else:
print("already patched", ws)
if "mbedtls" in s or "psa_" in s:
print("WARNING: mbedTLS/PSA still referenced in", ws, file=sys.stderr)
sys.exit(1)
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Vendor the third-party sources the desktop build needs, from ESP-IDF (espressif/idf:v6.1) and the cJSON
# managed component, then patch the two spots that use mbedTLS/PSA (see patch_vendor.py).
# Run from the repository root after changing the IDF version: desktop/tools/vendor.sh
set -euo pipefail
cd "$(dirname "$0")/../.."
IDF_IMAGE=${IDF_IMAGE:-espressif/idf:v6.1}
OUT=desktop/third_party
rm -rf "$OUT/esp_http_server" "$OUT/http_parser" "$OUT/cjson"
mkdir -p "$OUT/esp_http_server/src/util" "$OUT/esp_http_server/include" "$OUT/http_parser" "$OUT/cjson"
docker run --rm -v "$PWD/$OUT:/out" "$IDF_IMAGE" bash -c '
set -e; S=/opt/esp/idf/components
cp $S/esp_http_server/src/*.c $S/esp_http_server/src/esp_httpd_priv.h /out/esp_http_server/src/
cp $S/esp_http_server/src/util/* /out/esp_http_server/src/util/
cp $S/esp_http_server/include/esp_http_server.h /out/esp_http_server/include/
cp $S/http_parser/http_parser.c $S/http_parser/http_parser.h $S/http_parser/LICENSE.txt /out/http_parser/
cp $S/esp_http_server/LICENSE /out/esp_http_server/ 2>/dev/null || true
chown -R 0:0 /out
'
# cJSON: the managed component the board and the sim already use (version pinned in dependencies.lock)
CJSON=sim-controller/managed_components/espressif__cjson/cJSON
cp "$CJSON/cJSON.c" "$CJSON/cJSON.h" "$CJSON/LICENSE" "$OUT/cjson/"
python3 desktop/tools/patch_vendor.py "$OUT"
# sdkconfig.h: the config the sim's ESP-IDF linux build generated (the same CONFIG_* values the firmware reads)
if [ -f sim-controller/build/config/sdkconfig.h ]; then
cp sim-controller/build/config/sdkconfig.h desktop/port/include/sdkconfig.h
fi
echo "vendored into $OUT"