Chapter 2. API Reference
esp_err_t esp_netif_get_ip_info(esp_netif_t *esp_netif, esp_netif_ip_info_t *ip_info)
Get interface’s IP address information.
If the interface is up, IP information is read directly from the TCP/IP stack. If the interface is down, IP
information is read from a copy kept in the ESP-NETIF instance
Return
• ESP_OK
• ESP_ERR_ESP_NETIF_INVALID_PARAMS
Parameters
• [in] esp_netif: Handle to esp-netif instance
• [out] ip_info: If successful, IP information will be returned in this argument.
esp_err_t esp_netif_get_old_ip_info(esp_netif_t *esp_netif, esp_netif_ip_info_t *ip_info)
Get interface’s old IP information.
Returns an “old”IP address previously stored for the interface when the valid IP changed.
If the IP lost timer has expired (meaning the interface was down for longer than the configured interval) then
the old IP information will be zero.
Return
• ESP_OK
• ESP_ERR_ESP_NETIF_INVALID_PARAMS
Parameters
• [in] esp_netif: Handle to esp-netif instance
• [out] ip_info: If successful, IP information will be returned in this argument.
esp_err_t esp_netif_set_ip_info(esp_netif_t *esp_netif, const esp_netif_ip_info_t *ip_info)
Set interface’s IP address information.
This function is mainly used to set a static IP on an interface.
If the interface is up, the new IP information is set directly in the TCP/IP stack.
The copy of IP information kept in the ESP-NETIF instance is also updated (this copy is returned if the IP is
queried while the interface is still down.)
Note DHCP client/server must be stopped (if enabled for this interface) before setting new IP information.
Note Calling this interface for may generate a SYSTEM_EVENT_STA_GOT_IP or SYS-
TEM_EVENT_ETH_GOT_IP event.
Return
• ESP_OK
• ESP_ERR_ESP_NETIF_INVALID_PARAMS
• ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED If DHCP server or client is still running
Parameters
• [in] esp_netif: Handle to esp-netif instance
• [in] ip_info: IP information to set on the specified interface
esp_err_t esp_netif_set_old_ip_info(esp_netif_t *esp_netif, const esp_netif_ip_info_t
*ip_info)
Set interface old IP information.
This function is called from the DHCP client (if enabled), before a new IP is set. It is also called from the default
handlers for the SYSTEM_EVENT_STA_CONNECTED and SYSTEM_EVENT_ETH_CONNECTED
events.
Calling this function stores the previously configured IP, which can be used to determine if the IP changes in
the future.
If the interface is disconnected or down for too long, the “IP lost timer”will expire (after the configured
interval) and set the old IP information to zero.
Return
• ESP_OK
• ESP_ERR_ESP_NETIF_INVALID_PARAMS
Espressif Systems 203
Submit Document Feedback
Release v4.4