fix(coord): back off minutes behind a captive portal instead of every 16s - #48
Merged
Conversation
… 16s do_noise_handshake() now flags a captive portal in two ways: an HTTP 302 in the Noise-upgrade response, or the TCP connection closing outright before any response arrives (some portals do this instead of a redirect). Either sets s_captive_portal, which the COORD_RECONNECTING backoff checks: instead of the usual <=16s exponential backoff, it waits a flat 5 minutes. Hammering a portal every 16s until the user logs in is futile and churns TLS setup/teardown that starves the radio and internal heap for no benefit. The wait remains command-queue-interruptible (xQueueReceive with the backoff as timeout), so a real event — new creds, a rebind, the portal clearing — still wakes the loop early; a false-positive portal detection is harmless for the same reason. Adapted from cplewes/microlink@8f2ff39b and @5c7303b4. Closes #23 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fudio101
added a commit
that referenced
this pull request
Aug 19, 2026
Issue #23 (captive-portal detection) was closed and merged via PR #48 on 2026-08-18 but the tracker table was never updated to reflect it — the only row still missing a done marker. Also prunes the Notes section's two "conflicts to resolve before scoping" callouts (#11, #2-vs-#17), both already resolved in their own rows. Co-authored-by: Adrian.Nguyen-Qualgo <nguyen.ndt@qualgo.net> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
do_noise_handshake()now flags a captive portal in two ways:portals do this instead of a redirect).
Either sets a module-static
s_captive_portalflag, which theCOORD_RECONNECTINGbackoff checks: instead of the usual<=16sexponentialbackoff, it waits a flat 5 minutes. Hammering a portal every 16s until the
user logs in is futile and churns TLS setup/teardown for no benefit, wasting
radio time and internal heap. The wait remains command-queue-interruptible
(it's the existing
xQueueReceive(ml->coord_cmd_queue, &wake_cmd, pdMS_TO_TICKS(backoff_ms))), so a real event — new creds, a rebind, theportal clearing — still wakes the loop early; a false-positive portal
detection is harmless for the same reason.
Source
Adapted from
cplewes/microlink8f2ff39b+5c7303b4(not cherry-picked — base has diverged too far).Related issues
Closes #23
Builds on top of #47 (the teardown-UAF liveness bitmask, same file) —
branched from that PR's tip and rebased onto
mainonce #47 merged, sothis diff is just the captive-portal change.
Test plan
idf.py buildisn't runnable in this sandbox (no ESP-IDF installed).Manual check:
grep -n "s_captive_portal" components/microlink/src/ml_coord.cshows exactly 5 uses (declare + 2 sets + check + clear). Needs hardware
re-test behind an actual captive portal to confirm detection fires and the
5-minute backoff is observed, plus confirm a real wake (rebind) still
interrupts it promptly.