Chapter 2. API Reference
ESP-NETIF programmer’s manual Please refer to the example section for basic initialization of default inter-
faces:
• WiFi Station: wifi/getting_started/station/main/station_example_main.c
• WiFi Access Point: wifi/getting_started/softAP/main/softap_example_main.c
• Ethernet: ethernet/basic/main/ethernet_example_main.c
For more specific cases please consult this guide: ESP-NETIF Custom I/O Driver.
WiFi default initialization The initialization code as well as registering event handlers for default interfaces, such
as softAP and station, are provided in two separate APIs to facilitate simple startup code for most applications:
• esp_netif_create_default_wifi_ap()
• esp_netif_create_default_wifi_sta()
Please note that these functions return the esp_netif handle, i.e. a pointer to a network interface object allocated
and configured with default settings, which as a consequence, means that:
• The created object has to be destroyed if a network de-initialization is provided by an application using
esp_netif_destroy_default_wifi().
• These default interfaces must not be created multiple times, unless the created handle is deleted using
esp_netif_destroy().
• When using Wifi in AP+STA mode, both these interfaces has to be created.
API Reference
Header File
• components/esp_netif/include/esp_netif.h
Functions
esp_err_t esp_netif_init(void)
Initialize the underlying TCP/IP stack.
Return
• ESP_OK on success
• ESP_FAIL if initializing failed
Note This function should be called exactly once from application code, when the application starts up.
esp_err_t esp_netif_deinit(void)
Deinitialize the esp-netif component (and the underlying TCP/IP stack)
Note: Deinitialization is not supported yet
Return
• ESP_ERR_INVALID_STATE if esp_netif not initialized
• ESP_ERR_NOT_SUPPORTED otherwise
esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config)
Creates an instance of new esp-netif object based on provided config.
Return
• pointer to esp-netif object on success
• NULL otherwise
Parameters
• [in] esp_netif_config: pointer esp-netif configuration
void esp_netif_destroy(esp_netif_t *esp_netif)
Destroys the esp_netif object.
Parameters
• [in] esp_netif: pointer to the object to be deleted
Espressif Systems 199
Submit Document Feedback
Release v4.4