EasyManua.ls Logo

Espressif Systems ESP - Page 143

Default Icon
191 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 4. Software framework
4.10.5 [LWIP] With ESP-IDF v4.1, how to congure ESP32s 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 interface instead.
Code example
{
...
esp_netif_t *ap_netif = esp_netif_create_default_wifi_ap();
char* ip= "192.168.5.241";
char* gateway = "192.168.5.1";
char* netmask = "255.255.255.0";
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 = esp_ip4addr_aton((const char *)ip);
info_t.netmask.addr = esp_ip4addr_aton((const char *)netmask);
info_t.gw.addr = esp_ip4addr_aton((const char *)gateway);
esp_netif_set_ip_info(ap_netif, &info_t);
ESP_ERROR_CHECK(esp_netif_dhcps_start(ap_netif));
}
...
}
4.10.6 [LWIP] How to congure ESP32s 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 = esp_netif_create_default_wifi_sta();
if (sta_netif)
{
esp_netif_ip_info_t info_t = {0};
esp_netif_dhcpc_stop(sta_netif);
info_t.ip.addr = ESP_IP4TOADDR(192, 168, 3, 23);
info_t.gw.addr = ESP_IP4TOADDR(192, 168, 3, 1);
info_t.netmask.addr = ESP_IP4TOADDR(255, 255, 255, 0);
esp_netif_set_ip_info(sta_netif, &info_t);
}
esp_netif_dns_info_t dns_info = {0};
4.10.7 [LWIP] How to congure 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
con󰝘guration. The code example is as follows:
Espressif Systems 126
Submit Document Feedback
Release master

Table of Contents