Fetch refresh interval from server instead of hardcoding it

Replaces check_server_reachable() (bare bool, GET /health) with
fetch_frame_config(), which GETs the server's new /frame/config endpoint
instead -- doubles as the reachability check (any completed HTTP response
counts, same as before) and delivers the server-configured
refresh_interval_s, used for the success-path deep sleep duration instead
of the Kconfig-only default.

Parses the tiny JSON response with a hand-rolled scalar extractor
(json_extract_uint) rather than pulling in a JSON library -- cJSON isn't
bundled in this ESP-IDF install, and a single flat integer field doesn't
justify a new dependency. Verified standalone against exactly the JSON
shape the server emits, including a missing-field fallback case.

FRAME_SLEEP_INTERVAL_S (Kconfig) is now just the fallback used before the
device has ever reached a configured server, or if the response is
missing/unparseable -- documented as such in its help text.
This commit is contained in:
2026-07-18 15:34:37 -04:00
parent 6e353c2271
commit 21af41ff66
2 changed files with 89 additions and 17 deletions
+14 -7
View File
@@ -45,11 +45,13 @@ menu "ESPresso Frame Configuration"
stored home WiFi network before counting it as a failed retry.
config FRAME_SERVER_CHECK_TIMEOUT_MS
int "Tools server reachability check timeout (ms)"
int "Tools server /frame/config request timeout (ms)"
default 3000
help
How long to wait for an HTTP response from the tools server
when checking reachability on the post-connect status screen.
How long to wait for a GET /frame/config response from the
tools server -- doubles as both the reachability check for the
post-connect status screen and the source of the
server-configured refresh interval below.
config FRAME_FETCH_TIMEOUT_MS
int "Image fetch HTTP timeout (ms)"
@@ -61,12 +63,17 @@ menu "ESPresso Frame Configuration"
check's timeout.
config FRAME_SLEEP_INTERVAL_S
int "Deep sleep interval between refreshes (seconds)"
int "Fallback deep sleep interval between refreshes (seconds)"
default 3600
help
How long the device deep-sleeps between successful
fetch-and-display cycles. Lower this for bench testing so you
don't have to wait an hour per iteration.
The refresh interval is normally set server-side (the "Refresh
interval" field in the server's web UI, delivered via GET
/frame/config) so it can be changed without reflashing. This
value is only a fallback: used before the device has ever
successfully reached a configured server, or if the server's
response doesn't include a valid interval (e.g. an older
server version). Lower this for bench testing so you don't
have to wait an hour per iteration.
config FRAME_RETRY_INTERVAL_S
int "Deep sleep interval after a failed cycle (seconds)"