Files
ruvnet--RuView/firmware/esp32-csi-node/main/stream_sender.h
T
rUv fca5e6f0a0 fix: multistatic canonicalization, csi_fps burst inflation, control-packet starvation (#1170, #1180, #1183) (#1193)
#1170 — live multistatic bridge fed raw, un-canonicalized per-node CSI
(64/128/192 bins) to MultistaticFuser, tripping DimensionMismatch every
cycle and silently disabling fusion on mixed HT20/HT40 meshes. Add
HardwareNormalizer::resample_to_canonical (resample-only, no z-score) and
canonicalize every node frame onto the 56-tone grid before fusion.

#1180 — update_csi_fps_ema only rejected dt<=0 or >=1s, so sub-ms UDP-burst
arrivals (36us -> ~27kHz) inflated csi_fps_ema 40-840x. Add a 5ms plausibility
floor and stop re-anchoring observe_csi_frame_arrival on burst deltas.

#1183 — global ENOMEM backoff (CSI flood) starved <=48B/<=1Hz control packets.
Add stream_sender_send_priority() bypassing the backoff gate without touching
the streak; route feature_state/HEALTH/sync through it. Fix the misleading
"HEALTH sent" log that printed even on rv_mesh_send failure.

Verified: signal 501, sensing-server 677 tests (0 failed); firmware builds clean.


Claude-Session: https://claude.ai/code/session_01AgpTcBLRJ32hUsKWxDXf36
2026-06-27 13:04:44 -04:00

59 lines
1.5 KiB
C

/**
* @file stream_sender.h
* @brief UDP stream sender for CSI frames.
*/
#ifndef STREAM_SENDER_H
#define STREAM_SENDER_H
#include <stdint.h>
#include <stddef.h>
/**
* Initialize the UDP sender.
* Creates a UDP socket targeting the configured aggregator.
*
* @return 0 on success, -1 on error.
*/
int stream_sender_init(void);
/**
* Initialize the UDP sender with explicit IP and port.
* Used when configuration is loaded from NVS at runtime.
*
* @param ip Aggregator IP address string (e.g. "192.168.1.20").
* @param port Aggregator UDP port.
* @return 0 on success, -1 on error.
*/
int stream_sender_init_with(const char *ip, uint16_t port);
/**
* Send a serialized CSI frame over UDP.
*
* @param data Frame data buffer.
* @param len Length of data to send.
* @return Number of bytes sent, or -1 on error.
*/
int stream_sender_send(const uint8_t *data, size_t len);
/**
* Send a low-rate control packet, bypassing the ENOMEM backoff gate (#1183).
*
* Intended for ≤48 B, ≤1 Hz control traffic (feature_state, HEALTH, mesh
* sync) that must not be starved by the global backoff the high-rate CSI
* stream triggers. An ENOMEM on this path is reported quietly and does NOT
* extend or reset the global backoff streak.
*
* @param data Frame data buffer.
* @param len Length of data to send.
* @return Number of bytes sent, or -1 on error.
*/
int stream_sender_send_priority(const uint8_t *data, size_t len);
/**
* Close the UDP sender socket.
*/
void stream_sender_deinit(void);
#endif /* STREAM_SENDER_H */