Chapter 4. Software framework
4.10.5 [LWIP] With ESP-IDF v4.1, how to configure ESP32's IP address when it is in
SoftAP mode?
Since ESP-IDF v4.1 and later versions do not have TCP/IP interfaces anymore, it is recommended to
use the
ESP-NETIF
Code example:
{
...
esp_netif_t *ap_netif
char* ip=
"192.168.5.241";
char*
gateway
char*
netmask
esp_netif_ip_info_t info_t;
memset(&info_t, 0, sizeof(esp_netif_ip_info_t));
if
(ap_netif)
{
ESP_ERROR_CHECK(esp_netif_dhcps_stop(ap_netif));
info_t.ip.addr
info_t.netmask.addr
info_t.gw.addr
esp_netif_set_ip_info(ap_netif, &info_t);
ESP_ERROR_CHECK(esp_netif_dhcps_start(ap_netif));
}
...
}
4.10.6 [LWIP] How to configure ESP32's static IP when it is in Station mode?
Since ESP-IDF v4.2 and later versions do not have tcp/ip interfaces anymore, it is recommended to use
the
ESP-NETIF
interface instead. The code example is as follows:
esp_netif_t *sta_netif
if
(sta_netif)
{
esp_netif_ip_info_t info_t
esp_netif_dhcpc_stop(sta_netif);
info_t.ip.addr
info_t.gw.addr
info_t.netmask.addr
esp_netif_set_ip_info(sta_netif, &info_t);
}
esp_netif_dns_info_t dns_info
4.10.7 [LWIP] How to configure the Option contents of DHCP Server in ESP-IDF?
Since ESP-IDF v4.1 and later versions do not have TCP/IP interfaces anymore, it is recommended to use
the
ESP-NETIF
interface instead. You can also refer to this example when dealing with DHCP Client
configuration. The code example is as follows:
Espressif Systems
interface instead.
=
esp_netif_create_default_wifi_ap();
=
"192.168.5.1";
=
"255.255.255.0";
=
esp_ip4addr_aton((const
=
esp_ip4addr_aton((const
=
esp_ip4addr_aton((const
=
esp_netif_create_default_wifi_sta();
=
{0};
=
ESP_IP4TOADDR(192, 168, 3, 23);
=
ESP_IP4TOADDR(192, 168, 3, 1);
=
ESP_IP4TOADDR(255, 255, 255, 0);
=
{0};
Submit Document Feedback
char
*)ip);
char
char
*)gateway);
126
*)netmask);
Release master
Need help?
Do you have a question about the ESP and is the answer not in the manual?