Skip to content

Commit

Permalink
LwipImtfDev - add DNS IP getters/setters and MAC getters
Browse files Browse the repository at this point in the history
Ethernet styles getters/setters and WiFi styles getters/setters
  • Loading branch information
JAndrassy committed Nov 8, 2023
1 parent 31c1592 commit 402fec5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cores/esp8266/LwipIntfDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ class LwipIntfDev: public LwipIntf, public RawDev
return &_netif;
}

uint8_t* macAddress(uint8_t* mac) { // WiFi lib way
memcpy(mac, &_netif.hwaddr, 6);
return mac;
}
void MACAddress(uint8_t* mac) { // Ethernet lib way
macAddress(mac);
}
IPAddress localIP() const
{
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)));
Expand All @@ -86,6 +93,29 @@ class LwipIntfDev: public LwipIntf, public RawDev
{
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw)));
}
IPAddress dnsIP(int n) const // WiFi lib way
{
return IPAddress(dns_getserver(n));
}
IPAddress dnsServerIP() const // Ethernet lib way
{
return dnsIP(0);
}
void setDNS(IPAddress dns1, IPAddress dns2 = (uint32_t)0x00000000) // WiFi lib way
{
if (dns1.isSet())
{
dns_setserver(0, dns1);
}
if (dns2.isSet())
{
dns_setserver(1, dns2);
}
}
void setDnsServerIP(const IPAddress dnsIP) // Ethernet lib way
{
setDNS(dnsIP);
}

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

0 comments on commit 402fec5

Please sign in to comment.