Files
jimmyandClaude Opus 5.5 581b751904 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>
2026-11-16 19:32:46 +13:00

46 lines
1.8 KiB
Python

#!/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)