File
Blob: archive/fft-benchmark/firmware/platform/include/radio_bridge.h
| 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 | */ |
| 10 | int32_t radio_board_init(void); |
| 11 | int32_t radio_network_ready(void); |
| 12 | int32_t radio_clock_sync(void); |
| 13 | uint64_t radio_now_us(void); |
| 14 | uint32_t radio_random(void); |
| 15 | uint32_t radio_heap_free(void); |
| 16 | uint32_t radio_stack_free(void); |
| 17 | int32_t radio_rssi(void); |
| 18 | int32_t radio_led(uint8_t r, uint8_t g, uint8_t b); |
| 19 | int32_t radio_console_byte(void); |
| 20 | void radio_log(const char *message); |
| 21 | uint32_t radio_recovery_attempt(int32_t reset); |
| 22 | void radio_restart(void) __attribute__((noreturn)); |
| 23 | uint8_t *radio_music_load(size_t *length); |
| 24 | void radio_music_free(uint8_t *bytes); |
| 25 | |
| 26 | typedef struct radio_peer radio_peer; |
| 27 | radio_peer *radio_peer_open(void); |
| 28 | int32_t radio_peer_poll(radio_peer *peer); |
| 29 | int32_t radio_peer_offer(radio_peer *peer, uint8_t *out, size_t capacity); |
| 30 | int32_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. */ |
| 32 | int32_t radio_peer_state(radio_peer *peer); |
| 33 | int32_t radio_peer_channels(radio_peer *peer); |
| 34 | int32_t radio_peer_command(radio_peer *peer, uint8_t *out, size_t capacity); |
| 35 | uint32_t radio_peer_dropped(radio_peer *peer); |
| 36 | int32_t radio_peer_audio(radio_peer *peer, uint32_t pts, const uint8_t *bytes, size_t length); |
| 37 | int32_t radio_peer_data(radio_peer *peer, uint16_t stream, int32_t binary, const uint8_t *bytes, size_t length); |
| 38 | |
| 39 | typedef struct radio_http radio_http; |
| 40 | radio_http *radio_http_open(void); |
| 41 | int32_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); |
| 43 | void radio_http_free(radio_http *http); |
| 44 | |
| 45 | /* Called exactly once by app_main. The Rust release profile aborts on panic. */ |
| 46 | void radio_rust_main(void); |