Back to Ruview

Edge Intelligence Modules — WiFi-DensePose

docs/edge-modules/README.md

0.7.07.0 KB
Original Source

Edge Intelligence Modules — WiFi-DensePose

60 WASM modules that run directly on an ESP32 sensor. No internet needed, no cloud fees, instant response. Each module is a tiny file (5-30 KB) that reads WiFi signal data and makes decisions locally in under 10 ms.

Quick Start

bash
# Build all modules for ESP32
cd rust-port/wifi-densepose-rs/crates/wifi-densepose-wasm-edge
cargo build --target wasm32-unknown-unknown --release

# Run all 632 tests
cargo test --features std

# Upload a module to your ESP32
python scripts/wasm_upload.py --port COM7 --module target/wasm32-unknown-unknown/release/module_name.wasm

Module Categories

CategoryModulesTestsDocumentation
Core781core.md
Medical & Health538medical.md
Security & Safety642security.md
Smart Building538building.md
Retail & Hospitality538retail.md
Industrial538industrial.md
Exotic & Research10~60exotic.md
Signal Intelligence654signal-intelligence.md
Adaptive Learning442adaptive-learning.md
Spatial & Temporal656spatial-temporal.md
AI Security220ai-security.md
Quantum & Autonomous430autonomous.md
Total65632

How It Works

  1. WiFi signals bounce off people and objects in a room, creating a unique pattern
  2. The ESP32 chip reads these patterns as Channel State Information (CSI) — 52 numbers that describe how each WiFi channel changed
  3. WASM modules analyze the patterns to detect specific things: someone fell, a room is occupied, breathing rate changed
  4. Events are emitted locally — no cloud round-trip, response time under 10 ms

Architecture

WiFi Router ──── radio waves ────→ ESP32-S3 Sensor
                                      │
                                      ▼
                              ┌──────────────┐
                              │  Tier 0-2    │  C firmware: phase unwrap,
                              │  DSP Engine  │  stats, top-K selection
                              └──────┬───────┘
                                      │ CSI frame (52 subcarriers)
                                      ▼
                              ┌──────────────┐
                              │   WASM3      │  Tiny interpreter
                              │   Runtime    │  (60 KB overhead)
                              └──────┬───────┘
                                      │
                          ┌───────────┼───────────┐
                          ▼           ▼           ▼
                    ┌──────────┐ ┌──────────┐ ┌──────────┐
                    │ Module A │ │ Module B │ │ Module C │
                    │ (5-30KB) │ │ (5-30KB) │ │ (5-30KB) │
                    └────┬─────┘ └────┬─────┘ └────┬─────┘
                         │           │           │
                         └───────────┼───────────┘
                                     ▼
                              Events + Alerts
                         (UDP to aggregator or local)

Host API

Every module talks to the ESP32 through 12 functions:

FunctionReturnsDescription
csi_get_phase(i)f32WiFi signal phase angle for subcarrier i
csi_get_amplitude(i)f32Signal strength for subcarrier i
csi_get_variance(i)f32How much subcarrier i fluctuates
csi_get_bpm_breathing()f32Breathing rate (BPM)
csi_get_bpm_heartrate()f32Heart rate (BPM)
csi_get_presence()i32Is anyone there? (0/1)
csi_get_motion_energy()f32Overall movement level
csi_get_n_persons()i32Estimated number of people
csi_get_timestamp()i32Current timestamp (ms)
csi_emit_event(id, val)Send a detection result to the host
csi_log(ptr, len)Log a message to serial console
csi_get_phase_history(buf, max)i32Past phase values for trend analysis

Event ID Registry

RangeCategoryExample Events
0-99CoreGesture detected, coherence score, anomaly
100-199MedicalApnea, bradycardia, tachycardia, seizure
200-299SecurityIntrusion, perimeter breach, loitering, panic
300-399Smart BuildingZone occupied, HVAC, lighting, elevator, meeting
400-499RetailQueue length, dwell zone, customer flow, turnover
500-599IndustrialProximity warning, confined space, vibration
600-699ExoticSleep stage, emotion, gesture language, rain
700-729Signal IntelligenceAttention, coherence gate, compression, recovery
730-759Adaptive LearningGesture learned, attractor, adaptation, EWC
760-789Spatial ReasoningInfluence, HNSW match, spike tracking
790-819Temporal AnalysisPattern, LTL violation, GOAP goal
820-849AI SecurityReplay attack, injection, jamming, behavior
850-879Quantum-InspiredEntanglement, decoherence, hypothesis
880-899AutonomousInference, rule fired, mesh reconfigure

Module Development

Adding a New Module

  1. Create src/your_module.rs following the pattern:

    rust
    #![cfg_attr(not(feature = "std"), no_std)]
    #[cfg(not(feature = "std"))]
    use libm::fabsf;
    
    pub struct YourModule { /* fixed-size fields only */ }
    
    impl YourModule {
        pub const fn new() -> Self { /* ... */ }
        pub fn process_frame(&mut self, /* inputs */) -> &[(i32, f32)] { /* ... */ }
    }
    
  2. Add pub mod your_module; to lib.rs

  3. Add event constants to event_types in lib.rs

  4. Add tests with #[cfg(test)] mod tests { ... }

  5. Run cargo test --features std

Constraints

  • No heap allocation: Use fixed-size arrays, not Vec or String
  • No std: Use libm for math functions
  • Budget tiers: L (<2ms), S (<5ms), H (<10ms) per frame
  • Binary size: Each module should be 5-30 KB as WASM

References