#pragma once #include #include typedef struct { uint32_t rx_candidates; // sync matches handed to us by the radio uint32_t rx_valid; // CRC-valid C1 frames uint32_t rx_crc_fail; uint32_t rx_not_c1; // sync matched but not C-mode (e.g. T1) uint32_t rx_len_invalid; uint32_t rx_t1; // receptions classified as T-mode (any CRC state) uint32_t rx_bytes; uint32_t tx_attempts; uint32_t tx_success; uint32_t tx_timeout; uint64_t tx_airtime_us; // cumulative, for duty-cycle accounting uint32_t tx_failures; uint32_t tx_suppressed_dup; uint32_t tx_suppressed_duty; // blocked by the duty-cycle guard uint32_t tx_suppressed_whitelist; uint32_t radio_reinit; uint32_t fem_reinit; uint32_t recoveries; } repeater_stats_t; typedef struct { uint32_t repeat_delay_ms; // 20..1000; persisted (cfg_store) uint32_t duty_budget_ppm; // rolling-hour TX airtime cap, 0 = disabled; persisted uint32_t beacon_period_ms; // periodic synthetic test frame, 0 = off int8_t tx_power_dbm; // configured SX1262 level, not radiated power bool repeat_enabled; bool verbose; bool fem_rx_csd; // experimental FEM CSD level in RX uint8_t preamble_bits; // 0, 8, 16, 24 or 32 detected bits uint8_t test_lfield; // 19..200, synthetic frame payload length uint32_t whitelist[8]; // A-field ID (4 bytes LE as uint32) int whitelist_len; } repeater_cfg_t; // Radio-owned applied configuration after boot; other tasks may display it, // but all mutations must go through settings_update. extern repeater_cfg_t g_cfg; extern repeater_stats_t g_stats; // Last-event snapshot published by the radio task for the local UI. // Written only from the radio task; read from the UI task without locks. // Races tear at most one displayed frame and are deliberately accepted -- // the UI must never block or query the radio (docs/FUTURE_UI.md). typedef struct { int64_t rx_ts_us; // 0 = no reception yet uint32_t rx_meter_id; // A-field ID, LE uint32 (prints as meter number) uint32_t rx_hash; int16_t rx_len; int8_t rx_rssi_dbm; char rx_format; // 'A' / 'B' bool rx_crc_ok; int64_t tx_ts_us; // 0 = no TX yet char tx_result[16]; // includes full "radio_timeout" + terminator int64_t hb_ts_us; // last heartbeat probe uint8_t chip_mode; bool config_intact; int8_t rssi_dbm; } repeater_ui_t; extern repeater_ui_t g_ui; // Rolling-hour duty usage right now. Pure memory reads (ledger + monotonic // clock); safe to call from the UI task. uint64_t repeater_duty_used_us(void); void repeater_start(void); void repeater_request_radio_reset(void); void repeater_request_test_tx(void); void repeater_request_test_tx_t1(void); void repeater_request_probe(void); void repeater_request_test_burst(void); void repeater_inject_fault(int what); // 1 = standby, 2 = sleep void repeater_print_status(void); void repeater_print_stats(void); void repeater_print_radio_status(void);