Add repeater protocol and device firmware features
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEBUG_HISTORY_CAPACITY 256
|
||||
|
||||
// Immutable final outcome. String pointers must refer to static literals.
|
||||
// Identity is the link-layer sender, never an inferred transport-layer meter.
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
int64_t timestamp_us;
|
||||
int64_t tx_start_us;
|
||||
int64_t tx_done_us;
|
||||
uint32_t meter_id;
|
||||
uint32_t hash;
|
||||
uint16_t manufacturer;
|
||||
uint16_t length;
|
||||
uint8_t version;
|
||||
uint8_t device_type;
|
||||
int8_t rssi_dbm;
|
||||
bool identity_present;
|
||||
bool crc_ok;
|
||||
const char *source; // rx, beacon, test
|
||||
const char *mode; // C1, T1, unknown
|
||||
const char *format; // A, B, unknown
|
||||
const char *reception; // ok, crc_failed, bad_length, undecodable,
|
||||
// t1_too_long, rx_read_failed, not_applicable
|
||||
const char *outcome; // ok, ok_polled, crc_failed, bad_length, undecodable,
|
||||
// t1_too_long, rx_read_failed, repeat_disabled,
|
||||
// whitelist, duplicate, duty_cycle, hop_policy,
|
||||
// encode_failed, start_failed, radio_timeout, irq_timeout
|
||||
} debug_record_t;
|
||||
|
||||
typedef struct {
|
||||
int64_t sampled_at_us;
|
||||
int64_t heartbeat_us;
|
||||
int64_t last_rx_us; // last CRC-valid reception
|
||||
int64_t last_tx_us; // last completed transmission (includes synthetic)
|
||||
uint64_t rx_valid;
|
||||
uint64_t rx_rejected;
|
||||
uint64_t repeats_completed;
|
||||
uint64_t tx_failed; // received repeats only
|
||||
uint64_t skipped; // valid received frames intentionally not repeated
|
||||
uint64_t duty_used_us;
|
||||
uint64_t duty_budget_us; // zero means disabled
|
||||
uint32_t recoveries;
|
||||
uint32_t repeat_delay_ms;
|
||||
uint8_t chip_mode;
|
||||
bool config_intact;
|
||||
bool repeat_enabled;
|
||||
} debug_status_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cursor;
|
||||
uint32_t oldest_id;
|
||||
uint32_t evicted;
|
||||
bool reset; // caller must discard retained rows before merging
|
||||
size_t count;
|
||||
debug_status_t status;
|
||||
debug_record_t rows[DEBUG_HISTORY_CAPACITY]; // ascending id
|
||||
} debug_snapshot_t;
|
||||
|
||||
// Single writer: radio task. No allocation, formatting, or network operations.
|
||||
void debug_history_record(const debug_record_t *record);
|
||||
// Radio publishes health/config/duty; record() owns counters and last-event ages.
|
||||
void debug_history_publish_status(const debug_status_t *status);
|
||||
// HTTP task owns the output buffer. No lock held while formatting or sending.
|
||||
void debug_history_snapshot(uint32_t after, debug_snapshot_t *out);
|
||||
Reference in New Issue
Block a user