Skip to content

src: Cap the STA re-scan backoff so reconnection stays brisk. - #7

Open
kwagyeman wants to merge 2 commits into
mainfrom
kwabena/halow_scan_interval
Open

kwagyeman wants to merge 2 commits into
mainfrom
kwabena/halow_scan_interval

Conversation

@kwagyeman

@kwagyeman kwagyeman commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Two commits, both making STA association robust when a scan misses the beacon.

1. Cap the STA re-scan backoff

2s/10s instead of the 2s/512s default, so a station that loses its AP
reconnects in seconds instead of minutes.

2. Hold the SPI bus quiet during the connect scan

On a board that radiates a scan-time spur into its own receiver (OpenMV AE3,
near 921.5 MHz), the continuous SPI polling done between events adds switching
noise that masks the beacon being scanned for, so association takes many sweeps.

This holds the bus quiet between real events during the JOIN scan, servicing the
transceiver at once whenever it asserts IRQ and pumping only at a bounded floor
otherwise. Gated to the JOIN scan, so the data path and the IRQ-driven
association handshake are untouched. Knob is MM_HALOW_SCAN_QUIET_MS, default 3.

Bench results

AE3, AP parked on the affected channel, 12 associations per run:

median worst failures
before 3.45s 26.9s 0
after 2.26s ~14s 0
  • after median matches a clear channel; the worst-case tail is roughly halved.
  • Clear channel (ch44) and connected throughput are unchanged.
  • Swept MM_HALOW_SCAN_QUIET_MS 1 to 6: 1 to 4 all pin the median at the
    clear-channel floor, 5 to 6 overshoot and degrade.

morselib defaults the station re-scan interval to a 512s limit with an
exponential backoff, so after a few failed attempts a station that has
lost its AP re-scans only every several minutes.  Set base 2s / limit
10s so a transient loss recovers within seconds instead of minutes.

Signed-off-by: kwagyeman <5694981+kwagyeman@users.noreply.github.com>
@kwagyeman
kwagyeman requested a review from dpgeorge September 26, 2026 18:20
The scan morselib runs internally when connecting is serviced from the
network poll, which otherwise pumps the driver continuously.  On a board
that radiates a scan-time spur into its own receiver, that steady SPI-bus
activity adds switching noise across the band, masks the beacon being
scanned for, and association takes many sweeps to catch it.

Between real events -- serviced at once whenever the transceiver asserts
its IRQ line -- hold the bus quiet, pumping only at a bounded floor so the
scan still advances.  Confined to the JOIN scan, so the data path and the
IRQ-driven association handshake are untouched.  On the AE3 this brings the
median association time on the affected channel from 3.5s to 2.3s, matching
a clear channel, with no change on a clear channel or in throughput.

Signed-off-by: kwagyeman <5694981+kwagyeman@users.noreply.github.com>
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