Device registry (/devices + hello), static-IP fallback, WS keepalive, uncompressed fonts
- gateway: GET /devices registry (per-IP connect count, timestamps, device/fw from new 'hello' protocol event); graceful utterance errors -> error event; uvicorn ws-ping-timeout 120s - firmware: hello on WS connect; static 192.168.86.53 fallback after 15s without DHCP; scan-on-boot removed (kept for diagnostics); ping_interval 8s; fonts regenerated --no-compress (compressed glyphs render blank with LV_USE_FONT_COMPRESSED off); 8MB factory partition; montserrat_28; LVGL lock timeout semantics fixed - docs: sauron endpoint plan, power ladder, versioning policy Known issue: 'Outside' AP association succeeds but no L2 traffic flows (no DHCP, no ARP) — worked once at 22:05 then never again; ToJ side verified clean. Investigation ongoing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+34
-2
@@ -14,6 +14,36 @@
|
||||
|
||||
static const char *TAG = "net";
|
||||
|
||||
static esp_netif_t *s_netif;
|
||||
static volatile bool s_got_ip;
|
||||
|
||||
/* Router DHCP has been observed to go silent for this MAC (flap throttling).
|
||||
* After 15 s without a lease, claim the previously granted address statically. */
|
||||
static void static_ip_fallback(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
vTaskDelay(pdMS_TO_TICKS(15000));
|
||||
if (!s_got_ip) {
|
||||
ESP_LOGW(TAG, "no DHCP lease after 15s — falling back to static 192.168.86.53");
|
||||
esp_netif_dhcpc_stop(s_netif);
|
||||
esp_netif_ip_info_t ip = { 0 };
|
||||
ip.ip.addr = esp_ip4addr_aton("192.168.86.53");
|
||||
ip.gw.addr = esp_ip4addr_aton("192.168.86.1");
|
||||
ip.netmask.addr = esp_ip4addr_aton("255.255.255.0");
|
||||
esp_netif_set_ip_info(s_netif, &ip);
|
||||
esp_netif_dns_info_t dns = { 0 };
|
||||
dns.ip.u_addr.ip4.addr = esp_ip4addr_aton("192.168.86.1");
|
||||
dns.ip.type = ESP_IPADDR_TYPE_V4;
|
||||
esp_netif_set_dns_info(s_netif, ESP_NETIF_DNS_MAIN, &dns);
|
||||
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
|
||||
tzset();
|
||||
esp_sntp_config_t sntp = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org");
|
||||
esp_netif_sntp_init(&sntp);
|
||||
gw_start();
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
static void scan_then_connect(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
@@ -38,7 +68,7 @@ static void wifi_event(void *arg, esp_event_base_t base, int32_t id, void *data)
|
||||
(void)arg;
|
||||
(void)data;
|
||||
if (base == WIFI_EVENT && id == WIFI_EVENT_STA_START) {
|
||||
xTaskCreate(scan_then_connect, "scan", 4096, NULL, 4, NULL);
|
||||
esp_wifi_connect();
|
||||
} else if (base == WIFI_EVENT && id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||
wifi_event_sta_disconnected_t *dc = (wifi_event_sta_disconnected_t *)data;
|
||||
ESP_LOGW(TAG, "wifi disconnected (reason %d), retrying", dc ? dc->reason : -1);
|
||||
@@ -47,6 +77,7 @@ static void wifi_event(void *arg, esp_event_base_t base, int32_t id, void *data)
|
||||
esp_wifi_connect();
|
||||
} else if (base == IP_EVENT && id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t *ev = (ip_event_got_ip_t *)data;
|
||||
s_got_ip = true;
|
||||
ESP_LOGI(TAG, "got ip " IPSTR, IP2STR(&ev->ip_info.ip));
|
||||
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
|
||||
tzset();
|
||||
@@ -65,7 +96,7 @@ void net_start(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
s_netif = esp_netif_create_default_wifi_sta();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
@@ -79,5 +110,6 @@ void net_start(void)
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wc));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
xTaskCreate(static_ip_fallback, "ipfb", 4096, NULL, 3, NULL);
|
||||
ESP_LOGI(TAG, "wifi starting, ssid=%s", WIFI_SSID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user