perf: keep IP after provisioning

This commit is contained in:
2026-05-16 11:58:35 +02:00
parent 6f313f0145
commit 680522c930
3 changed files with 22 additions and 3 deletions
+9 -1
View File
@@ -82,7 +82,15 @@ static void wifi_init_sta(void)
{
esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, wifi_event_handler, NULL);
esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, wifi_event_handler, NULL);
ESP_ERROR_CHECK(esp_wifi_connect());
esp_netif_t *netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
esp_netif_ip_info_t ip_info = {0};
if (netif && esp_netif_get_ip_info(netif, &ip_info) == ESP_OK && ip_info.ip.addr != 0) {
ESP_LOGI(TAG, "WiFi already connected (IP: " IPSTR ")", IP2STR(&ip_info.ip));
xEventGroupSetBits(s_evt, WIFI_CONNECTED_BIT);
} else {
ESP_ERROR_CHECK(esp_wifi_connect());
}
}
static bool resolve_mqtt_broker_mdns(char *host_out, size_t host_len, uint16_t *port_out)