跳转至

硬件平台域模型

硬件平台域涵盖从 ESP32-S3 芯片到服务器端聚合器的所有内容:采集原始 CSI、在设备端处理、在边缘运行可编程 WASM 模块,以及配置传感器节点车队。它是所有更高层域(RuvSense、WiFi-Mat、Pose Tracking)依赖以获取真实无线电数据的物理基础。

本文档使用领域驱动设计(DDD)定义系统:拥有自身数据和规则的限界上下文、强制不变量的聚合根、承载含义的值对象,以及连接一切的领域事件。目标是让固件和硬件层的结构与其控制的电子器件相匹配——这样,任何阅读代码的人(或修改代码的 AI 代理)都能理解每个部分为什么存在,而不仅仅是它做什么。

限界上下文:

# 上下文 职责 关键 ADR 代码
1 传感器节点 WiFi CSI 采集、信道跳变、TDM 调度、UDP 流式传输 ADR-012, ADR-018 firmware/esp32-csi-node/main/{csi_collector,stream_sender,nvs_config}.c
2 边缘处理 设备端 DSP 流水线(层级 0-2):相位解卷绕、存在检测、生命体征、跌倒检测 ADR-039 firmware/esp32-csi-node/main/edge_processing.c
3 WASM 运行时 层级 3 可编程感知:模块管理、宿主 API、预算控制、RVF 容器 ADR-040, ADR-041 firmware/esp32-csi-node/main/{wasm_runtime,wasm_upload,rvf_parser}.c
4 聚合 服务器端 CSI 帧接收、时间戳对齐、多节点特征融合 ADR-012 crates/wifi-densepose-hardware/src/esp32/
5 配置 NVS 配置、固件生命周期、车队管理、部署预设 ADR-044 firmware/esp32-csi-node/provision.py

所有固件路径均相对于仓库根目录。Rust crate 路径相对于 v2/。


领域驱动设计规范

通用语言

术语 定义
传感器节点 通过 UDP 捕获 WiFi CSI 帧并将其流式传输到聚合器的 ESP32-S3 设备
CSI 帧 信道状态信息(CSI)的快照:每个子载波的幅度和相位,从 WiFi 前导码中提取
子载波 52-56 个 OFDM 频点之一,其复响应编码了无线电信道;CSI 的原子单位
边缘层级 ESP32 上的处理层级:0 = 原始直通,1 = 基础 DSP,2 = 生命体征流水线,3 = WASM 可编程
核心 0 / 核心 1 ESP32-S3 上的两个 Xtensa LX7 核心;核心 0 运行 WiFi + CSI 回调,核心 1 运行 DSP 流水线
SPSC 环形缓冲区 核心 0(CSI 回调)与核心 1(DSP 任务)之间的单生产者单消费者无锁队列
生命体征数据包 32 字节 UDP 数据包(魔数 0xC5110002),包含存在状态、呼吸 BPM、心率 BPM、跌倒标志
压缩帧 增量压缩的 CSI 帧(魔数 0xC5110005,由 ADR-069 从 0xC5110003 重新分配),使用 XOR + RLE 实现 30-50% 的带宽降低
WASM 模块 编译为 wasm32-unknown-unknown 的 no_std Rust 程序,通过 WASM3 解释器在设备端执行
模块槽 4 个预分配 PSRAM 区域(每个 160 KB)之一,用于承载 WASM 模块实例
宿主 API csi 命名空间中的 12 个函数,WASM 模块调用它们以读取传感器数据并发出事件
RVF 容器 带签名的二进制信封(192 字节开销),用清单、能力和 Ed25519 签名封装 WASM 负载
预算守卫 每帧执行时间限制(默认 10 ms);连续故障超过 10 次的模块会被自动停止
自适应预算 由最小割特征值间隙驱动的算力分配:场景复杂度决定 WASM 模块获得多少 CPU 时间
聚合器 接收所有节点 UDP 流、对齐时间戳并融合特征的服务器(笔记本电脑、RPi 或云)
特征级融合 组合各节点提取的特征(而非原始 I/Q),以避免跨节点时钟同步
融合帧 来自所有节点在一个时间窗口内的聚合观测,包含跨节点相关性和融合运动能量
NVS ESP32 闪存上的非易失性存储;存储运行时配置(WiFi 凭据、边缘层级、TDM 时隙等)
配置 在不重新编译固件的情况下向设备写入 NVS 键值对
TDM 时隙 用于协调多节点传输的时分复用(TDM)时隙分配
信道跳变 在 WiFi 信道(例如 1、6、11)之间切换 ESP32 无线电,以实现多频段 CSI 分集
OTA 更新 通过 8032 端口上的 HTTP 端点进行的空中固件更新

限界上下文

1. 传感器节点上下文

职责: 通过 ESP-IDF CSI API 捕获原始 WiFi CSI 帧,将它们序列化为 ADR-018 二进制格式,并通过 UDP 流式传输到聚合器。处理信道跳变、TDM 调度和速率限制。

+--------------------------------------------------------------+
|                    Sensor Node Context                          |
+--------------------------------------------------------------+
|                                                                |
|  +----------------+    +----------------+                      |
|  | CSI Collector  |    | NVS Config     |                      |
|  | (promiscuous   |    | (20+ keys:     |                      |
|  |  mode, I/Q     |    |  ssid, ip,     |                      |
|  |  extraction)   |    |  tier, tdm...) |                      |
|  +-------+--------+    +-------+--------+                      |
|          |                     |                               |
|          |  CSI callback       |  Boot config                  |
|          |  (Core 0, 50 Hz    |                               |
|          |   rate limit)       |                               |
|          v                     |                               |
|  +----------------+            |                               |
|  | Stream Sender  |<-----------+                               |
|  | (UDP to agg,   |                                            |
|  |  seq numbers,  |                                            |
|  |  ENOMEM        |                                            |
|  |  backoff)      |---> UDP frames (magic 0xC5110001)          |
|  +-------+--------+                                            |
|          |                                                     |
|          | SPSC ring buffer (to Core 1)                        |
|          v                                                     |
|  [Edge Processing Context]                                     |
|                                                                |
+--------------------------------------------------------------+

聚合: - SensorNode(聚合根)

值对象: - CsiFrame - NodeIdentity - NvsConfig - TdmSchedule - ChannelHopConfig

领域服务: - CsiCollectionService -- 注册 ESP-IDF CSI 回调,提取 I/Q,并强制执行 50 Hz 速率限制 - StreamSendService -- 将帧序列化为 ADR-018 二进制格式,并发送带序列号的 UDP - NvsConfigService -- 在启动时读取 20+ 个 NVS 键,并向所有固件组件提供类型化配置


2. 边缘处理上下文

职责: 在 Core 1 上运行的设备端信号处理流水线。实现第 0-2 层:相位提取、Welford 运行统计、top-K 子载波选择、带通滤波、BPM 估计、存在检测和跌倒检测。

+--------------------------------------------------------------+
|                  Edge Processing Context                       |
+--------------------------------------------------------------+
|                                                                |
|  SPSC ring buffer (from Core 0)                               |
|          |                                                     |
|          v                                                     |
|  +----------------+                                            |
|  | Phase Extract  |   Tier 1                                   |
|  | + Unwrap       |                                            |
|  +-------+--------+                                            |
|          |                                                     |
|          v                                                     |
|  +----------------+    +----------------+                      |
|  | Welford Stats  |    | Top-K Select   |                      |
|  | (per-subcarrier|    | (by variance)  |                      |
|  |  running var)  |    +-------+--------+                      |
|  +-------+--------+            |                               |
|          |                     |                               |
|          +----------+----------+                               |
|                     |                                          |
|                     v                                          |
|  +------------------+-----------+   Tier 2                     |
|  | Biquad IIR Bandpass Filters  |                              |
|  | breathing: 0.1-0.5 Hz        |                              |
|  | heart rate: 0.8-2.0 Hz       |                              |
|  +-------+----------------------+                              |
|          |                                                     |
|          v                                                     |
|  +----------------+    +----------------+                      |
|  | Zero-Crossing  |    | Presence       |                      |
|  | BPM Estimator  |    | Detector       |                      |
|  |                |    | (adaptive      |                      |
|  |                |    |  threshold,    |                      |
|  |                |    |  3-sigma cal)  |                      |
|  +-------+--------+    +-------+--------+                      |
|          |                     |                               |
|          +----------+----------+                               |
|                     |                                          |
|                     v                                          |
|  +------------------+--------+                                 |
|  | Fall Detector             |                                 |
|  | (phase acceleration       |                                 |
|  |  threshold)               |                                 |
|  +------------------+--------+                                 |
|                     |                                          |
|                     v                                          |
|  +------------------+--------+                                 |
|  | Multi-Person Clustering   |                                 |
|  | (subcarrier groups, <=4)  |----> VitalsPacket (0xC5110002)  |
|  +---------------------------+----> CompressedFrame (0xC5110005)|
|                                                                |
+--------------------------------------------------------------+

聚合: - EdgeProcessingState(聚合根)

值对象: - VitalsPacket - CompressedFrame - PresenceState - BpmEstimate - FallAlert - EdgeTier

领域服务: - PhaseExtractionService -- 将原始 I/Q 转换为幅度 + 相位,并应用解卷绕 - WelfordStatsService -- 维护每个子载波的运行均值和方差 - TopKSelectionService -- 选择方差最高的 K 个子载波用于下游处理 - BandpassFilterService -- 用于呼吸和心率频段的 Biquad IIR 滤波器 - PresenceDetectionService -- 具有 1200 帧、3-sigma 校准的自适应阈值 - FallDetectionService -- 相位加速度超过可配置阈值(默认 2.0 rad/s^2) - DeltaCompressionService -- 使用 XOR + RLE 增量编码,实现 30-50% 的带宽降低


3. WASM 运行时上下文

职责: 管理第 3 层 WASM 可编程感知层。加载、验证、执行并监控从 Rust 编译的 WASM 模块。强制执行预算守卫,处理 RVF 容器验证,暴露 Host API,并提供 HTTP 管理端点。

+--------------------------------------------------------------+
|                   WASM Runtime Context                         |
+--------------------------------------------------------------+
|                                                                |
|  +--------------------+    +--------------------+              |
|  | Module Manager     |    | RVF Verifier       |              |
|  | (4 slots, load/    |    | (Ed25519 sig,      |              |
|  |  unload/start/     |    |  SHA-256 hash,     |              |
|  |  stop lifecycle)   |    |  host API compat)  |              |
|  +--------+-----------+    +--------+-----------+              |
|           |                         |                          |
|           +----------+--------------+                          |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |            WASM3 Interpreter          |                     |
|  |  +-----------+ +-----------+          |                     |
|  |  | Slot 0    | | Slot 1    | ...x4    |                     |
|  |  | 160 KB    | | 160 KB    |          |                     |
|  |  | arena     | | arena     |          |                     |
|  |  +-----------+ +-----------+          |                     |
|  +-------------------+------------------+                      |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |           Host API (12 funcs)         |                     |
|  |  csi_get_phase, csi_get_amplitude,    |                     |
|  |  csi_get_variance, csi_get_bpm_*,     |                     |
|  |  csi_emit_event, csi_log, ...         |                     |
|  +-------------------+------------------+                      |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |         Budget Controller             |                     |
|  |  B = clamp(B0 + k1*dL + k2*A         |                     |
|  |           - k3*T - k4*P,             |                     |
|  |       B_min, B_max)                   |                     |
|  |  10 consecutive faults -> auto-stop   |                     |
|  +-------------------+------------------+                      |
|                      |                                         |
|                      +----> WASM events (magic 0xC5110004)     |
|                                                                |
|  +--------------------+                                        |
|  | HTTP Upload Server |                                        |
|  | (port 8032)        |                                        |
|  | POST /wasm/upload  |                                        |
|  | GET  /wasm/list    |                                        |
|  | POST /wasm/start/N |                                        |
|  | POST /wasm/stop/N  |                                        |
|  | DELETE /wasm/N     |                                        |
|  +--------------------+                                        |
|                                                                |
+--------------------------------------------------------------+

聚合: - WasmModuleSlot(聚合根)

值对象: - RvfContainer - RvfManifest - WasmTelemetry - HostApiVersion - CapabilityBitmask - BudgetAllocation - ModuleState

领域服务: - RvfVerificationService -- 解析 RVF 头部,验证 SHA-256 哈希和 Ed25519 签名 - ModuleLifecycleService -- 处理加载 -> 启动 -> 运行 -> 停止 -> 卸载的状态转换 - BudgetControllerService -- 根据 mincut 特征值间隙、热压力和电池压力计算每帧预算 - HostApiBindingService -- 将 12 个宿主函数链接到 "csi" 命名空间中的 WASM3 导入 - WasmUploadService -- 用于模块管理端点的 8032 端口 HTTP 服务器


4. 聚合上下文

职责: 在服务器端接收来自多个 ESP32 节点的 UDP CSI 流。跨节点对齐时间戳(无需跨节点相位同步),计算跨节点相关性,并为下游管道消费生成融合特征帧。

+--------------------------------------------------------------+
|                   Aggregation Context                          |
+--------------------------------------------------------------+
|                                                                |
|  UDP socket (:5005)                                           |
|     |          |          |                                    |
|     v          v          v                                    |
|  +--------+ +--------+ +--------+                             |
|  | Node 0 | | Node 1 | | Node 2 |  ... (up to 6)             |
|  | State  | | State  | | State  |                             |
|  | (ring  | | (ring  | | (ring  |                             |
|  |  buf,  | |  buf,  | |  buf,  |                             |
|  |  drift)| |  drift)| |  drift)|                             |
|  +---+----+ +---+----+ +---+----+                             |
|      |          |          |                                   |
|      +-----+----+-----+---+                                   |
|            |          |                                        |
|            v          v                                        |
|  +--------------------+--+    +-----------------------+        |
|  | Timestamp Aligner     |    | Cross-Node Correlator |        |
|  | (per-node monotonic,  |    | (amplitude ratios,    |        |
|  |  no NTP needed)       |    |  fused motion energy) |        |
|  +-----------+-----------+    +----------+------------+        |
|              |                           |                     |
|              +----------+----------------+                     |
|                         |                                      |
|                         v                                      |
|  +----------------------+-----+                                |
|  |      Fused Frame           |                                |
|  |  per_node_features[]       |                                |
|  |  cross_node_correlation    |--> pipeline_tx (mpsc channel)  |
|  |  fused_motion_energy       |                                |
|  |  fused_breathing_band      |                                |
|  +----------------------------+                                |
|                                                                |
+--------------------------------------------------------------+

聚合: - Esp32Aggregator(聚合根)

值对象: - FusedFrame - NodeState - CrossNodeCorrelation - FusedMotionEnergy

领域服务: - UdpReceiverService -- 监听 UDP 端口 5005,按魔数和节点 ID 进行解复用 - TimestampAlignmentService -- 将每个节点的单调时间戳映射到聚合器本地时间 - FeatureFusionService -- 计算跨节点相关性、融合运动(跨节点最大值)和融合呼吸(最高 SNR) - PipelineBridgeService -- 通过 mpsc 通道将融合帧送入 wifi-densepose Rust 管道


5. 配置上下文

职责: 通过写入 NVS 键值对来配置 ESP32 传感器节点,无需重新编译固件。支持通过配置文件、部署预设、读回验证以及自动检测已连接设备进行批量配置。

+--------------------------------------------------------------+
|                   Provisioning Context                         |
+--------------------------------------------------------------+
|                                                                |
|  +--------------------+    +--------------------+              |
|  | CLI Interface      |    | Config File Loader |              |
|  | (--ssid, --port,   |    | (JSON mesh config, |              |
|  |  --edge-tier,      |    |  common + per-node |              |
|  |  --preset, ...)    |    |  settings)         |              |
|  +--------+-----------+    +--------+-----------+              |
|           |                         |                          |
|           +----------+--------------+                          |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |        Preset Resolver               |                      |
|  |  basic, vitals, mesh-3,              |                      |
|  |  mesh-6-vitals                       |                      |
|  +-------------------+------------------+                      |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |        NVS Writer                    |                      |
|  |  esptool partition write             |                      |
|  |  20+ keys: ssid, password,           |                      |
|  |  target_ip, edge_tier, tdm_slot,     |                      |
|  |  hop_count, wasm_max, ...            |                      |
|  +-------------------+------------------+                      |
|                      |                                         |
|                      v                                         |
|  +-------------------+------------------+                      |
|  |      Verifier (optional)             |                      |
|  |  serial monitor for 5s,             |                      |
|  |  check for "CSI streaming active"    |                      |
|  +--------------------------------------+                      |
|                                                                |
|  +--------------------+                                        |
|  | Read-Back           |                                       |
|  | (--read: dump NVS   |                                       |
|  |  partition, parse    |                                       |
|  |  key-value pairs)   |                                       |
|  +--------------------+                                        |
|                                                                |
|  +--------------------+                                        |
|  | Auto-Detect         |                                       |
|  | (scan serial ports  |                                       |
|  |  for ESP32-S3)      |                                       |
|  +--------------------+                                        |
|                                                                |
+--------------------------------------------------------------+

聚合: - ProvisioningSession(聚合根)

值对象: - NvsConfig - DeploymentPreset - MeshConfig - PortIdentity - VerificationResult

领域服务: - NvsWriteService -- 通过 esptool 将类型化的 NVS 键值对写入 ESP32 闪存分区 - PresetResolverService -- 将命名预设(basic、vitals、mesh-3、mesh-6-vitals)映射到 NVS 键集合 - MeshProvisionerService -- 遍历配置文件中的节点,自动计算 TDM 时隙 - ReadBackService -- 读取 NVS 分区,解析二进制格式,并返回类型化配置 - BootVerificationService -- 在配置完成后打开串口监视器,检查预期的日志行


聚合

SensorNode(聚合根)

/// A physical ESP32-S3 device configured for CSI collection.
/// Owns its identity, configuration, firmware version, and current edge tier.
pub struct SensorNode {
    /// Unique node identifier (0-255, assigned during provisioning)
    node_id: u8,
    /// WiFi MAC address of the ESP32-S3
    mac: MacAddress,
    /// Current WiFi channel
    channel: u8,
    /// Firmware version string (e.g., "1.2.0")
    firmware_version: FirmwareVersion,
    /// Current edge processing tier (0-3)
    edge_tier: EdgeTier,
    /// Full NVS configuration snapshot
    config: NvsConfig,
    /// TDM slot assignment (None if standalone)
    tdm_slot: Option<TdmSchedule>,
    /// Channel hopping configuration
    hop_config: Option<ChannelHopConfig>,
    /// Current operational status
    status: NodeStatus,
    /// Monotonic boot timestamp (ms since power-on)
    uptime_ms: u64,
}

impl SensorNode {
    /// Invariant: node_id must be unique within a mesh deployment
    /// Invariant: edge_tier 3 requires WASM runtime to be initialized
    /// Invariant: tdm_slot.slot < tdm_slot.total_nodes
    pub fn new(node_id: u8, mac: MacAddress, config: NvsConfig) -> Self { /* ... */ }

    pub fn transition_tier(&mut self, new_tier: EdgeTier) -> Result<(), TierError> {
        // Cannot go to Tier 3 if WASM runtime is not available
        // Cannot downgrade while WASM modules are running
        /* ... */
    }
}

EdgeProcessingState(聚合根)

/// Maintains the full on-device DSP pipeline state for one sensor node.
/// Runs exclusively on Core 1.
pub struct EdgeProcessingState {
    /// Current processing tier
    tier: EdgeTier,
    /// Per-subcarrier running statistics (Welford)
    subcarrier_stats: [WelfordAccumulator; 56],
    /// Top-K selected subcarrier indices
    top_k_indices: Vec<u8>,
    /// Biquad IIR filter states
    breathing_filter: BiquadState,
    heartrate_filter: BiquadState,
    /// Current presence detection state
    presence: PresenceState,
    /// Latest BPM estimates
    breathing_bpm: Option<BpmEstimate>,
    heartrate_bpm: Option<BpmEstimate>,
    /// Fall detection state
    fall_detector: FallDetectorState,
    /// Multi-person clustering state (up to 4 persons)
    person_clusters: Vec<PersonCluster>,
    /// Calibration state (1200-frame adaptive threshold)
    calibration: CalibrationState,
}

impl EdgeProcessingState {
    /// Invariant: Only processes frames on Core 1 (never Core 0)
    /// Invariant: Tier 0 performs no processing (passthrough only)
    /// Invariant: Tier 2 includes all of Tier 1 processing
    /// Invariant: person_clusters.len() <= 4
    pub fn process_frame(&mut self, frame: &RawCsiFrame) -> ProcessingResult { /* ... */ }
}

WasmModuleSlot(聚合根)

/// One of 4 pre-allocated WASM execution slots on the ESP32-S3.
/// Each slot owns its PSRAM arena, WASM3 runtime instance, and telemetry.
pub struct WasmModuleSlot {
    /// Slot index (0-3)
    slot_id: u8,
    /// Pre-allocated PSRAM arena (160 KB, fixed at boot)
    arena: FixedArena,
    /// Loaded module metadata (None if slot is empty)
    module: Option<LoadedModule>,
    /// Current slot state
    state: ModuleState,
    /// Per-module telemetry counters
    telemetry: WasmTelemetry,
    /// Budget allocation for this slot (microseconds per frame)
    budget_us: u32,
}

/// Metadata for a loaded WASM module
pub struct LoadedModule {
    /// Module name from RVF manifest (up to 32 chars)
    name: String,
    /// SHA-256 hash of the WASM payload
    build_hash: [u8; 32],
    /// Declared capability bitmask
    capabilities: CapabilityBitmask,
    /// Author string from manifest
    author: String,
    /// WASM3 function pointers for lifecycle
    fn_on_init: WasmFunction,
    fn_on_frame: WasmFunction,
    fn_on_timer: WasmFunction,
}

impl WasmModuleSlot {
    /// Invariant: Arena is pre-allocated at boot and never freed (prevents fragmentation)
    /// Invariant: Module auto-stopped after 10 consecutive budget faults
    /// Invariant: RVF signature must be verified before loading (when wasm_verify=1)
    /// Invariant: Module binary + WASM3 heap must fit within 160 KB arena
    pub fn load(&mut self, rvf: &RvfContainer) -> Result<(), WasmLoadError> { /* ... */ }

    pub fn on_frame(&mut self, n_sc: i32) -> Result<Vec<WasmEvent>, WasmExecError> {
        // Measure execution time
        // Record telemetry
        // Check budget guard
        /* ... */
    }
}

Esp32Aggregator(聚合根)

/// Server-side aggregator that receives CSI streams from multiple ESP32 nodes,
/// aligns timestamps, and produces fused feature frames.
pub struct Esp32Aggregator {
    /// UDP socket listening for node streams (port 5005)
    socket: UdpSocket,
    /// Per-node state: ring buffer, last timestamp, drift estimate
    nodes: HashMap<u8, NodeState>,
    /// Ring buffer of fused feature frames
    fused_buffer: VecDeque<FusedFrame>,
    /// Channel to downstream pipeline
    pipeline_tx: mpsc::Sender<CsiData>,
    /// Configuration
    config: AggregatorConfig,
}

impl Esp32Aggregator {
    /// Invariant: Fuses features, never raw phases (clock drift makes cross-node
    ///            phase alignment impossible with 20-50 ppm crystal oscillators)
    /// Invariant: Handles missing nodes gracefully (partial fused frames are valid)
    /// Invariant: Sequence number gaps < 100ms are interpolated, not dropped
    pub fn receive_and_fuse(&mut self) -> Result<FusedFrame, AggError> { /* ... */ }
}

ProvisioningSession (聚合根)

/// A provisioning session that configures one or more ESP32 nodes.
/// Tracks which nodes have been provisioned and their verification status.
pub struct ProvisioningSession {
    /// Session identifier
    session_id: SessionId,
    /// Common configuration shared across all nodes
    common_config: CommonConfig,
    /// Per-node provisioning state
    node_results: Vec<NodeProvisionResult>,
    /// Preset used (if any)
    preset: Option<DeploymentPreset>,
    /// Mesh configuration (if provisioning multiple nodes)
    mesh_config: Option<MeshConfig>,
}

impl ProvisioningSession {
    /// Invariant: WiFi credentials must be non-empty
    /// Invariant: target_ip must be a valid IPv4 address
    /// Invariant: TDM slot indices must be unique and contiguous within a mesh
    /// Invariant: hop_count must match the length of the channel list
    pub fn provision_node(&mut self, port: &PortIdentity) -> Result<(), ProvisionError> {
        /* ... */
    }
}

值对象

CsiFrame

/// A single CSI observation from one ESP32 node.
/// Immutable snapshot of the radio channel at one instant.
pub struct CsiFrame {
    /// Monotonic timestamp (ms since node boot)
    timestamp_ms: u32,
    /// Source node identifier
    node_id: u8,
    /// RSSI in dBm (typically -90 to -20)
    rssi: i8,
    /// WiFi channel number (1-13)
    channel: u8,
    /// Per-subcarrier amplitude (|CSI|, 52-56 values)
    amplitude: Vec<f32>,
    /// Per-subcarrier phase (arg(CSI), 52-56 values, radians)
    phase: Vec<f32>,
    /// Sequence number for loss detection
    seq_num: u32,
}

VitalsPacket

/// 32-byte Tier 2 output packet sent at configurable intervals.
/// Contains all vital sign estimates from on-device processing.
pub struct VitalsPacket {
    /// Presence state
    presence: PresenceState,
    /// Motion score (0-255, higher = more motion)
    motion_score: u8,
    /// Breathing rate estimate (BPM, None if not confident)
    breathing_bpm: Option<f32>,
    /// Heart rate estimate (BPM, None if not confident)
    heart_rate_bpm: Option<f32>,
    /// Fall detected flag
    fall_flag: bool,
    /// Number of detected persons (0-8)
    n_persons: u8,
    /// Motion energy scalar
    motion_energy: f32,
    /// Presence confidence score
    presence_score: f32,
    /// RSSI at time of measurement
    rssi: i8,
    /// Timestamp (ms since boot)
    timestamp_ms: u32,
}

EdgeTier

/// Processing tier on the ESP32-S3. Each tier includes all functionality
/// of lower tiers.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum EdgeTier {
    /// Tier 0: Raw CSI passthrough (magic 0xC5110001). No on-device processing.
    Disabled = 0,
    /// Tier 1: Phase unwrap, Welford stats, top-K selection, delta compression.
    /// Adds ~30 KB binary overhead.
    BasicDsp = 1,
    /// Tier 2: All of Tier 1 + biquad bandpass, BPM estimation, presence,
    /// fall detection, multi-person clustering. Adds ~3 KB over Tier 1.
    FullPipeline = 2,
    /// Tier 3: All of Tier 2 + WASM3 runtime for programmable sensing modules.
    /// Adds ~100 KB binary (WASM3 interpreter).
    WasmProgrammable = 3,
}

NvsConfig

/// Complete NVS configuration for one ESP32 sensor node.
/// Covers all 20+ firmware-readable keys.
pub struct NvsConfig {
    // -- Network --
    pub ssid: String,
    pub password: String,
    pub target_ip: Ipv4Addr,
    pub target_port: u16,       // default: 5005
    pub node_id: u8,            // default: 0

    // -- TDM --
    pub tdm_slot: u8,           // default: 0
    pub tdm_total: u8,          // default: 1 (no TDM)

    // -- Channel Hopping --
    pub hop_count: u8,          // default: 1 (no hop)
    pub chan_list: Vec<u8>,     // default: [1, 6, 11]
    pub dwell_ms: u32,          // default: 100

    // -- Edge Processing --
    pub edge_tier: EdgeTier,    // default: Tier 2
    pub pres_thresh: u16,       // default: 0 (auto-calibrate)
    pub fall_thresh: u16,       // default: 2000 (2.0 rad/s^2)
    pub vital_win: u16,         // default: 256
    pub vital_int: u16,         // default: 1000 ms
    pub subk_count: u8,         // default: 8

    // -- Power --
    pub power_duty: u8,         // default: 100 (always on)

    // -- WASM --
    pub wasm_max: u8,           // default: 4
    pub wasm_verify: bool,      // default: true (secure-by-default)
    pub wasm_pubkey: Option<[u8; 32]>, // Ed25519 public key

    // -- MAC Filter --
    pub filter_mac: Option<MacAddress>,
}

RvfContainer

/// RVF (RuVector Format) container for signed WASM deployment.
/// Total overhead: 192 bytes (32 header + 96 manifest + 64 signature).
pub struct RvfContainer {
    /// Format version (currently 1)
    pub format_version: u16,
    /// Feature flags (bit 0: has_signature, bit 1: has_test_vectors)
    pub flags: u16,
    /// Module manifest
    pub manifest: RvfManifest,
    /// Raw WASM payload (starts with "\0asm" magic)
    pub wasm_payload: Vec<u8>,
    /// Ed25519 signature over header + manifest + payload (64 bytes)
    pub signature: Option<[u8; 64]>,
    /// Optional test vectors for self-verification
    pub test_vectors: Option<Vec<u8>>,
}

/// 96-byte packed manifest describing the WASM module.
pub struct RvfManifest {
    pub module_name: String,         // up to 32 chars
    pub required_host_api: u16,      // version (1 = current)
    pub capabilities: CapabilityBitmask,
    pub max_frame_us: u32,           // requested per-frame budget
    pub max_events_per_sec: u16,     // rate limit
    pub memory_limit_kb: u16,        // max WASM heap
    pub event_schema_version: u16,
    pub build_hash: [u8; 32],        // SHA-256 of WASM payload
    pub min_subcarriers: u16,
    pub max_subcarriers: u16,
    pub author: String,              // up to 10 chars
}

WasmTelemetry

/// Per-module execution telemetry, exposed via /wasm/list endpoint.
pub struct WasmTelemetry {
    /// Total on_frame() calls since module start
    pub frame_count: u32,
    /// Total csi_emit_event() calls
    pub event_count: u32,
    /// WASM3 runtime errors
    pub error_count: u32,
    /// Cumulative execution time (microseconds)
    pub total_us: u32,
    /// Worst-case single-frame execution time (microseconds)
    pub max_us: u32,
    /// Number of times frame budget was exceeded
    pub budget_faults: u32,
}

FusedFrame

/// Aggregated observation from all nodes for one time window.
/// Product of feature-level fusion (not signal-level).
pub struct FusedFrame {
    /// Aggregator-local monotonic timestamp
    timestamp: Instant,
    /// Per-node features (None if node dropped frames)
    node_features: Vec<Option<CsiFrame>>,
    /// Cross-node correlation matrix (N x N)
    cross_node_correlation: Array2<f64>,
    /// Fused motion energy (max across all nodes)
    fused_motion_energy: f64,
    /// Fused breathing band (coherent sum from highest-SNR node)
    fused_breathing_band: f64,
}

DeploymentPreset

/// Named provisioning presets for common deployment scenarios.
pub enum DeploymentPreset {
    /// Single node, Tier 0, no TDM, no hopping
    Basic,
    /// Single node, Tier 2, vital_int=1000, subk_count=32
    Vitals,
    /// 3-node TDM, Tier 1, hop_count=3, channels=[1,6,11]
    Mesh3,
    /// 6-node TDM, Tier 2, hop_count=3, channels=[1,6,11], vital_int=500
    Mesh6Vitals,
}

PresenceState

/// Tri-state presence classification from the edge DSP pipeline.
pub enum PresenceState {
    /// No motion detected; room appears empty
    Empty,
    /// Static human presence (breathing motion only)
    Present,
    /// Active motion detected
    Moving,
}

ModuleState

/// Lifecycle state of a WASM module slot.
pub enum ModuleState {
    /// Slot is empty (arena allocated but no module loaded)
    Empty,
    /// Module loaded into arena but not yet started
    Loaded,
    /// Module running: on_frame() called per CSI frame, on_timer() at interval
    Running,
    /// Module explicitly stopped by user
    Stopped,
    /// Module auto-stopped due to error (10 consecutive budget faults or runtime error)
    Error,
}

领域事件

传感器节点事件

/// Emitted when an ESP32 node completes boot and begins CSI collection.
pub struct NodeBooted {
    pub node_id: u8,
    pub mac: MacAddress,
    pub firmware_version: FirmwareVersion,
    pub edge_tier: EdgeTier,
    pub uptime_ms: u64,
    pub timestamp: DateTime<Utc>,
}

/// Emitted each time a CSI frame is received by the aggregator.
pub struct CsiFrameReceived {
    pub node_id: u8,
    pub seq_num: u32,
    pub subcarrier_count: u8,
    pub rssi: i8,
    pub channel: u8,
    pub timestamp: DateTime<Utc>,
}

边缘处理事件

/// Emitted when presence detection state transitions.
pub struct PresenceChanged {
    pub node_id: u8,
    pub previous: PresenceState,
    pub current: PresenceState,
    pub motion_energy: f32,
    pub timestamp: DateTime<Utc>,
}

/// Emitted at each vitals interval (default 1 Hz) with latest estimates.
pub struct VitalsUpdated {
    pub node_id: u8,
    pub breathing_bpm: Option<f32>,
    pub heart_rate_bpm: Option<f32>,
    pub n_persons: u8,
    pub timestamp: DateTime<Utc>,
}

/// Emitted when phase acceleration exceeds the fall detection threshold.
pub struct FallDetected {
    pub node_id: u8,
    pub motion_energy: f32,
    pub phase_acceleration: f32,
    pub threshold: f32,
    pub timestamp: DateTime<Utc>,
}

WASM 运行时事件

/// Emitted when a WASM module is loaded into a slot and passes verification.
pub struct WasmModuleLoaded {
    pub slot_id: u8,
    pub module_name: String,
    pub build_hash: [u8; 32],
    pub capabilities: CapabilityBitmask,
    pub author: String,
    pub timestamp: DateTime<Utc>,
}

/// Emitted when a WASM module is auto-stopped or encounters a runtime error.
pub struct WasmModuleFaulted {
    pub slot_id: u8,
    pub module_name: String,
    pub fault_type: WasmFaultType,
    pub fault_count: u32,
    pub telemetry: WasmTelemetry,
    pub timestamp: DateTime<Utc>,
}

pub enum WasmFaultType {
    /// Exceeded per-frame budget 10 consecutive times
    BudgetExhausted,
    /// WASM3 runtime trap (stack overflow, OOB memory, etc.)
    RuntimeTrap,
    /// Module called an unavailable host API function
    MissingImport,
    /// RVF signature verification failed
    SignatureInvalid,
}

/// Emitted when a WASM module calls csi_emit_event().
pub struct WasmEventEmitted {
    pub slot_id: u8,
    pub module_name: String,
    pub event_type: u8,
    pub value: f32,
    pub timestamp: DateTime<Utc>,
}

配置事件

/// Emitted when a node's NVS configuration has been successfully written.
pub struct NodeProvisioningComplete {
    pub node_id: u8,
    pub port: String,
    pub config_keys: Vec<String>,
    pub preset: Option<DeploymentPreset>,
    pub verified: bool,
    pub timestamp: DateTime<Utc>,
}

/// Emitted when mesh provisioning completes for all nodes in a config file.
pub struct MeshProvisioningComplete {
    pub session_id: SessionId,
    pub node_count: usize,
    pub failed_nodes: Vec<u8>,
    pub timestamp: DateTime<Utc>,
}

不变量

固件架构不变量

# 不变量 理由 强制机制
1 核心 0 仅处理 WiFi + CSI 回调;核心 1 处理所有 DSP 防止计算密集型 DSP 导致 WiFi 协议栈损坏。CSI 回调在核心 0 的中断服务程序上下文中运行。 FreeRTOS 任务绑定:DSP 任务使用 xTaskCreatePinnedToCore(..., 1)
2 核心之间的 SPSC 环形缓冲区防止内存争用 无锁单生产者单消费者避免了中断服务程序上下文与任务上下文之间的互斥锁 csi_spsc_ring 实现,使用原子读写索引
3 CSI 回调速率限制为 50 Hz 防止在高 CSI 速率(混杂模式下 100-500 Hz)时 lwIP pbuf 耗尽。这是问题 #127 的根本原因。 csi_collector.c 中的 20 ms 最小间隔检查
4 sendto() 使用 100 ms ENOMEM 退避 当 lwIP pbuf 池暂时耗尽时,UDP 发送可能失败;立即重试会加剧问题 stream_sender.c 检查 errno == ENOMEM 并延迟
5 二进制文件必须适配 1 MB OTA 分区 ESP32-S3 分区表为出厂应用分配 1 MB。超出此大小将阻止 OTA 更新。 firmware-ci.yml 中 950 KB 的 CI 大小门禁
# 不变量 依据 执行机制

WASM 运行时不变量

# 不变量 依据 执行机制
6 WASM 模块每帧最多 10 ms 防止失控模块阻塞 Tier 2 DSP 流水线并错过 CSI 帧 esp_timer_get_time() 测量 + 预算故障计数器
7 连续 10 次预算故障后自动停止 优雅降级:故障模块被停止,Tier 2 流水线继续不受影响 WasmModuleSlot 中的故障计数器,状态转换到 Error
8 默认启用 RVF 签名验证 WASM 上传属于远程代码执行;签名确保真实性 Kconfig 和 NVS 回退中默认 wasm_verify=1
9 WASM 内存区在启动时预分配(640 KB PSRAM) 动态 malloc/free 循环会在数天连续运行中使 PSRAM 碎片化 每个槽位固定 160 KB 内存区,卸载时清零但永不释放
10 最多 4 个并发 WASM 模块槽位 限制 PSRAM 使用并防止计算资源耗尽 WASM_MAX_SLOTS 常量,在加载时验证

聚合不变量

# 不变量 依据 执行机制
11 仅进行特征级融合(绝不进行原始相位对齐) ESP32 晶振漂移 20-50 ppm 使跨节点相位相干不可能 聚合器独立提取每个节点的特征,然后进行相关
12 缺失节点产生部分融合帧,而不是错误 节点可能掉线;系统必须优雅降级 FusedFrame.node_features 中每个节点一个 Option<CsiFrame>
13 序列号间隙 < 100 ms 时进行插值 短暂的 UDP 丢失不应在下游处理中造成不连续 NodeState 环形缓冲区中的间隙检测 + 线性插值

配网不变量

# 不变量 依据 执行机制
14 WiFi 凭据绝不能出现在受跟踪文件中 防止凭据通过 git 历史泄露 对 sdkconfig 使用 .gitignore,provision.py 仅写入 NVS
15 TDM 槽位索引在网状网络内必须唯一 重复槽位会导致传输冲突 MeshProvisionerService 中的验证,配置文件模式检查
16 hop_count 必须等于 chan_list.len() 不匹配会导致固件读取未初始化的通道值 CLI 验证 + NVS 写入时断言

领域服务

CSI 采集服务

管理核心 0 上的 ESP-IDF CSI API 生命周期。

pub trait CsiCollectionService {
    /// Register CSI callback, configure promiscuous mode, set channel.
    /// Rate-limits callback invocations to 50 Hz.
    fn start_collection(&mut self, config: &NvsConfig) -> Result<(), CsiError>;

    /// Stop CSI collection and deregister callback.
    fn stop_collection(&mut self) -> Result<(), CsiError>;

    /// Get current collection statistics (frames/sec, drops, errors).
    fn stats(&self) -> CollectionStats;
}

边缘处理流水线

编排核心 1 上的 Tier 1-2 DSP 链。

pub trait EdgeProcessingPipeline {
    /// Process a single CSI frame through the configured tier pipeline.
    /// Returns vitals packet (if Tier 2 interval elapsed) and/or compressed frame.
    fn process_frame(
        &mut self,
        raw: &RawCsiFrame,
    ) -> Result<ProcessingOutput, ProcessingError>;

    /// Reconfigure the pipeline tier at runtime (e.g., via NVS update).
    fn set_tier(&mut self, tier: EdgeTier) -> Result<(), TierError>;

    /// Get calibration status (0.0-1.0, 1.0 = fully calibrated after 1200 frames).
    fn calibration_progress(&self) -> f32;
}

pub struct ProcessingOutput {
    pub vitals: Option<VitalsPacket>,
    pub compressed: Option<CompressedFrame>,
    pub events: Vec<EdgeEvent>,
}

WASM 模块管理器

管理 4 个槽位中 WASM 模块的生命周期。

pub trait WasmModuleManager {
    /// Load an RVF container into the next available slot.
    /// Verifies signature (if wasm_verify=1), checks host API compatibility,
    /// validates binary fits within arena.
    fn load_module(&mut self, rvf: &RvfContainer) -> Result<u8, WasmLoadError>;

    /// Start a loaded module (calls on_init()).
    fn start_module(&mut self, slot_id: u8) -> Result<(), WasmExecError>;

    /// Stop a running module.
    fn stop_module(&mut self, slot_id: u8) -> Result<(), WasmExecError>;

    /// Unload a module from its slot (zeroes the arena).
    fn unload_module(&mut self, slot_id: u8) -> Result<(), WasmLoadError>;

    /// Get telemetry for all slots.
    fn list_modules(&self) -> Vec<(u8, Option<&LoadedModule>, &ModuleState, &WasmTelemetry)>;

    /// Execute on_frame() for all running modules within the budget.
    fn dispatch_frame(&mut self, n_sc: i32) -> Vec<WasmEvent>;
}

特征融合服务

将每个节点的特征在服务端融合为一致的多节点观测。

pub trait FeatureFusionService {
    /// Fuse features from N nodes for one time window.
    /// - Motion energy: max across nodes
    /// - Breathing band: highest-SNR node as primary
    /// - Location: cross-node amplitude ratios
    fn fuse(
        &self,
        node_features: &[Option<CsiFrame>],
    ) -> Result<FusedFrame, FusionError>;

    /// Compute cross-node correlation matrix.
    fn cross_correlate(
        &self,
        features: &[Option<CsiFrame>],
    ) -> Array2<f64>;
}

配网服务

编排单个节点和网状网络的完整配网工作流。

pub trait ProvisioningService {
    /// Provision a single node with the given configuration.
    fn provision_node(
        &mut self,
        port: &PortIdentity,
        config: &NvsConfig,
    ) -> Result<NodeProvisionResult, ProvisionError>;

    /// Provision all nodes defined in a mesh config file.
    fn provision_mesh(
        &mut self,
        mesh: &MeshConfig,
    ) -> Result<Vec<NodeProvisionResult>, ProvisionError>;

    /// Read back the current NVS configuration from a connected device.
    fn read_config(
        &self,
        port: &PortIdentity,
    ) -> Result<NvsConfig, ProvisionError>;

    /// Verify a provisioned node booted successfully.
    fn verify_boot(
        &self,
        port: &PortIdentity,
        timeout_secs: u32,
    ) -> Result<VerificationResult, ProvisionError>;

    /// Auto-detect connected ESP32-S3 devices.
    fn detect_ports(&self) -> Vec<PortIdentity>;
}

上下文地图

+------------------------------------------------------------------+
|                     Hardware Platform Domain                       |
+------------------------------------------------------------------+
|                                                                    |
|  +------------------+                                              |
|  |  Provisioning    |                                              |
|  |  Context         |--(writes NVS)---+                            |
|  |  (provision.py)  |                 |                            |
|  +------------------+                 |                            |
|                                       v                            |
|  +------------------+    SPSC    +------------------+              |
|  |  Sensor Node     |---------->|  Edge Processing  |              |
|  |  Context         |  ring buf |  Context          |              |
|  |  (Core 0)        |           |  (Core 1)         |              |
|  +--------+---------+           +--------+----------+              |
|           |                              |                         |
|           | UDP raw (0x01)               | feeds CSI data          |
|           |                              v                         |
|           |                     +------------------+               |
|           |                     |  WASM Runtime    |               |
|           |                     |  Context         |               |
|           |                     |  (Tier 3, Core 1)|               |
|           |                     +--------+---------+               |
|           |                              |                         |
|           | UDP raw   UDP vitals (0x02)  | UDP events (0x04)       |
|           | (0x01)    UDP compressed     |                         |
|           |           (0x03)             |                         |
|           +----------+------------------+                          |
|                      |                                             |
|                      v                                             |
|           +------------------+                                     |
|           |  Aggregation     |                                     |
|           |  Context         |                                     |
|           |  (Server-side)   |                                     |
|           +--------+---------+                                     |
|                    |                                               |
|                    | mpsc channel                                  |
|                    v                                               |
+------------------------------------------------------------------+
|                 DOWNSTREAM (Customer/Supplier)                    |
|  +-----------------+  +-----------------+  +-----------------+    |
|  | wifi-densepose  |  | wifi-densepose  |  | wifi-densepose  |    |
|  |   -signal       |  |   -nn           |  |   -mat          |    |
|  | (RuvSense)      |  | (Inference)     |  | (Disaster)      |    |
|  +-----------------+  +-----------------+  +-----------------+    |
+------------------------------------------------------------------+

关系类型:

上游 下游 关系 描述
配置 传感器节点 客户/供应商 配置上下文写入 NVS 配置,节点在启动时读取该配置
传感器节点 边缘处理 合作伙伴 通过同一芯片上的 SPSC 环形缓冲区紧密耦合
边缘处理 WASM 运行时 客户/供应商 边缘流水线通过 Host API 向 WASM 模块提供 CSI 数据
传感器节点 聚合 已发布语言 ADR-018 二进制线路格式(魔数、固定偏移)
边缘处理 聚合 已发布语言 生命体征(0xC5110002)、压缩(0xC5110005)和特征向量(0xC5110003)线路格式
WASM 运行时 聚合 已发布语言 WASM 事件(0xC5110004)线路格式
聚合 下游 crate 客户/供应商 聚合器生成 FusedFrame,由 signal/nn/mat 消费

防腐层

聚合器到流水线 ACL

聚合器在硬件特定的 ESP32 二进制线路格式与 wifi-densepose Rust 流水线类型之间进行转换。

/// Adapts raw ESP32 UDP packets to the wifi-densepose-signal CsiData type.
pub struct Esp32ToPipelineAdapter {
    /// Maps ADR-018 magic bytes to frame type
    frame_parser: FrameParser,
    /// Converts ESP32 I/Q byte pairs to f32 amplitude/phase
    iq_converter: IqConverter,
}

impl Esp32ToPipelineAdapter {
    /// Parse a raw UDP datagram from an ESP32 node into a pipeline-ready frame.
    /// Handles magic byte demuxing:
    ///   0xC5110001 -> raw CSI frame
    ///   0xC5110002 -> vitals packet
    ///   0xC5110003 -> feature vector (ADR-069, 48-byte 8-dim)
    ///   0xC5110005 -> compressed frame (decompress first)
    ///   0xC5110004 -> WASM event packet
    pub fn parse_datagram(
        &self,
        data: &[u8],
        src_addr: SocketAddr,
    ) -> Result<ParsedFrame, ParseError> {
        /* ... */
    }
}

pub enum ParsedFrame {
    RawCsi(CsiFrame),
    Vitals(VitalsPacket),
    CompressedCsi(CsiFrame), // decompressed
    WasmEvent(WasmEventEmitted),
}

WASM 主机 API ACL

Host API 充当 WASM 模块世界(no_std、wasm32 ABI)与固件 C 数据结构之间的防腐层。

/// Translates between WASM3 linear memory and firmware C structs.
/// Each Host API function validates indices, clamps values, and converts types.
pub struct WasmHostApiAdapter {
    /// Pointer to current CSI frame data (set before each on_frame dispatch)
    current_frame: *const EdgeProcessingState,
    /// Event buffer for this dispatch cycle
    event_buffer: Vec<WasmEvent>,
}

impl WasmHostApiAdapter {
    /// csi_get_phase(sc_idx: i32) -> f32
    /// Validates sc_idx is within [0, n_subcarriers), returns 0.0 if out of bounds.
    pub fn get_phase(&self, sc_idx: i32) -> f32 { /* ... */ }

    /// csi_emit_event(event_type: i32, value: f32) -> void
    /// Validates event_type is within the module's declared event ID range.
    /// Applies dead-band filter: suppresses if |value - last_emitted| < threshold.
    pub fn emit_event(&mut self, event_type: i32, value: f32) { /* ... */ }
}

配置到 NVS ACL

配置工具在人类可读的 CLI 参数 / JSON 配置文件与 ESP-IDF NVS 二进制格式之间进行转换。

/// Adapts CLI/JSON configuration to ESP32 NVS binary partition format.
/// Handles type conversions, validation, and encoding.
pub struct ProvisioningAdapter {
    /// Maps CLI flag names to NVS key names and types
    key_registry: HashMap<String, NvsKeySpec>,
}

pub struct NvsKeySpec {
    pub nvs_key: String,       // e.g., "edge_tier"
    pub nvs_type: NvsType,     // u8, u16, u32, string, blob
    pub default: Option<String>,
    pub validator: Box<dyn Fn(&str) -> bool>,
}

impl ProvisioningAdapter {
    /// Convert a typed NvsConfig struct to a list of NVS binary writes.
    pub fn to_nvs_entries(&self, config: &NvsConfig) -> Vec<NvsEntry> { /* ... */ }

    /// Parse an NVS binary partition dump into a typed NvsConfig.
    pub fn from_nvs_partition(&self, data: &[u8]) -> Result<NvsConfig, ParseError> { /* ... */ }
}

线路协议摘要

所有 ESP32 UDP 数据包共享一个 4 字节魔数前缀,用于在聚合器处进行解复用。

魔数 名称 来源 大小 速率 描述
0xC5110001 原始 CSI Tier 0+ ~128-404 B 20-28.5 Hz 每个子载波的完整 I/Q
0xC5110002 生命体征 Tier 2+ 32 B 1 Hz(可配置) 存在、BPM、跌倒标志
0xC5110003 特征向量 Tier 2+ 48 B 1 Hz ADR-069 的 8 维归一化特征,用于 Cognitum Seed RVF 摄取
0xC5110004 WASM 事件 Tier 3 可变 事件驱动 模块 event_type + value 元组
0xC5110005 压缩 Tier 1+ 可变 20-28.5 Hz XOR+RLE 差分压缩 CSI(从 0xC5110003 重新分配)

硬件约束与实测性能

指标 值 来源
CSI 帧率 28.5 Hz(实测) ADR-039 硬件基准测试
启动至就绪 3.9 s WiFi 连接占主导
二进制大小 925 KB(1 MB 中剩余 10%) 包含完整 WASM3 运行时
WASM 初始化时间 106 ms 4 个槽位,160 KB 内存区域
WASM 二进制大小(7 个模块) 13.8 KB wasm32-unknown-unknown 发布版
可用内部 RAM 316 KiB 测试板无 PSRAM
晶振漂移 20-50 ppm 每小时 72-180 ms 偏差
BOM(3 节点入门套件) $54 ADR-012 物料清单

参考资料

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView