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>
64 lines
3.8 KiB
C
64 lines
3.8 KiB
C
#pragma once
|
|
|
|
// Bridges: carry the controller's ESP-NOW frames to hosts that stand in for the radio. Several can run at
|
|
// once; every frame goes to all of them, and frames from any of them count as received (a frame heard by
|
|
// two boards arrives once). The list is settings "bridges" (or "bridge", one address, before that list):
|
|
// "host:port" UDP, e.g. led-simulator (bridge_sim.py), or a network bridge board.
|
|
// Down: dst_mac(6) + packet. Up: src_mac(6) + packet.
|
|
// "/dev/ttyACM1" serial, the USB ESP-NOW bridge board in bridge/ (linux target only), or "serial:/dev/...".
|
|
// "usb:aabbccddeeff" a USB board by its MAC, wherever its port is (linux). A board added by port becomes this
|
|
// once it answers; the list is saved again then (bridge_set_renamed_cb).
|
|
// "dmx:<id>" a DMX bridge (bridge_dmx.h, linux only): the "dmx_bridge" record id's fixtures, each a
|
|
// led-driver of its own, sent as Art-Net, sACN or USB-DMX at 40 Hz.
|
|
// "browser" the rig page the host build serves at /sim/ (linux target only): the simulated drivers
|
|
// run in the browser and get the frames over the page's WebSocket (sim_rig.c).
|
|
// While one runs, nothing goes out over the air.
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "esp_err.h"
|
|
|
|
typedef void (*bridge_rx_cb_t)(const uint8_t *src_mac, const uint8_t *data, int len);
|
|
|
|
// Microphone audio from a board that has one: 16 kHz mono samples, BRIDGE_AUDIO_SAMPLES at a time
|
|
typedef void (*bridge_audio_cb_t)(const int16_t *pcm, size_t n);
|
|
|
|
#define BRIDGE_DEFAULT_PORT 8766
|
|
#define BRIDGE_MAX_LINKS 8
|
|
#define BRIDGE_ADDR_MAX 80
|
|
#define BRIDGE_BROWSER "browser"
|
|
|
|
// Make the running set of bridges addrs[0..n-1] (see above). Bridges not in the list are closed, new ones
|
|
// opened, and frames received from any of them go to cb. Returns the first error, if any; the bridges that
|
|
// could open stay up.
|
|
esp_err_t bridge_set_all(const char addrs[][BRIDGE_ADDR_MAX], size_t n, bridge_rx_cb_t cb);
|
|
// Called when a bridge's address changed by itself (a USB board became "usb:<mac>"): save the list
|
|
void bridge_set_renamed_cb(void (*cb)(void));
|
|
bool bridge_active(void);
|
|
// A frame the rig page's drivers sent: src_mac(6) + packet (linux; sim_rig.c). Dropped unless "browser" runs.
|
|
void bridge_browser_rx(const uint8_t *frame, int len);
|
|
// The driver with this MAC was heard on the browser bridge since start: a simulated driver of the rig page
|
|
bool bridge_mac_is_browser(const uint8_t mac[6]);
|
|
// The driver with this MAC is a fixture of a running DMX bridge; that bridge's address ("dmx:<id>") in addr
|
|
bool bridge_mac_is_dmx(const uint8_t mac[6], char *addr, size_t n);
|
|
// The "browser" bridge is running
|
|
bool bridge_has_browser(void);
|
|
// Send to every running bridge
|
|
esp_err_t bridge_send(const uint8_t *dst_mac, const void *data, size_t len);
|
|
// The running bridges' addresses, in order; returns how many (at most max)
|
|
size_t bridge_list(char addrs[][BRIDGE_ADDR_MAX], size_t max);
|
|
// JSON array describing each running bridge: {addr, kind, ...}; returns its length
|
|
size_t bridge_status_json(char *out, size_t n);
|
|
// Serial ports a board may be on, as a JSON array of paths ("[]" off linux); returns its length
|
|
size_t bridge_ports_json(char *out, size_t n);
|
|
// Microphone audio from whichever board is recording (any bridge type)
|
|
void bridge_set_audio_cb(bridge_audio_cb_t cb);
|
|
// A running board has a microphone (USB or network)
|
|
bool bridge_has_mic(void);
|
|
// Start (true) or stop (false) the microphone on the board that has one. Network boards are asked every
|
|
// half second while they record, so a stop from the host is never needed for safety.
|
|
esp_err_t bridge_mic(bool on);
|
|
// Set the radio channel of the serial board at addr (linux). ESP_ERR_NOT_FOUND if no such board is running.
|
|
esp_err_t bridge_board_set_channel(const char *addr, uint8_t channel);
|