From 204492bd7838d3687719473a7de30876f3d1ee7e Mon Sep 17 00:00:00 2001 From: David Cermak Date: Sat, 31 Aug 2019 16:21:31 +0200 Subject: [PATCH] examples: wifi getting started examples to use esp_netif_init() and create default netif instances for station and AP --- .../wifi/getting_started/softAP/main/softap_example_main.c | 3 ++- .../wifi/getting_started/station/main/station_example_main.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/wifi/getting_started/softAP/main/softap_example_main.c b/examples/wifi/getting_started/softAP/main/softap_example_main.c index 624e020ed..ca1883e04 100644 --- a/examples/wifi/getting_started/softAP/main/softap_example_main.c +++ b/examples/wifi/getting_started/softAP/main/softap_example_main.c @@ -45,8 +45,9 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base, void wifi_init_softap(void) { - tcpip_adapter_init(); + esp_netif_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_create_default_wifi_ap(); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK(esp_wifi_init(&cfg)); diff --git a/examples/wifi/getting_started/station/main/station_example_main.c b/examples/wifi/getting_started/station/main/station_example_main.c index ce349e839..9a5a94ac6 100644 --- a/examples/wifi/getting_started/station/main/station_example_main.c +++ b/examples/wifi/getting_started/station/main/station_example_main.c @@ -64,13 +64,15 @@ void wifi_init_sta(void) { s_wifi_event_group = xEventGroupCreate(); - tcpip_adapter_init(); + esp_netif_init(); 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_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));