Files
led-controller/bridge
jimmyandClaude Opus 5.5 e0c6c36996 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>
2026-11-24 22:09:28 +13:00
..

USB ESP-NOW bridge

For a computer with no radio. The P4-Nano controller does not need one: its ESP32-C6 is its radio, and it is itself a network bridge for the desktop on UDP 8766 (docs/P4_NANO.md).

An ESP32 board that gives a computer an ESP-NOW radio. Two builds: an ESP32-S3 (the one with an I2S microphone, below) and an ESP32-C3 (ESP-NOW only). led-controller running on the computer sends its ESP-NOW frames to the board over USB, and the board puts them on the air; frames from the drivers come back the same way.

led-controller (host) --SLIP over USB-Serial-JTAG--> bridge board --ESP-NOW--> LED drivers
                      <-------------------------------                <--------

Build and flash

Built with ESP-IDF v6.1 (espressif/idf:v6.1), one build directory per chip (bridge/build-s3, bridge/build-c3):

make bridge-build-s3                       # or bridge-build-c3, or bridge-build for both
make bridge-flash-s3 BRIDGE=/dev/ttyACM2   # overwrites the board's firmware
make bridge-flash-c3 BRIDGE=/dev/ttyACM1

Flash only the board you mean: the flash targets overwrite whatever is on the port.

Running the controller against it

make rig BRIDGE=/dev/ttyACM1               # the sim-controller build, web UI on http://localhost:8080/

Or set the bridge in settings ("bridge": "/dev/ttyACM1"), or LED_SIM_BRIDGE=/dev/ttyACM1 for the sim. The controller reconnects if the board is unplugged. Its status (GET /status, field bridge_links, one entry per bridge) shows whether the board is linked, its MAC and channel, and the counters.

Microphone (S3)

The S3 build reads an I2S microphone (an INMP441 on a XIAO ESP32-S3: SCK GPIO 5, WS GPIO 6, SD GPIO 43, configurable under "Bridge microphone (I2S)" in menuconfig). While the desktop records from it, the board sends 10 ms blocks of 16 kHz mono audio (AUDIO frames, below). The desktop lists it in the audio input list as "I2S microphone on the bridge board". The C3 build has no microphone and reports that in INFO.

Channel

ESP-NOW runs on one Wi-Fi channel, and the drivers and the bridge must share it. The bridge starts on channel 11. Set the channel the drivers use (the access point's, or the router's when a driver is joined to one), either by a SET_CHANNEL frame (bridge_serial_set_channel) or by changing it on the board's NVS.

Protocol

SLIP frames, each [type][body][crc16 LE] (CRC-16/CCITT-FALSE over type and body). The single source is main/bridge_proto.h, shared by the firmware and the host (main/bridge_serial.c).

type direction body
00 PKT host → board dst_mac(6) + packet → ESP-NOW
00 PKT board → host src_mac(6) + packet for every ESP-NOW frame received
10 HELLO host → board (empty); answered with INFO
11 INFO board → host version, MAC, channel, tx, tx_fail, rx, drop counters
12 SET_CHANNEL host → board channel (1-13); answered with INFO
13 SET_MIC host → board on (1) or off (0): send microphone audio
40 AUDIO board → host 160 16-bit little-endian mono samples at 16 kHz, while the mic is on
30 LOG board → host a log line

INFO's last byte is capabilities: bit 0 is set when the board has a microphone.

The board sends one PKT at a time and waits for each send's result, so a burst cannot overrun the radio.

Ethernet (W5500)

The S3 board also has a W5500 on SPI (XIAO pins by default: SCLK 7, MISO 8, MOSI 9, CS 2, INT 3, RST 1; change them in make menuconfig under "Bridge Ethernet (W5500)"). It takes DHCP and answers UDP on port 8766, with the same datagrams as the simulator's bridge: send dst_mac + packet and the board puts it on ESP-NOW; each frame it hears comes back to the last sender as src_mac + packet.

The board's address is in INFO (bytes 25-28, with the Ethernet-up bit in byte 24), so the desktop shows it under the board's status (ip). Add it as a network bridge with <ip>:8766. Don't use the USB and the UDP path for the same board at once: each frame would go out over the air twice.