#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 #include #include #include "esp_err.h" #include "bridge.h" typedef struct bridge_serial bridge_serial_t; // Open a board on dev (e.g. /dev/ttyACM1), 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); // 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);