I've been struggling to get Wifi working in V4.1, using the ESP_NETIF library. I have it working now -- my initialization routine is a composite of the docs, the example in the IDF and the example on github (because none of them seemed 100% correct.) Here's a distillation of my init routine (error checking and initializations have been removed):
Code: Select all
esp_netif_t *m_netif = nullptr;
void Wifi::taskInit()
{
esp_netif_config_t netifConfig;
wifi_init_config_t wifiInitConfig;
static wifi_config_t wifiConfig; // initialization removed for brevity
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifiInitConfig = WIFI_INIT_CONFIG_DEFAULT();
esp_wifi_init(&wifiInitConfig);
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT,
ESP_EVENT_ANY_ID,
event_handler,
m_tasks));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT,
ESP_EVENT_ANY_ID,
event_handler,
m_tasks));
netifConfig = ESP_NETIF_DEFAULT_WIFI_STA();
m_netif = esp_netif_new(&netifConfig);
esp_netif_attach_wifi_station(m_netif);
esp_wifi_set_default_wifi_sta_handlers();
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
esp_wifi_set_config(ESP_IF_WIFI_STA, &wifiConfig);
return;
}
- as a member of the object
- using malloc()
- using new()
All failed identically. Only the static definition worked.
I do have SPIRAM enabled, whihc might be affecting this, though I don't see how. So, my question to the experts is: should I report this as a bug?
Thanks...