refactor: entkopple mDNS-Discovery, Status-Flags und WiFi-Manager

- net_mdns: Autostart + Discovery-Retry stabilisiert (Forward-Declarations, Task-Start bei GOT_IP)
- sys_status: EventGroup zentralisiert; Statusbits nicht mehr aus net_mdns gesetzt
- main: Integration von net_mdns Autostart/Discovery und UI-Status-Update vorbereitet
- wifi_mgr: mDNS-Discovery-Logik entfernt/vereinheitlicht, damit keine doppelte Discovery läuft
- net_influx: Anpassungen an neue Discovery/Storage-Semantik
This commit is contained in:
2026-01-22 13:45:15 +01:00
parent ca8ec3c993
commit 2352075c58
8 changed files with 493 additions and 154 deletions
-30
View File
@@ -232,8 +232,6 @@ static void wifi_event_handler(void* arg, esp_event_base_t base, int32_t id, voi
ESP_LOGI(TAG, "STA got IP: " IPSTR, IP2STR(&e->ip_info.ip));
xEventGroupSetBits(wifi_events, EVT_STA_GOTIP);
xTaskCreate(mdns_discover_task, "mdns_discover", 3072, NULL, 4, NULL);
if (ap_off_timer) {
if (esp_timer_is_active(ap_off_timer)) esp_timer_stop(ap_off_timer);
ESP_ERROR_CHECK(esp_timer_start_once(ap_off_timer, 10 * 1000 * 1000)); // 10 s
@@ -353,31 +351,3 @@ static void ap_set_dhcp_dns_to_self(void) {
&ip.ip, sizeof(ip.ip));
esp_netif_dhcps_start(netif_ap);
}
// Task für mDNS-Discover ---
static void mdns_discover_task(void *arg) {
// Start/ensure mDNS läuft
(void)net_mdns_autostart_init(NULL, NULL);
const TickType_t kDelay = pdMS_TO_TICKS(60000); // 60 s
for (;;) {
// Erst offizieller Service, dann Fallback auf HTTP:8086
esp_err_t err = net_mdns_autodiscover_and_store("_myapp", "_tcp", -1,
NULL, NULL, 2000);
if (err != ESP_OK) {
err = net_mdns_autodiscover_and_store("_http", "_tcp", 8086,
NULL, NULL, 2000);
}
if (err == ESP_OK) {
sys_status_set_mdns_ok(true);
ESP_LOGI(TAG, "mDNS: Service gefunden und gespeichert. Beende Re-Try-Task.");
vTaskDelete(NULL); // fertig, keine weiteren Versuche
} else {
sys_status_set_mdns_ok(false);
ESP_LOGW(TAG, "mDNS: nichts gefunden – neuer Versuch in 60 s");
vTaskDelay(kDelay);
}
}
}