Files
led-controller/main/bridge_serial.h
T
jimmyandClaude Haiku 5.5 edf35e9c71 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>
2026-11-21 01:19:02 +13:00

49 lines
2.2 KiB
C

#pragma once
// Serial bridge boards (linux target only): USB ESP-NOW bridge boards (bridge/) on serial ports. Several
// boards can be open at once; bridge.c owns the list and routes frames. Frames are in bridge_proto.h.
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
#include "bridge.h"
typedef struct bridge_serial bridge_serial_t;
// Open a board on dev (e.g. /dev/ttyACM1), or "usb:aabbccddeeff" for the board with that MAC wherever its port is,
// or reopen it if it was closed. The port may come and go: its
// link task keeps reopening it, so a missing board is not an error. Frames from it go to cb.
bridge_serial_t *bridge_serial_open(const char *dev, bridge_rx_cb_t cb);
// The board's MAC, once it has answered (false before)
bool bridge_serial_mac(bridge_serial_t *b, uint8_t mac[6]);
// From now on follow this board by its MAC: when its port goes away, look for it on the other ports
void bridge_serial_follow_mac(bridge_serial_t *b);
// Stop using the board: its port closes and stays closed until bridge_serial_open(dev) again.
void bridge_serial_close(bridge_serial_t *b);
// Send dst_mac + packet to the board, which puts it on ESP-NOW. ESP_ERR_INVALID_STATE while the board is closed.
esp_err_t bridge_serial_send(bridge_serial_t *b, const uint8_t *dst_mac, const void *data, size_t len);
// Change the board's ESP-NOW channel (1-13). It keeps the setting in its NVS. ESP_ERR_INVALID_STATE until it answers.
esp_err_t bridge_serial_set_channel(bridge_serial_t *b, uint8_t channel);
// JSON object describing the board: port, linked, MAC, channel, mic and counters; returns its length
size_t bridge_serial_status(bridge_serial_t *b, char *out, size_t n);
// Audio from whichever board is recording (one at a time)
void bridge_serial_set_audio_cb(bridge_audio_cb_t cb);
// A linked board reports a microphone (its INFO capabilities)
bool bridge_serial_has_mic(void);
// Start (true) or stop (false) microphone audio on the first open board that has a mic. A start is re-sent
// after a reconnect.
esp_err_t bridge_serial_mic(bool on);
// Serial ports a board may be on, as a JSON array of paths; returns its length
size_t bridge_serial_ports_json(char *out, size_t n);