Chapter 4. Software framework
// Set up the handle for softap netif
esp_netif_t *ap_netif = esp_netif_create_default_wifi_ap();
// ESP_NETIF_IP_ADDRESS_LEASE_TIME, DHCP Option 51, Set the lease time␣
,→for distributed IP address
uint32_t dhcps_lease_time = 60; // The unit is min
ESP_ERROR_CHECK(esp_netif_dhcps_option(ap_netif,ESP_NETIF_OP_SET,ESP_
,→NETIF_IP_ADDRESS_LEASE_TIME,&dhcps_lease_time,sizeof(dhcps_lease_
,→time)));
// ESP_NETIF_DOMAIN_NAME_SERVER , DHCP Option 6, Set DNS SERVER
// Set the local domain DNS first
esp_netif_dns_info_t dns_info = {0};
dns_info.ip.u_addr.ip4.addr = ESP_IP4TOADDR(8,8,8,8);
ESP_ERROR_CHECK(esp_netif_set_dns_info(ap_netif,ESP_NETIF_DNS_MAIN,&dns_
,→info));
uint8_t dns_offer = 1; // Pass 1 to make the modified DNS take effect, if␣
,→it is 0, then it means the gw ip of softap is used as the DNS server (0␣
,→by default)
ESP_ERROR_CHECK(esp_netif_dhcps_option(ap_netif,ESP_NETIF_OP_SET,ESP_
,→NETIF_DOMAIN_NAME_SERVER,&dns_offer,sizeof(dns_offer)));
// ESP_NETIF_ROUTER_SOLICITATION_ADDRESS, DHCP Option 3 Router, Pass 0 to␣
,→make the DHCP Option 3(Router) un-shown (1 by default)
uint8_t router_enable = 0;
ESP_ERROR_CHECK(esp_netif_dhcps_option(ap_netif,ESP_NETIF_OP_SET,ESP_
,→NETIF_ROUTER_SOLICITATION_ADDRESS,&router_enable, sizeof(router_
,→enable)));
// ESP_NETIF_SUBNET_MASK, DHCP Option 1, Configure the subnet mask
// If it fails to configure the subnet mask via ESP_NETIF_SUBNET_MASK,␣
,→please make modifications using esp_netif_set_ip_info
4.10.8 [Performance] How to test the bit rate of Wi-Fi modules?
Please use the example iperf in ESP-IDF for testing.
4.10.9 [LWIP] What is the default IP address of ESP8266 SoftAP?
Why do I have problem connecting to router with IP 192.168.4.X in SoftAP + Station mode?
• The default network segment used by ESP8266 SoftAP is 192.168.4.*, and its IP address is
192.168.4.1. When connecting ESP8266 to the router of 192.168.4.X, it cannot distinguish
whether this address indicates its own SoftAP or the external router.
4.10.10 [Connect] How many devices is ESP8266 able to connect in SoftAP mode?
The ESP8266 chip in SoftAP mode supports connecting eight devices at most. This is because the NAT
(Network Address Translation) mechanism used by the ESP8266 chip in SoftAP mode only supports
eight devices at most. However, it should be noted that each connected device will occupy a certain
amount of bandwidth and resources. Therefore, we recommend connecting four devices as too many
devices may aect the performance and stability of the Wi-Fi module.
Espressif Systems 127
Submit Document Feedback
Release master