Move esp_netif_create_default_wifi_sta() before initializing Wi-Fi to

align with the ESP-IDF recommended order
This commit is contained in:
2025-11-06 13:22:46 +01:00
parent 8e82e21a3d
commit c74a0501c1
+1 -1
View File
@@ -44,9 +44,9 @@ void wifi_init_sta(void) {
ESP_ERROR_CHECK(esp_event_loop_create_default());
esp_netif_create_default_wifi_sta();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
esp_netif_create_default_wifi_sta();
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL));
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, NULL));