feat: port the remaining v1 API to the v2 controller

Profiles seed presets, a default zone and a palette, and clone with their
own copies; deleting a profile removes what it owned. Zones get the v1
list shape, set-current, current, clone and content-fragment. Devices are
keyed by MAC with v1 validation and identify. Patterns: definitions, OTA
file and manifest, upload, driver, and send over ESP-NOW (the led-driver
pattern sources are embedded in the firmware). Pixel outputs get v1
validation and a DDP/Art-Net/sACN test pattern. Sequences, palettes and
settings follow v1 replies and validation, and /ws forwards browser
messages to the drivers.

The resource handlers move out of api.c into res_*.c, patterns.c and
outputs.c. cJSON now allocates from PSRAM: the store had grown enough to
starve internal RAM and abort the mic at boot. /status reports
free_internal.

The Wi-Fi AP and led-tool routes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-03 09:58:17 +13:00
1 parent 4b42391a46
commit 57182188ba
30 files changed
+2846 -425

No files matched your search

+1 -10
View File
@@ -1,21 +1,18 @@
from helpers import missing, unique
from helpers import unique
@missing("/patterns/definitions")
def test_definitions(c):
resp = c.get("/patterns/definitions")
assert resp.status_code == 200
assert isinstance(resp.json(), dict)
@missing("driver pattern files in /patterns")
def test_list_includes_driver_patterns(c):
resp = c.get("/patterns")
assert resp.status_code == 200
assert "blink" in resp.json()
@missing("v1 pattern create ({name, data})")
def test_crud(c):
pid = unique("pytest_pattern").replace("-", "_")
resp = c.post("/patterns", json={"name": pid, "data": {"foo": "bar"}})
@@ -30,7 +27,6 @@ def test_crud(c):
assert c.delete(f"/patterns/{pid}").status_code == 200
@missing("/patterns/ota/file")
def test_ota_file(c):
resp = c.get("/patterns/ota/file/blink.py")
assert resp.status_code == 200
@@ -38,7 +34,6 @@ def test_ota_file(c):
assert "class" in resp.text
@missing("/patterns/ota/file")
def test_ota_file_rejects_builtin(c):
# on/off are built into the driver firmware, not OTA files
resp = c.get("/patterns/ota/file/on.py")
@@ -46,7 +41,6 @@ def test_ota_file_rejects_builtin(c):
assert "error" in resp.json()
@missing("/patterns/ota/manifest")
def test_ota_manifest(c):
resp = c.get("/patterns/ota/manifest")
assert resp.status_code == 200
@@ -54,20 +48,17 @@ def test_ota_manifest(c):
assert "blink.py" in names
@missing("/patterns/<name>/send")
def test_send_rejects_builtin(c):
resp = c.post("/patterns/off/send", json={})
assert resp.status_code == 400
assert "error" in resp.json()
@missing("/patterns/upload")
def test_upload_rejects_builtin(c):
resp = c.post("/patterns/upload", json={"name": "on.py", "code": "class On:\n def run(self, p):\n yield\n"})
assert resp.status_code == 400
@missing("/patterns/driver")
def test_driver_rejects_builtin(c):
resp = c.post("/patterns/driver", json={"name": "off", "code": "class Off:\n def run(self, p):\n yield\n"})
assert resp.status_code == 400