#pragma once #include #include "esp_err.h" #include "wifi_provisioning.h" /** * Which photo-fetch behavior this wake cycle should use -- normally the * idempotent GET /frame/image (the server decides on its own whether to * advance, based on its configured refresh interval, so a plain * wake/reboot never skips a photo just by asking), or POST * /frame/advance / POST /frame/back to force a move in either direction * (the next-photo / back-photo buttons). */ typedef enum { FETCH_NORMAL, FETCH_ADVANCE, FETCH_BACK, } fetch_action_t; /** * Connects to the home WiFi network described by cfg, retrying up to * CONFIG_FRAME_STA_CONNECT_MAX_RETRIES times with a per-attempt timeout of * CONFIG_FRAME_STA_CONNECT_TIMEOUT_MS. Returns ESP_OK once an IP address * has been obtained, ESP_FAIL if all retries are exhausted. */ esp_err_t frame_wifi_connect_sta(const frame_config_t *cfg); /** * Runs the frame's normal-operation cycle: fetch the current image from * cfg->toolsserver per `action` (see fetch_action_t), display it, and * deep-sleep until the next refresh. * * If show_management_qr is true (the manage button was held), the * displayed photo gets a small "scan to manage" QR overlay in the * top-right corner linking to the server's config page, held for 30 * seconds (the device stays awake), then reverted back to the plain * photo before proceeding to the normal sleep-interval logic. * * battery_percent (0-100, or -1 for "no reading" -- see * battery_read_percent()) is shown on the management menu overlay and * reported to the server after a successful fetch; -1 skips both. */ void frame_client_run(const frame_config_t *cfg, fetch_action_t action, bool show_management_qr, int battery_percent);