Skip to content

fix(csi): filter by MAC before the early rate gate - #1734

Open
mikhaellerik4-alt wants to merge 1 commit into
ruvnet:mainfrom
mikhaellerik4-alt:fix/csi-mac-filter-before-rate-gate
Open

fix(csi): filter by MAC before the early rate gate#1734
mikhaellerik4-alt wants to merge 1 commit into
ruvnet:mainfrom
mikhaellerik4-alt:fix/csi-mac-filter-before-rate-gate

Conversation

@mikhaellerik4-alt

Copy link
Copy Markdown

Problem

csi_collector.c runs the ADR-060 MAC filter after the early rate gate. The gate stamps s_last_process_us before the filter has a chance to run, so a frame from any transmitter claims the 20 ms window and is then dropped by the filter. The matched transmitter's next frame arrives inside the window that the foreign frame just consumed, and gets gated away.

The net effect is that configuring filter_mac starves the very stream it is meant to isolate.

Measurement

On an ESP32-C6 (v0.8.4, sdkconfig.defaults.esp32c6, node locked to its associated AP, --filter-mac set to that AP's BSSID):

CSI rate
before 1.7 CSI/s
after ~20 Hz (22 pps sustained)

Same board, same room, same channel (2447 MHz), only the ordering changed.

Fix

Move the s_filter_mac_set check above the rate gate.

  • The gate's purpose — capping processing at 50 Hz to avoid the SPI flash cache crash in the WiFi ISR (wDev_ProcessFiq) — is preserved: every frame that reaches the gate is still gated.
  • Filtering earlier only means the gate now sees fewer frames, never more, so the crash protection is not weakened.
  • When no filter is configured (s_filter_mac_set == false) the code path is byte-for-byte unchanged.

The filter keeps using the defensively-copied s_filter_mac rather than g_nvs_config, for the same reason as before (the wifi_init_sta clobber).

Testing

Built with ESP-IDF for esp32c6 and flashed to real hardware; CSI rate verified over a live UDP stream (ADR-018 0xC5110001 frames) for ~8 minutes of continuous capture. Vitals and sync frames are unaffected.

The early rate gate stamps s_last_process_us before the ADR-060 MAC
filter runs, so a frame from any foreign transmitter claims the 20 ms
window and is then discarded by the filter -- starving the filtered
stream. Measured on an ESP32-C6 locked to its associated AP: 1.7 CSI/s
instead of the expected ~20 Hz.

Moving the filter above the gate preserves the gate's crash protection
(processing is still capped at 50 Hz) while letting the matched
transmitter actually fill the slots. With no filter configured
(s_filter_mac_set == false) the behaviour is byte-for-byte unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant