feat(sensing): native macOS CoreWLAN WiFi sensing adapter #64
Reference in New Issue
Block a user
Delete Branch "feature/macos-corewlan"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add native macOS LiDAR / WiFi sensing support via CoreWLAN:
Review
Nice contribution — this adds macOS CoreWLAN support to the Python v1 pipeline, which complements ADR-025 (targeting the Rust v2 pipeline). The approach is solid: Swift helper binary + Python subprocess consumer, same pattern as the existing collectors.
What works well
Swift helper is clean —
mac_wifi.swiftis minimal (~34 lines), pollsrssiValue()/noiseMeasurement()at 10 Hz, outputs JSON lines. Good use ofsetbuf(stdout, nil)to prevent buffering issues.Auto-compile on first run —
MacosWifiCollector.start()compiles the Swift binary if missing. Smart for developer experience.Docker-on-Mac fix — The
/proc/net/wirelesscheck in the Linux branch prevents Docker containers on macOS from incorrectly tryingLinuxWifiCollector. Good defensive fix.Fits existing patterns — Produces
WifiSampledataclass, usesRingBuffer, follows the samestart()/stop()/get_samples()API as other collectors.Issues to address
1. Single-AP RSSI only (not multi-BSSID)
The Swift helper polls only the connected interface (
CWWiFiClient.shared().interface()), returning one RSSI value at a time. The Windows collector (WindowsWifiCollector) and the Rust ADR-022 pipeline scan all visible BSSIDs (10-30+) to create multi-AP spatial diversity.Consider adding a
--scanmode that callsinterface.scanForNetworks(withSSID: nil)to get all visible networks. This would match the multi-BSSID approach and significantly improve motion detection quality. Can be a follow-up PR.2. Synthetic
tx_bytes/rx_bytescountersThese increment monotonically at fixed values regardless of actual traffic. If any downstream code uses TX/RX bytes for feature extraction, this will produce misleading data. Consider either:
netstator/usr/sbin/nettop3. Missing
__init__.py/ module exportMacosWifiCollectoris imported inws_server.pyfromrssi_collector, but the diff doesn't update any__init__.pyif one exists. Verify the import path works.4. No cleanup of compiled binary
The auto-compiled
mac_wifibinary ends up inv1/src/sensing/alongside source code. Consider adding it to.gitignoreto prevent accidental commits, or building to abuild/subdirectory.5. PR title says "LiDAR"
The description mentions "native macOS LiDAR / WiFi sensing" but there's no LiDAR code — this is WiFi RSSI only. Minor, but should be corrected to avoid confusion.
Summary
Good first step. The single-AP limitation is the main gap vs. the ADR-022/025 approach, but this is still useful for basic presence/motion detection on macOS. Would be mergeable after addressing the synthetic counters and the PR title.
Changes pushed to your branch
I've pushed fixes and enhancements directly to your
feature/macos-corewlanbranch so you retain full contribution credit. Here's what was added:Python fixes
synth_tx += 1500/synth_rx += 3000produced misleading data. Now reportstx_bytes=0, rx_bytes=0(honest: macOS CoreWLAN doesn't expose per-interface byte counts)v1/src/sensing/mac_wifito.gitignoreto prevent the compiled Swift binary from being committedNew Rust platform adapters
Both follow the same
Command::new()→ parse →Vec<BssidObservation>pattern as the existingNetshBssidScanner:macos_scanner.rs—MacosCoreWlanScannermac_wifiSwift helper binaryserde_jsondependency)#[cfg(target_os = "macos")]linux_scanner.rs—LinuxIwScanneriw dev <iface> scanoutput (BSS stanza format)scan(requires root) andscan dump(cached, no root needed)wlan0)#[cfg(target_os = "linux")]Module updates
adapter/mod.rsandlib.rsupdated with#[cfg(target_os)]-gated module declarations and re-exportsThis addresses the review feedback from earlier. The PR should be ready for another review round.
Thank you @zqyhimself for the macOS CoreWLAN contribution! 🎉
Your Swift helper + Python adapter laid the foundation. We built on top of it with:
MacosCoreWlanScannerandLinuxIwScanneradaptersGreat first contribution — welcome to the project!