src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/http_api.c
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-14 20:11:21 -0500
committerLuke Hoersten <[email protected]>2026-06-14 20:11:21 -0500
commit865c4859d710870245ae7954e729edcaf442a921 (patch)
treec22cb7d60fb8ea3bba6e9e85b45779d0dfa87d4f /main/http_api.c
parent8e2de89efb540fd6a3dce2086216d3afc49e6831 (diff)
Default name = MAC; brief wake on boot; drop dead touch defences
- Seed viewport_name with the full base MAC, colons stripped (e8:f6:0a:e0:90:94 → "e8f60ae09094"). Stable across reboots, globally unique, 12 alphanumeric chars — well inside the mDNS hostname limit even with the "viewport-" prefix. - Add a mac_str field to viewport_state and expose it as the new "mac" key in GET /state and as a "mac" line on the info screen. - "Configured" no longer requires a viewport_name (it always has the MAC default); the scrypted URL alone gates outbound POSTs and the loading-vs-info screen choice. - Strip viewport_name[0] fallbacks in http_api / mdns / local_screens now that the field is never empty. - Replace the wake-on-boot-stays-on behaviour with a ~600 ms flash followed by sleep — long enough for the FT5426 touch IC to come out of its initial unresponsive state, short enough that an idle device doesn't burn the backlight. - Drop the touch defensive cruft added when we were chasing a PoE-power theory: the DEV_MODE=0x00 write at init, the touch_reset_pulse() call at init, and the runtime wedge-self-heal in the polling loop didn't actually fix anything — the wake-on-boot flash did. Also delete the display_touch_reset_pulse() helper since it now has zero callers.
Diffstat (limited to 'main/http_api.c')
-rw-r--r--main/http_api.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/main/http_api.c b/main/http_api.c
index 028d3a7..2c5ce87 100644
--- a/main/http_api.c
+++ b/main/http_api.c
@@ -39,9 +39,8 @@ static esp_err_t state_get_handler(httpd_req_t *req)
: (int64_t)((now_us - (uint64_t)st->last_frame_us) / 1000);
cJSON *root = cJSON_CreateObject();
- cJSON_AddItemToObject(root, "name",
- st->viewport_name[0] ? cJSON_CreateString(st->viewport_name)
- : cJSON_CreateNull());
+ cJSON_AddStringToObject(root, "name", st->viewport_name);
+ cJSON_AddStringToObject(root, "mac", st->mac_str);
cJSON_AddStringToObject(root, "version", VIEWPORT_VERSION);
cJSON_AddBoolToObject (root, "configured", st->configured);
cJSON_AddStringToObject(root, "state",
@@ -81,9 +80,7 @@ static esp_err_t config_get_handler(httpd_req_t *req)
viewport_state_t *st = viewport_state_get();
cJSON *root = cJSON_CreateObject();
- cJSON_AddItemToObject(root, "viewport",
- st->viewport_name[0] ? cJSON_CreateString(st->viewport_name)
- : cJSON_CreateNull());
+ cJSON_AddStringToObject(root, "viewport", st->viewport_name);
cJSON_AddItemToObject(root, "scrypted",
st->scrypted_url[0] ? cJSON_CreateString(st->scrypted_url)
: cJSON_CreateNull());
@@ -233,8 +230,11 @@ static esp_err_t config_post_handler(httpd_req_t *req)
st->brightness = bright;
}
- // A configured device has both a viewport name and a scrypted URL.
- st->configured = (st->viewport_name[0] && st->scrypted_url[0]);
+ // "Configured" means a scrypted URL has been registered — that's
+ // what gates outbound POSTs and the loading-vs-info screen content
+ // choice. The viewport_name always has a value (MAC-derived default
+ // until POST /config overrides), so it doesn't factor in here.
+ st->configured = (st->scrypted_url[0] != '\0');
viewport_state_unlock();