docs: P4-Nano controller and simulator, users API, README screenshots

README, API, help, P4_NANO and the sub-READMEs now describe the ESP32-P4-Nano
controller and the simulator on it. API.md gains the users and permissions
routes; BENCH_TEST and SPECIFICATION are marked historical. Screenshots of the
simulator, sequence editor and pattern gallery. Graph rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-24 22:09:28 +13:00
1 parent 8756315a7b
commit e0c6c36996
32 files changed
+269751 -683

No files matched your search

+28 -6
View File
@@ -1,6 +1,6 @@
# LED Controller API
The controller is an ESP32-S3 on Ethernet (W5500). It serves the web UI and a JSON API on port 80, detects beats from its I2S microphone and talks to the LED drivers over ESP-NOW. This document covers:
The controller is a Waveshare ESP32-P4-Nano on Ethernet ([P4_NANO.md](P4_NANO.md)). It serves the web UI and a JSON API on port 80, detects beats from its microphone and talks to the LED drivers over ESP-NOW through the board's ESP32-C6. The host builds (desktop, Docker, sim) serve the same API, on port 8080 by default; differences are marked. This document covers:
1. The HTTP and WebSocket API, by resource.
2. How the controller turns API calls into driver messages, and the message format.
@@ -26,6 +26,7 @@ Request and response bodies are JSON (`Content-Type: application/json`) unless n
| GET | `/audio` | Live audio and beat page (level, tempo, bar position, tap) |
| GET | `/settings/editor` | Driver settings editor: sends a driver settings (`PUT /devices/<id>`) |
| GET | `/static/<path>` | UI scripts and styles |
| GET | `/sim/`, `/sim/gallery` | The simulated rig and the pattern gallery. Their API (`/sim/api/*`, `/sim/ws`) is in [`led-simulator/README.md`](../led-simulator/README.md) |
| GET | `/favicon.ico` | 204 |
Pages and static files are built into the firmware (gzipped, sent with `Content-Encoding: gzip`). They carry `Cache-Control: no-cache` and an `ETag` of the firmware build, so a browser revalidates each load (304 until the next update).
@@ -34,13 +35,34 @@ Pages and static files are built into the firmware (gzipped, sent with `Content-
| Method | Path | Description |
|--------|------|-------------|
| GET | `/status` | IP, `eth` (ip, mask, gw, up), `ap_ip`, `ap_clients` (`[{mac, ip}]` on the Wi-Fi access point), MAC, uptime, `free_heap`, `free_internal` (internal RAM), mic level, tempo and beat counts, ESP-NOW and link statistics |
| GET | `/status` | IP, `eth` (ip, mask, gw, up), `ap_ip`, `ap_clients` (`[{mac, ip}]` on the Wi-Fi access point), MAC, uptime, `free_heap`, `free_internal` (internal RAM), mic level, tempo and beat counts, ESP-NOW and link statistics. Host builds add `sim`, `bridge`, `bridges` and `bridge_links`; on the board the bridges are in `GET /settings/bridge` |
| POST | `/reboot` | Replies `{"message":"rebooting"}`, then restarts after 0.5 s |
| GET | `/ota` | Running image: partition, version, build time, IDF version, sha |
| POST | `/ota` | Body: the raw firmware `.bin` (web UI included). Written to the idle slot, made the boot image, then the board reboots. A new image confirms itself after staying up a few seconds; one that crashes on start rolls back. `make ota HOST=<ip>` |
| GET | `/db/<collection>` | Export a whole collection |
| PUT | `/db/<collection>` | Replace a whole collection. Body: the object of id → record. Reply: `{"records": n}` |
## Users and permissions — `/auth`
Off until the first user exists: until then every request is allowed. From then on a request needs a session and a role with enough permission for its area. Signed-out requests have the `guest` role. The last user who can manage users cannot be removed, so the API cannot switch this off again.
- **Levels:** 0 none, 1 view, 2 control (play, stop, brightness, identify and the like), 3 edit.
- **Areas:** `presets`, `sequences`, `zones` (with profiles and scenes), `groups`, `devices`, `outputs`, `patterns` (with palettes), `sim`, `settings` (with bridges, audio, OTA, reboot and bench tests), `users`. `/db` needs edit on `settings`, reads included.
- **Always public:** the main page, static files, `/status`, the audio page and the simulator's files.
- **Built-in roles:** `admin` (edit everywhere, fixed) and `guest` (editable).
- **Session:** a `led_session` cookie, 30 days. Sessions are kept in memory, so a restart signs everyone out.
| Method | Path | Description |
|--------|------|-------------|
| GET | `/auth` | `{enabled, user, role, perms: {area: level}}` for this request |
| POST | `/auth/login` | `{username, password}`. 401 when wrong, 429 after too many attempts |
| POST | `/auth/logout` | Ends the session |
| PUT | `/auth/password` | `{old, new}`: the signed-in user's own password, 8–128 characters |
| GET, POST | `/auth/users` | List; create `{username, password, role}` |
| PUT, DELETE | `/auth/users/<name>` | Change `role` and/or `password`; delete |
| GET, POST | `/auth/roles` | List; create `{name, perms: {area: level}}` |
| PUT, DELETE | `/auth/roles/<name>` | Change `perms`; delete (not a built-in role, nor one in use) |
**Bench tests** (see `docs/BENCH_TEST.md`):
| Method | Path | Description |
@@ -61,11 +83,11 @@ Keys with meaning on the controller (others are stored as they are):
| Key | Checked | Meaning |
|-----|---------|---------|
| `ap_enabled` | | Wi-Fi access point (open, SSID = hostname, `192.168.5.1`); default `true`; applies after a restart. Holding the D3 button at boot forces it on |
| `ap_enabled` | | Wi-Fi access point (open, SSID = hostname, `192.168.5.1`); default `true`; applies after a restart. Holding a button wired to the menuconfig "AP button" GPIO at boot forces it on (none by default: the P4-Nano has no user button) |
| `ap_password` | | AP password, 8-63 characters (WPA2); empty (default) is an open network; applies after a restart |
| `bridges` | list of strings | Bridges the ESP-NOW frames go to instead of the radio, each up to 79 characters: `/dev/ttyACM1` (a USB bridge board, or `serial:/dev/...`) `host:port` (UDP: led-simulator, or a network bridge board, default port 8766), or `dmx:<id>` (a DMX bridge, see below; host builds only, and only an id that exists). Every frame goes to each; a frame several bridges hear arrives once. Empty or missing: the radio. The host applies changes at once (`GET`/`PUT /settings/bridge`); a device applies them after a restart. `bridge` (one address) is still read when `bridges` is missing. |
| `bridges` | list of strings | Bridges the ESP-NOW frames go to, each up to 79 characters: `/dev/ttyACM1` (a USB bridge board, or `serial:/dev/...`; host builds only), `host:port` (UDP: led-simulator, or a network bridge board, default port 8766), or `dmx:<id>` (a DMX bridge, see below; host builds only, and only an id that exists), or `browser` (the rig page at `/sim/`). Every frame goes to each; a frame several bridges hear arrives once. The board always runs `c6` (its own radio) and `browser` as well, whatever the list says. A host build with an empty list runs `browser`. The host applies changes at once (`PUT /settings/bridge`); the board applies them after a restart and answers that PUT with 404. `bridge` (one address) is still read when `bridges` is missing. |
| `hostname` | | mDNS name (`<hostname>.local`, default `led-controller`); applies after a restart |
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP, else `192.168.4.1/24` for a direct PC cable. Applies after a restart |
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP, else (no answer in 5 s) `192.168.50.20/24` for a direct PC cable. Applies after a restart |
| `global_brightness` | integer 0–255 | Global factor of each driver's brightness (see Groups). Stored only: the UI pushes each driver its combined value |
| `wifi_channel` | integer 1–11 | Stored for reference. The controller's ESP-NOW channel is set at build time (`make menuconfig`) |
| `audio_simulated_bpm` | clamped to 60–200 | Tempo of the beat clock (default 120) |
@@ -305,7 +327,7 @@ Network pixel fixtures. An output is `{id, name, protocol: "ddp" | "artnet" | "s
Zones do not render to outputs: only the test pattern is sent.
The simulated rig (`/sim/`, host builds) receives Art-Net and DDP, so an output aimed at `127.0.0.1` shows on its DDP and Art-Net fixtures; see `led-simulator/README.md` (Network fixtures) and `GET /sim/api/dmx`.
The simulated rig (`/sim/`) receives Art-Net and DDP, so an output aimed at `127.0.0.1` shows on its DDP and Art-Net fixtures; see `led-simulator/README.md` (Network fixtures) and `GET /sim/api/dmx`.
## DMX bridges — `/dmx-bridges`, `/dmx-definitions`