Channel 11 defaults, ESP-NOW driver config and rig/desktop updates

Moves the controller, bridge and led-driver default ESP-NOW channel to 11 and
updates the led-driver and led-tool submodule pointers. Includes the rest of the
working tree: web UI, desktop and sim-controller changes, API and bridge code,
graphify output, and the .gitea and fixture-driver folders.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Haiku 5.5 committed 2026-11-21 01:19:02 +13:00
1 parent 35207a868a
commit edf35e9c71
280 files changed
+24043 -1756

No files matched your search

+103 -7
View File
@@ -31,7 +31,7 @@ static const struct {
{ "devices", "device" }, { "zones", "zone" }, { "presets", "preset" },
{ "profiles", "profile" }, { "palettes", "palette" }, { "patterns", "pattern" },
{ "sequences", "sequence" }, { "scenes", "scene" }, { "groups", "group" },
{ "outputs", "output" },
{ "outputs", "output" }, { "dmx-definitions", "dmx_definition" }, { "dmx-bridges", "dmx_bridge" },
};
/* ---------------------------------------------------------------- helpers */
@@ -228,6 +228,7 @@ static bool route(const char *res, httpd_req_t *req, int n, api_seg_t seg, esp_e
{ "profiles", profiles_route }, { "zones", zones_route }, { "presets", presets_route },
{ "palettes", palettes_route }, { "sequences", sequences_route }, { "devices", devices_route },
{ "patterns", patterns_route }, { "outputs", outputs_route }, { "groups", groups_route },
{ "dmx-definitions", dmx_definitions_route }, { "dmx-bridges", dmx_bridges_route },
};
for (size_t i = 0; i < sizeof(ROUTERS) / sizeof(ROUTERS[0]); i++) {
if (!strcmp(ROUTERS[i].res, res)) {
@@ -439,9 +440,26 @@ static esp_err_t put_settings(httpd_req_t *req)
}
// The bridges the controller sends its ESP-NOW frames to (USB boards, network boards, the simulator).
// GET /settings/bridge: {supported, bridges: [{addr, kind, status}], ports}.
// PUT /settings/bridge: {bridges: [addr, ...]} sets the whole list; {addr, channel} sets a board's channel.
// GET /settings/bridge: {supported, bridges: [{addr, name, kind, status}], ports}.
// PUT /settings/bridge: {bridges: [addr, ...]} sets the whole list; {addr, channel} sets a board's channel;
// {addr, name} names a bridge (an empty name clears it).
// Both apply at once on the host; a device reads the list at the next restart.
// Bridge names are kept in settings "bridge_names", by address. A USB board is kept by its MAC ("usb:<mac>") once it
// has answered, so its name survives a change of port.
static void bridge_name_key(const cJSON *bridge, char *key, size_t n)
{
const cJSON *addr = cJSON_GetObjectItem(bridge, "addr");
const cJSON *mac = cJSON_GetObjectItem(cJSON_GetObjectItem(bridge, "status"), "mac");
snprintf(key, n, "%s", cJSON_IsString(addr) ? addr->valuestring : "");
if (cJSON_IsString(mac) && strcmp(mac->valuestring, "00:00:00:00:00:00") != 0 &&
(!strncmp(key, "/dev/", 5) || !strncmp(key, "serial:", 7) || !strncmp(key, "usb:", 4))) {
unsigned m[6];
if (sscanf(mac->valuestring, "%x:%x:%x:%x:%x:%x", &m[0], &m[1], &m[2], &m[3], &m[4], &m[5]) == 6) {
snprintf(key, n, "usb:%02x%02x%02x%02x%02x%02x", m[0], m[1], m[2], m[3], m[4], m[5]);
}
}
}
static esp_err_t bridge_get(httpd_req_t *req)
{
char links[1536], ports[512];
@@ -453,11 +471,31 @@ static esp_err_t bridge_get(httpd_req_t *req)
#else
cJSON_AddBoolToObject(out, "supported", false);
#endif
cJSON_AddItemToObject(out, "bridges", cJSON_Parse(links));
cJSON *bridges = cJSON_Parse(links);
const cJSON *names = cJSON_GetObjectItem(store_settings(), "bridge_names");
const cJSON *b;
cJSON_ArrayForEach(b, bridges)
{
char key[BRIDGE_ADDR_MAX];
bridge_name_key(b, key, sizeof(key));
const cJSON *name = cJSON_GetObjectItem(names, key);
cJSON_AddStringToObject((cJSON *)b, "name", cJSON_IsString(name) ? name->valuestring : "");
}
cJSON_AddItemToObject(out, "bridges", bridges);
cJSON_AddItemToObject(out, "ports", cJSON_Parse(ports));
return api_json(req, "200 OK", out, true);
}
static void bridge_store(void);
// bridge.c calls this when a USB board's address became its MAC
static void bridge_store_locked(void)
{
store_lock();
bridge_store();
store_unlock();
}
// Save the list the running bridges actually have (a bridge that failed to open is not kept)
static void bridge_store(void)
{
@@ -475,6 +513,24 @@ static void bridge_store(void)
store_save("settings");
}
void api_bridges_remove(const char *addr)
{
char addrs[BRIDGE_MAX_LINKS][BRIDGE_ADDR_MAX];
size_t n = bridge_list(addrs, BRIDGE_MAX_LINKS), k = 0;
bool had = false;
for (size_t i = 0; i < n; i++) {
if (strcmp(addrs[i], addr) != 0) {
memmove(addrs[k++], addrs[i], BRIDGE_ADDR_MAX);
} else {
had = true;
}
}
if (had) {
espnow_tx_change_bridges(addrs, k);
bridge_store();
}
}
static esp_err_t bridge_put(httpd_req_t *req)
{
#if !CONFIG_IDF_TARGET_LINUX
@@ -488,8 +544,9 @@ static esp_err_t bridge_put(httpd_req_t *req)
const cJSON *addr = cJSON_GetObjectItem(body, "addr");
const cJSON *ch = cJSON_GetObjectItem(body, "channel");
const char *bad = NULL;
if (!list && !(addr && ch)) {
bad = "send bridges (a list), or addr and channel";
const cJSON *name = cJSON_GetObjectItem(body, "name");
if (!list && !(addr && (ch || name))) {
bad = "send bridges (a list), or addr with a channel or a name";
} else if (list && !cJSON_IsArray(list)) {
bad = "bridges must be a list of addresses";
} else if (list && cJSON_GetArraySize(list) > BRIDGE_MAX_LINKS) {
@@ -498,12 +555,17 @@ static esp_err_t bridge_put(httpd_req_t *req)
bad = "addr must be a board port (/dev/...) or host:port";
} else if (ch && !(cJSON_IsNumber(ch) && ch->valueint >= 1 && ch->valueint <= 13)) {
bad = "channel must be 1 to 13";
} else if (name && !(cJSON_IsString(name) && strlen(name->valuestring) <= 40)) {
bad = "name must be text of up to 40 characters";
}
const cJSON *item = NULL;
if (!bad && list) {
cJSON_ArrayForEach(item, list) {
if (!cJSON_IsString(item) || strlen(item->valuestring) >= BRIDGE_ADDR_MAX) {
bad = "each bridge must be a board port (/dev/...), host:port or serial:/dev/...";
bad = "each bridge must be a board port (/dev/...), host:port, serial:/dev/... or dmx:<id>";
} else if (!strncmp(item->valuestring, "dmx:", 4) &&
!cJSON_GetObjectItem(store_coll("dmx_bridge"), item->valuestring + 4)) {
bad = "no DMX bridge has that id (create it at /dmx-bridges first)";
}
}
}
@@ -514,10 +576,16 @@ static esp_err_t bridge_put(httpd_req_t *req)
if (list) {
char addrs[BRIDGE_MAX_LINKS][BRIDGE_ADDR_MAX];
size_t n = 0;
bool has_browser = false;
cJSON_ArrayForEach(item, list) {
snprintf(addrs[n], BRIDGE_ADDR_MAX, "%s", item->valuestring);
has_browser = has_browser || !strcmp(item->valuestring, BRIDGE_BROWSER);
n++;
}
// The rig page's own bridge cannot be removed: keep it when it runs and the list leaves it out
if (!has_browser && bridge_has_browser() && n < BRIDGE_MAX_LINKS) {
snprintf(addrs[n++], BRIDGE_ADDR_MAX, "%s", BRIDGE_BROWSER);
}
esp_err_t err = espnow_tx_change_bridges(addrs, n);
bridge_store();
if (err != ESP_OK) {
@@ -525,6 +593,31 @@ static esp_err_t bridge_put(httpd_req_t *req)
return api_error(req, "400 Bad Request", "one of the bridges could not be opened (the others are running)");
}
}
if (addr && name) {
char links[1536];
bridge_status_json(links, sizeof(links));
cJSON *all = cJSON_Parse(links);
char key[BRIDGE_ADDR_MAX];
snprintf(key, sizeof(key), "%s", addr->valuestring);
const cJSON *b;
cJSON_ArrayForEach(b, all)
{
const cJSON *a = cJSON_GetObjectItem(b, "addr");
if (cJSON_IsString(a) && !strcmp(a->valuestring, addr->valuestring)) {
bridge_name_key(b, key, sizeof(key));
}
}
cJSON_Delete(all);
cJSON *names = cJSON_GetObjectItem(store_settings(), "bridge_names");
if (!cJSON_IsObject(names)) {
names = cJSON_AddObjectToObject(store_settings(), "bridge_names");
}
cJSON_DeleteItemFromObject(names, key);
if (name->valuestring[0]) {
cJSON_AddStringToObject(names, key, name->valuestring);
}
store_save("settings");
}
if (addr && ch) {
// A board just switched in answers its INFO a moment later: wait up to 3 s for it before giving up
esp_err_t err = ESP_OK;
@@ -681,6 +774,7 @@ LOCKED(test_handler)
esp_err_t api_register(httpd_handle_t server)
{
bridge_set_renamed_cb(bridge_store_locked);
ESP_ERROR_CHECK(auth_init());
ESP_ERROR_CHECK_WITHOUT_ABORT(auth_register(server));
store_lock();
@@ -689,10 +783,12 @@ esp_err_t api_register(httpd_handle_t server)
api_migrate_sequences();
api_migrate_zones();
api_migrate_groups();
dmx_seed_definitions();
store_unlock();
static const char *const ROUTES[] = {
"/devices*", "/zones*", "/presets*", "/profiles*", "/palettes*",
"/patterns*", "/sequences*", "/scenes*", "/groups*", "/outputs*",
"/dmx-definitions*", "/dmx-bridges*",
};
static const httpd_method_t METHODS[] = { HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_DELETE };
for (size_t r = 0; r < sizeof(ROUTES) / sizeof(ROUTES[0]); r++) {