Moderator: igrr
extern "C" {
#include "user_interface.h"
#include "lwip/err.h"
#include "lwip/dns.h"
}
void showDNS() {
ip_addr_t dns_ip = dns_getserver(0);
IPAddress dns = IPAddress(dns_ip.addr);
String str = String("DNS IP Addr: ");
str += dns.toString();
Serial.println(str);
}
I would suggest to include this into the ESP8266WiFi library for good programming practice,
because we can set the dns with
void config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns);
and can retrieve all
IPAddress localIP();
IPAddress subnetMask();
IPAddress gatewayIP();
but not the dns IP yet. What's simply missing is this code in ESP8266WiFi.h:
/*
* Get the dns server ip address.
*
* return: dns server ip address value
*/
IPAddress dnsIP();
And this in ESP8266WiFi.cpp:
IPAddress ESP8266WiFiClass::dnsIP()
{
ip_addr_t dns_ip = dns_getserver(0);
return IPAddress(dns_ip.addr);
}
What do you think?
I was thinking the same when trying the piece of code before sending my post.
I will do, it only question of time is always the missing ingredient ...