From 865c4859d710870245ae7954e729edcaf442a921 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 14 Jun 2026 20:11:21 -0500 Subject: Default name = MAC; brief wake on boot; drop dead touch defences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- main/mdns_service.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'main/mdns_service.c') diff --git a/main/mdns_service.c b/main/mdns_service.c index 21cd464..05d8c23 100644 --- a/main/mdns_service.c +++ b/main/mdns_service.c @@ -17,6 +17,8 @@ static const uint16_t PORT = 80; // Pull hostname + TXT values from viewport_state under one lock acquisition, // then push them at the mDNS service. mdns_service_add() rejects with // INVALID_ARG if the hostname isn't set, so order matters on first apply. +// viewport_name is always populated (MAC-derived default) so the hostname +// is always `viewport-`. static esp_err_t apply_state(bool include_hostname) { char hostname[80]; @@ -25,11 +27,8 @@ static esp_err_t apply_state(bool include_hostname) viewport_state_lock(); viewport_state_t *st = viewport_state_get(); - snprintf(hostname, sizeof(hostname), "viewport%s%s", - st->viewport_name[0] ? "-" : "", - st->viewport_name[0] ? st->viewport_name : ""); - snprintf(name, sizeof(name), "%s", - st->viewport_name[0] ? st->viewport_name : ""); + snprintf(hostname, sizeof(hostname), "viewport-%s", st->viewport_name); + snprintf(name, sizeof(name), "%s", st->viewport_name); resolution = viewport_state_resolution_str(); orientation = (st->orientation == VIEWPORT_ORIENTATION_PORTRAIT) ? "portrait" : "landscape"; @@ -53,9 +52,7 @@ esp_err_t mdns_service_start(void) char hostname[80]; viewport_state_lock(); viewport_state_t *st = viewport_state_get(); - snprintf(hostname, sizeof(hostname), "viewport%s%s", - st->viewport_name[0] ? "-" : "", - st->viewport_name[0] ? st->viewport_name : ""); + snprintf(hostname, sizeof(hostname), "viewport-%s", st->viewport_name); viewport_state_unlock(); ESP_RETURN_ON_ERROR(mdns_init(), TAG, "mdns_init"); -- cgit v1.2.3