- 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>
38 lines
1.6 KiB
C
38 lines
1.6 KiB
C
// Wi-Fi LED drivers (the cpp led-driver): found by mDNS (_http._tcp, TXT app=led-strip) and driven
|
|
// through its JSON API over a WebSocket (/ws). A device's id is its hostname, 12 characters or fewer.
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include "cJSON.h"
|
|
|
|
#define WIFI_DRV_ID_MAX 12
|
|
#define WIFI_DRV_PING_MAX 16 // most Wi-Fi drivers in one ping
|
|
|
|
// Start the send queue and sender task. Safe to call more than once.
|
|
void wifi_drv_init(void);
|
|
|
|
// Board only: browse mDNS every 30 s and add each new led-strip driver as a wifi device. Needs mdns up.
|
|
void wifi_drv_start_discovery(void);
|
|
|
|
// True while the driver's WebSocket is open and its last request was answered
|
|
bool wifi_drv_connected(const char *id);
|
|
|
|
// Queue POST path with body (a JSON object, freed here) to the driver id. Never blocks; drops when full.
|
|
void wifi_drv_post(const char *id, const char *path, cJSON *body);
|
|
|
|
// A driver preset body (/api/pattern fields) from a stored or pushed preset; NULL if not an object
|
|
cJSON *wifi_drv_preset_body(const cJSON *preset);
|
|
|
|
// Identify a Wi-Fi driver: red blink at 10 Hz (brightness 128) for 2 s, then off
|
|
void wifi_drv_identify(const char *id);
|
|
|
|
// One Wi-Fi driver's answer to a ping: its id and round trip in ms (-1 when it did not answer)
|
|
typedef struct {
|
|
char id[WIFI_DRV_ID_MAX + 1];
|
|
int rtt_ms;
|
|
} wifi_drv_ping_t;
|
|
|
|
// Ping every Wi-Fi driver (GET /api/status over its link) and wait up to timeout_ms for the answers.
|
|
// Copies up to max results into out and returns how many; returns 0 when there are no drivers.
|
|
int wifi_drv_ping_all(int timeout_ms, wifi_drv_ping_t out[], int max);
|