ESP32 integrates with LWIP for network stack which has a "netif" data structure. Some LWIP functions take "struct netif *" as arguments. tcpip_adapter component manages netif structures and provides functions to manipulate them. It also has a enum - tcpip_adapter_if_t - to point to particular network interface. The problem is that there is no function to get "struct netif *" based on tcpip_adapter_if_t to pass it to LWIP functions. ESP8266 SDK had system_get_netif() function for that.
How can I get netif based on tcpip_adapter_if_t ?
Getting netif
-
- Posts: 29
- Joined: Fri Mar 03, 2017 10:31 am
Re: Getting netif
I found a netif-solution:
For AP-mode the parameter is "WIFI_AP_DEF"
I found this in the component sources, the ifkey parameter is not really explained.
Code: Select all
esp_netif_t* netif=NULL;
netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
I found this in the component sources, the ifkey parameter is not really explained.
Re: Getting netif
Hi,
How do I set Wifi as default interface?
error: dereferencing pointer to incomplete type 'esp_netif_t' {aka 'struct esp_netif_obj'}
How do I set Wifi as default interface?
Code: Select all
void setWifidefault()
{
esp_netif_t* netif = NULL;
netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
netif_set_default(netif->lwip_netif);
}
Re: Getting netif
Thanks for posting this, it's just what I was looking for! Not sure why it isn't used in any official examples.JoeSensoric wrote: ↑Sun Dec 15, 2019 9:47 amI found a netif-solution:
For AP-mode the parameter is "WIFI_AP_DEF"Code: Select all
esp_netif_t* netif=NULL; netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
I found this in the component sources, the ifkey parameter is not really explained.
Who is online
Users browsing this forum: Corand and 85 guests