RuView icon indicating copy to clipboard operation
RuView copied to clipboard

feat(macos-rssi-bridge): Mac WiFi card → sensing-server bridge

Open GriffinCanCode opened this issue 6 months ago • 0 comments

Summary

Adds scripts/macos-rssi-bridge/ — a standalone Swift + Rust bridge that turns any stock Mac into a RuView sensing-server "node 0" using only the built-in WiFi card. Useful while waiting on ESP32-S3 boards (or as a permanent extra node once they arrive).

  • Swift helper (mac_wifi.swift) wraps Apple's CoreWLAN and emits one JSON line per visible BSSID, ~1/s. Multi-BSSID format matches what v2/.../macos_scanner.rs expects (supersedes the single-AP v1 helper at archive/v1/src/sensing/mac_wifi.swift).
  • Rust binary (src/main.rs) spawns the helper, maintains a rolling per-AP RSSI history, packs each scan into an ESP32 CSI frame (magic = 0xC511_0001), and emits UDP on the same wire format wifi-densepose-sensing-server already consumes. RSSI per AP → pseudo-subcarrier amplitude (I), per-AP variance → Q channel.

The sensing-server pipeline runs unmodified. The crate is intentionally a standalone Cargo project (not a v2 workspace member) so it doesn't perturb the main build.

Why

Every AP in range beacons ~every 100 ms. When someone moves, multipath reflections shift and RSSI fluctuates. With 5–15 visible APs (your router + neighbors'), running variance and cross-AP correlation gives a real motion signal — coarser than CSI but useful for through-wall presence and room-level activity. Aligns with README.md §"Any WiFi: RSSI-only" and ADR-022.

Files

File Purpose
mac_wifi.swift CoreWLAN multi-BSSID scanner, JSON-lines output
src/main.rs Rust UDP emitter, ESP32 frame format (0xC511_0001)
Cargo.toml / Cargo.lock Standalone crate — not a v2 workspace member
Makefile build, scan, run, listen, test, clean, install-helper
README.md Build/run guide, tuning, macOS Location Services note, RSSI-vs-CSI capability table, wire format
dashboard.html Optional multistatic RF tomography UI (served on :9090)
listen.py Debug helper: prints magic/seq/rssi of arriving frames
presence_to_pose.py RSSI-derived presence → pose stub for downstream experimentation

Also adds scripts/macos-rssi-bridge/mac_wifi (compiled Swift helper, ~82 MB) to .gitignore. Cargo target/ is already covered.

macOS Sonoma 14.4+ note

Apple started redacting BSSIDs to 00:00:00:00:00:00 and SSIDs to "" unless the caller holds com.apple.wifi.scan or has Location Services granted. The Swift helper handles this transparently by synthesizing stable per-AP identifiers from (channel, RSSI bucket, ordinal), so the downstream pipeline still sees distinct virtual APs. Real SSIDs/BSSIDs (better cross-scan tracking) are opt-in via System Settings → Privacy & Security → Location Services. README documents this.

Test plan

  • [ ] cd scripts/macos-rssi-bridge && make build — Swift + Rust both compile (Swift 6.0+, Cargo 1.80+, tested on macOS 26 arm64)
  • [ ] make scan — single multi-BSSID scan, prints valid JSON lines
  • [ ] make test — Rust unit tests (frame builder, variance, RSSI mapping) pass
  • [ ] make run while wifi-densepose-sensing-server is running on 127.0.0.1:5005 — frames arrive, motion registers within ~5 baseline frames
  • [ ] make listen confirms magic/seq/rssi on the wire match the ESP32 format

Made with Cursor

GriffinCanCode avatar May 26 '26 16:05 GriffinCanCode