Skip to content

A battery frame rejoins Wi-Fi directly, asks for an update only when one waits, and paints with the radio off (W-921) - #375

Merged
wr merged 4 commits into
mainfrom
wells/w-921-battery-frames-spend-less-on-each-check-in
Nov 20, 2026
Merged

wr merged 4 commits into
mainfrom
wells/w-921-battery-frames-spend-less-on-each-check-in

Conversation

@wr

@wr wr commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

A frame on Battery now spends less radio time on each check-in. Three changes, as W-921 Battery frames spend less on each check-in set out:

  • It rejoins Wi-Fi directly. A wake out of deep sleep joins the access point the last wake used, by its BSSID and channel (kept in RTC memory), with no scan. If that fails (the access point moved channel, as in W-1056, or is gone), it falls back to the all-channel scan as before. It scans again at least once a day, and on the next wake after a weak join (below −75 dBm), so a better access point is still found. The pinned join is never saved: the Wi-Fi config is held in RAM for the rest of that wake, because the core's own reconnect writes whatever config is current. Improv saves to flash again explicitly. Skipping the join also skips WiFiManager's fixed 500 ms delay before every join.
  • It asks for an update only when one waits. /api/frame now answers X-FF-Update: 1|0 on every response (304, 503, 403 and views included). On self-hosted, app._firmware_answer is the one rule for both the check-in and /api/firmware, so the two cannot disagree; asking on a check-in does not count as handing a release over. On Cloud the front door says 1 exactly when its firmwareFor would let /api/firmware through to the server, and an unclaimed kit's pairing screen says 0. A frame that hears no header (an older server) asks as before. A USB frame's poll loop honours it too.
  • It paints with the radio off. Once a deep-sleep wake's check-in is answered, it runs the update check, then turns Wi-Fi off before any paint: a new picture, an error screen, or the repaint that clears the corner mark. On the EE02 the CPU also drops to 80 MHz for the ~27 s refresh, which is a wait on the panel. An update found there restarts the frame, which then fetches and paints the new picture.

Also:

  • Each wake reports how long the previous one was up and how long it took to join (up=… join=…q|s in X-Wake-Detail, q a quick rejoin, s a scan), so the cost of a wake can be read from the server without a serial cable.
  • The front door reads only the firmware rows of its files table for that check (a key range instead of LIKE), since it now runs on every check-in.

USB frames are unchanged apart from skipping /api/firmware when the check-in says nothing waits. Quick rejoin applies only to wakes out of deep sleep.

Verified

  • make test: 1397 passed, 2 skipped. New tests hold the check-in's X-FF-Update to what /api/firmware answers, for releases (not pressed, pressed before the image arrives, ready, already running it, another frame) and dev images (none, this board, already running it, another board, a frame not added yet).
  • hosted: vitest 323 passed (new test/update.test.ts), tsc --noEmit clean.
  • Firmware builds: ee02, xiao_ee03, release, release_ee02, generic_bench.
  • An independent review of the Wi-Fi config handling found no path for the pinned access point to reach flash (the core's reconnect, WiFiManager, Improv, the KEY2 portal, restarts). Its three lower-confidence notes are fixed in the second commit: the saved config is restored until the driver takes it, the quick rejoin runs only on a wake that ends in deep sleep, and a failing update check leaves the header out instead of failing the check-in.

Not verified

  • On hardware. The bench measurement at the battery, before and after, is still to do. The target is about 2 s awake per check-in, roughly 14 → 6 mAh a day at a 15-minute interval.
  • The Cloud half is not deployed yet. Until it is, a Cloud frame still opens the second connection (the front door answers it without starting the server).

Refs W-921

…one waits, and paints with the radio off (W-921)

A deep-sleep wake rejoins the last access point by BSSID and channel from
RTC memory, falling back to the all-channel scan; the pinned config stays
in RAM for the wake so it is never saved. /api/frame says X-FF-Update 1|0
(self-hosted: app._firmware_answer, the one rule for both asks; Cloud: the
front door's firmwareFor), and the frame asks /api/firmware only then.
Once the check-in is answered the wake is done with the network: the
update check, then Wi-Fi off (and the EE02 at 80 MHz) before any paint.
Each wake reports the last one's awake and join time in X-Wake-Detail.

Refs: W-921
@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown

W-921

wr added 3 commits October 19, 2026 00:30
…, and a failed update check never holds up a check-in (W-921)

From review: retry restoring the saved Wi-Fi config while the driver is
still connecting; try the quick rejoin only on a wake that ends in deep
sleep; leave X-FF-Update out (the frame then asks as before) if the
answer raises.

Refs: W-921
@wr
wr enabled auto-merge (squash) November 20, 2026 03:35
@wr
wr merged commit 33d506c into main Nov 20, 2026
6 checks passed
@wr
wr deleted the wells/w-921-battery-frames-spend-less-on-each-check-in branch November 20, 2026 03:39
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