Skip to content

Commit 402fec5

Browse files
committed
LwipImtfDev - add DNS IP getters/setters and MAC getters
Ethernet styles getters/setters and WiFi styles getters/setters
1 parent 31c1592 commit 402fec5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cores/esp8266/LwipIntfDev.h

+30
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ class LwipIntfDev: public LwipIntf, public RawDev
7474
return &_netif;
7575
}
7676

77+
uint8_t* macAddress(uint8_t* mac) { // WiFi lib way
78+
memcpy(mac, &_netif.hwaddr, 6);
79+
return mac;
80+
}
81+
void MACAddress(uint8_t* mac) { // Ethernet lib way
82+
macAddress(mac);
83+
}
7784
IPAddress localIP() const
7885
{
7986
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)));
@@ -86,6 +93,29 @@ class LwipIntfDev: public LwipIntf, public RawDev
8693
{
8794
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw)));
8895
}
96+
IPAddress dnsIP(int n) const // WiFi lib way
97+
{
98+
return IPAddress(dns_getserver(n));
99+
}
100+
IPAddress dnsServerIP() const // Ethernet lib way
101+
{
102+
return dnsIP(0);
103+
}
104+
void setDNS(IPAddress dns1, IPAddress dns2 = (uint32_t)0x00000000) // WiFi lib way
105+
{
106+
if (dns1.isSet())
107+
{
108+
dns_setserver(0, dns1);
109+
}
110+
if (dns2.isSet())
111+
{
112+
dns_setserver(1, dns2);
113+
}
114+
}
115+
void setDnsServerIP(const IPAddress dnsIP) // Ethernet lib way
116+
{
117+
setDNS(dnsIP);
118+
}
89119

90120
// 1. Currently when no default is set, esp8266-Arduino uses the first
91121
// DHCP client interface receiving a valid address and gateway to

0 commit comments

Comments
 (0)