Skip to content
File

Blob: archive/fft-benchmark/firmware/platform/include/radio_bridge.h

cpp47 lines
1#pragma once
2#include <stddef.h>
3#include <stdint.h>
4 
5/* Private ABI, implemented in C and imported only by esp32-radio::platform.
6 * Call with valid pointer/length pairs; no Rust values cross this boundary.
7 * All input bytes are borrowed only for the call. Output storage is caller-owned.
8 * Peer/HTTP handles stay on their creating task. See docs/ffi.md for lifetimes.
9 */
10int32_t radio_board_init(void);
11int32_t radio_network_ready(void);
12int32_t radio_clock_sync(void);
13uint64_t radio_now_us(void);
14uint32_t radio_random(void);
15uint32_t radio_heap_free(void);
16uint32_t radio_stack_free(void);
17int32_t radio_rssi(void);
18int32_t radio_led(uint8_t r, uint8_t g, uint8_t b);
19int32_t radio_console_byte(void);
20void radio_log(const char *message);
21uint32_t radio_recovery_attempt(int32_t reset);
22void radio_restart(void) __attribute__((noreturn));
23uint8_t *radio_music_load(size_t *length);
24void radio_music_free(uint8_t *bytes);
25 
26typedef struct radio_peer radio_peer;
27radio_peer *radio_peer_open(void);
28int32_t radio_peer_poll(radio_peer *peer);
29int32_t radio_peer_offer(radio_peer *peer, uint8_t *out, size_t capacity);
30int32_t radio_peer_answer(radio_peer *peer, const uint8_t *bytes, size_t length);
31/* State is normalized: 0 connecting, 1 SCTP connected, -1 fatal/lost. */
32int32_t radio_peer_state(radio_peer *peer);
33int32_t radio_peer_channels(radio_peer *peer);
34int32_t radio_peer_command(radio_peer *peer, uint8_t *out, size_t capacity);
35uint32_t radio_peer_dropped(radio_peer *peer);
36int32_t radio_peer_audio(radio_peer *peer, uint32_t pts, const uint8_t *bytes, size_t length);
37int32_t radio_peer_data(radio_peer *peer, uint16_t stream, int32_t binary, const uint8_t *bytes, size_t length);
38 
39typedef struct radio_http radio_http;
40radio_http *radio_http_open(void);
41int32_t radio_http_post(radio_http *http, const char *path, const uint8_t *body, size_t length,
42 uint8_t *out, size_t capacity, size_t *used);
43void radio_http_free(radio_http *http);
44 
45/* Called exactly once by app_main. The Rust release profile aborts on panic. */
46void radio_rust_main(void);