Currently I see that in Soft-AP mode the ESP32 has 192.168.4.1 for the gateway. When a client connects to the ESP32, it will successfully do so and pickup the ip/gateway/netmask. However, when I look at what DNS servers have been assigned, I see none.
How do I specify what DNS servers the DHCP clients should get? I see the tcpip_adapter_set_dns_info(..) and it's comment is:
...
2.In soft-AP mode, the DNS Server's main dns server offered to the station is the IP address of soft-AP, if the application don't want to use the IP address of soft-AP, they can set the main dns server.
...
This comment seems to indicate that the IP address of the ESP32 "should" be provided as the main DNS server by default when in AP-mode? This is not happening, as any of the connecting clients never have a DNS server set; is this a bug? I am using the latest ESP-IDF pull as of this writing.
I see the tcpip_adapter_dns_type_t enum says that the backup and fallback DNS server addresses are only for STA mode at this time. However, the TCPIP_ADAPTER_DNS_MAIN enum value does not have this restriction, which corresponds to the previous code comment.
The following code snippet is my attempt to set the main DNS server. The ** Problem ** is I can't figure out how to assign the actual IP address to the tcpip_adapter_dns_info_t. I keep getting compile errors not matter what approach I try. In general the error is related to: 'ip_addr_t {aka struct _ip_addr}' has no member named 'addr', or something related to that.
Code: Select all
tcpip_adapter_dns_info_t dns_info;
const char* dns_server = "192.168.4.1" ;
// int ip4addr_aton(const char *cp, ip4_addr_t *addr);
int v = ip4addr_aton(dns_server, &dns_info.ip) ; // ** Problem **
ESP_ERROR_CHECK(tcpip_adapter_set_dns_info(
TCPIP_ADAPTER_IF_AP,
TCPIP_ADAPTER_DNS_MAIN,
&dns_info));
2. When should this call be made in the set of calls necessary to setup AP-mode?