perf: keep IP after provisioning
This commit is contained in:
+9
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user