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/viewport_state.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'main/viewport_state.c') diff --git a/main/viewport_state.c b/main/viewport_state.c index 7ddf737..a67745a 100644 --- a/main/viewport_state.c +++ b/main/viewport_state.c @@ -1,7 +1,9 @@ #include "viewport_state.h" +#include #include +#include "esp_mac.h" #include "esp_timer.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" @@ -9,6 +11,22 @@ static viewport_state_t s_state; static SemaphoreHandle_t s_mutex; +// Populate viewport_name with the full base MAC, colons stripped +// (e.g. e8:f6:0a:e0:90:94 → "e8f60ae09094"). Stable across reboots, +// globally unique, and 12 alphanumeric chars — fits comfortably under +// the 32-char mDNS hostname limit with the "viewport-" prefix. +// POST /config can override it with a friendlier name. +static void seed_mac_and_name(char *mac_str, size_t mac_cap, + char *name, size_t name_cap) +{ + uint8_t mac[6] = {0}; + esp_read_mac(mac, ESP_MAC_BASE); + snprintf(mac_str, mac_cap, "%02x:%02x:%02x:%02x:%02x:%02x", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + snprintf(name, name_cap, "%02x%02x%02x%02x%02x%02x", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); +} + void viewport_state_init(void) { memset(&s_state, 0, sizeof(s_state)); @@ -19,6 +37,8 @@ void viewport_state_init(void) s_state.orientation = VIEWPORT_ORIENTATION_PORTRAIT; s_state.boot_us = (uint64_t)esp_timer_get_time(); s_state.last_frame_us = -1; + seed_mac_and_name(s_state.mac_str, sizeof(s_state.mac_str), + s_state.viewport_name, sizeof(s_state.viewport_name)); s_mutex = xSemaphoreCreateMutex(); } -- cgit v1.2.3