How to fix ESP-IDF error: cannot convert 'esp_interface_t' to 'wifi_interface_t'
Problem:
While trying to compile your ESP-IDF app using code such as
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
you see an error message such as
src/main.cpp:76:41: error: cannot convert 'esp_interface_t' to 'wifi_interface_t'
76 | ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
| ^~~~~~~~~~~~~~~
| |
| esp_interface_t
Solution
Instead of ESP_IF_WIFI_STA
, use WIFI_IF_STA
(which has the correct type):
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));