2df2a14df6
A freshly-claimed device on a noon-daily schedule would otherwise sit
dark for up to 24 h after WiFi setup waiting for its first image. The
schedule kicks in only AFTER an image has actually been displayed.
Mechanism: at the bottom of normal_operation_impl, re-read NVS_KEY_IMG_ID
to see whether any successful 200-with-integrity-OK persisted an image
id this cycle (or any prior). If still -1, override sleepMs to
FIRST_IMAGE_POLL_INTERVAL_MS (15 s) — bypassing the schedule and the
clamp range, since SLEEP_CLAMP_MIN_MS is about runaway protection in
steady state and the bootstrap window is naturally bounded by "first
image arrives."
Tests:
- FW-FIRST-IMG-A: 204 with no img_id in NVS → 15s override fires
even when server says 6 hours.
- FW-FIRST-IMG-B: img_id pre-set, 200 cycle → server interval honored
(override doesn't trap the device in 15s forever).
- FW-FIRST-IMG-C: first 200 ever (img_id was -1, now persisted) →
server interval applies starting THIS cycle, no extra 15s nap.
Also patched FW-03 (304 sleep timing) to pre-set img_id so the test
exercises what it claims; 304 in production only happens when the
device already holds the image, so the override would never fire there.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
#pragma once
|
|
// Mirror of src/config.h for use in native unit tests.
|
|
// Values must match src/config.h so test assertions stay consistent.
|
|
#define APP_BASE_URL "https://pictureframe.edholm.me"
|
|
#define NVS_NAMESPACE "pf"
|
|
#define NVS_KEY_SSID "ssid"
|
|
#define NVS_KEY_PASS "pass"
|
|
#define NVS_KEY_IMG_ID "img_id"
|
|
#define NVS_KEY_DRAW_NEEDED "draw"
|
|
#define NVS_KEY_JUST_PROVISIONED "just_prov"
|
|
#define IMAGE_PATH "/img.bin"
|
|
#define FETCH_INTERVAL_MS_FALLBACK 60000ULL
|
|
#define SLEEP_CLAMP_MIN_MS 30000ULL
|
|
#define SLEEP_CLAMP_MAX_MS (25ULL * 60ULL * 60ULL * 1000ULL)
|
|
#define FIRST_IMAGE_POLL_INTERVAL_MS 15000ULL
|
|
#define WIFI_TIMEOUT_MS 30000
|
|
#define RESET_HOLD_MS 5000
|
|
#define AP_IP "192.168.4.1"
|
|
#define PIN_CS 5
|
|
#define PIN_DC 17
|
|
#define PIN_RST 16
|
|
#define PIN_BUSY 4
|
|
#define PIN_SCK 18
|
|
#define PIN_MOSI 23
|
|
#define PIN_BTN_RESET 0
|
|
// Color constants (also defined in Arduino mock, repeated here for clarity)
|
|
#define COLOR_BLACK 0x0
|
|
#define COLOR_WHITE 0x1
|
|
#define COLOR_YELLOW 0x2
|
|
#define COLOR_RED 0x3
|
|
#define COLOR_BLUE 0x5
|
|
#define COLOR_GREEN 0x6
|