Skip to content

Commit

Permalink
LwipIntfDev - legacy Ethernet API methods moved to EthernetCompat
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed May 5, 2024
1 parent 685f2c9 commit 4bfbc45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
18 changes: 3 additions & 15 deletions cores/esp8266/LwipIntfDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,11 @@ class LwipIntfDev: public LwipIntf, public RawDev
return &_netif;
}

uint8_t* macAddress(uint8_t* mac) // WiFi lib way
uint8_t* macAddress(uint8_t* mac)
{
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 @@ -104,15 +100,11 @@ class LwipIntfDev: public LwipIntf, public RawDev
{
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw)));
}
IPAddress dnsIP(int n = 0) const // WiFi lib way
IPAddress dnsIP(int n = 0) const
{
return IPAddress(dns_getserver(n));
}
IPAddress dnsServerIP() const // Ethernet lib way
{
return dnsIP(0);
}
void setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY) // WiFi lib way
void setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY)
{
if (dns1.isSet())
{
Expand All @@ -123,10 +115,6 @@ class LwipIntfDev: public LwipIntf, public RawDev
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
15 changes: 15 additions & 0 deletions libraries/lwIP_Ethernet/src/EthernetCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ class ArduinoEthernet: public LwipIntfDev<RawDev>
return DHCP_CHECK_NONE;
}

void MACAddress(uint8_t* mac)
{
LwipIntfDev<RawDev>::macAddress(mac);
}

IPAddress dnsServerIP() const
{
return LwipIntfDev<RawDev>::dnsIP(0);
}

void setDnsServerIP(const IPAddress dnsIP)
{
LwipIntfDev<RawDev>::setDNS(dnsIP);
}

protected:
HardwareStatus _hardwareStatus;
};
Expand Down

0 comments on commit 4bfbc45

Please sign in to comment.