From 15da1635b68e1437658bf413ba8684e74272fed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Andr=C3=A1ssy?= Date: Fri, 18 Jun 2021 11:21:07 +0200 Subject: [PATCH] LwipIntfDev.h - apply static DNS config (#8076) DNS setting was not applied. Additionally default values for dns parameters in config are added. --- cores/esp8266/LwipIntfDev.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/LwipIntfDev.h b/cores/esp8266/LwipIntfDev.h index dded93499..3354a3256 100644 --- a/cores/esp8266/LwipIntfDev.h +++ b/cores/esp8266/LwipIntfDev.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include // wifi_get_macaddr() @@ -40,7 +41,7 @@ public: memset(&_netif, 0, sizeof(_netif)); } - boolean config(const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2, const IPAddress& arg3, const IPAddress& dns2); + boolean config(const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2, const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE); // default mac-address is inferred from esp8266's STA interface boolean begin(const uint8_t *macAddress = nullptr, const uint16_t mtu = DEFAULT_MTU); @@ -116,6 +117,17 @@ boolean LwipIntfDev::config(const IPAddress& localIP, const IPAddress& g ip4_addr_set_u32(ip_2_ip4(&_netif.gw), realGateway.v4()); ip4_addr_set_u32(ip_2_ip4(&_netif.netmask), realNetmask.v4()); + if (realDns1.isSet()) + { + // Set DNS1-Server + dns_setserver(0, realDns1); + } + + if (dns2.isSet()) + { + // Set DNS2-Server + dns_setserver(1, dns2); + } return true; }