a0dc4e0115
Closes the sell-to-friend gap where a buyer's freshly-reset device
would briefly display the seller's photos before the buyer reached
/setup/{mac} to claim. The firmware had no way to tell the server
"I just got reset" — now it does.
Flow:
- WiFi-setup completion (handle_connect in main.cpp) writes
NVS_KEY_JUST_PROVISIONED=1 alongside the SSID/PASS save.
- Every poll while the flag is set sends X-Just-Provisioned: 1.
- Server (DeviceImageController, paired commit on the webApp side)
responds with 204 + X-Interval-Ms when the binding is stale,
forcing the device to its setup-QR fallback. Once the user
re-claims via /setup/{mac}, the binding is fresh, and the server
answers with X-Claimed: 1 alongside whatever response code applies.
- Firmware clears the NVS flag on seeing X-Claimed: 1 — once
cleared, the device is back to normal long-stable polling.
Tests:
- PROV-A: flag set in NVS → header on the request
- PROV-B: no flag → no header (steady state)
- PROV-C: response with X-Claimed: 1 → flag cleared
- PROV-D: response without X-Claimed → flag stays (so the next
poll keeps signaling "not yet acknowledged")
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
1.1 KiB
C
32 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 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
|