From f741521abc4a200fdb427f7cf9c5a4b5648777bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Andr=C3=A1ssy?= <10706773+JAndrassy@users.noreply.github.com> Date: Sat, 15 Jun 2024 21:06:29 +0200 Subject: [PATCH] LwipIntfDev - legacy Ethernet API methods moved to EthernetCompat (#9133) --- cores/esp8266/LwipIntfDev.h | 18 +++--------------- libraries/lwIP_Ethernet/src/EthernetCompat.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cores/esp8266/LwipIntfDev.h b/cores/esp8266/LwipIntfDev.h index daf63e935d..962d5e1196 100644 --- a/cores/esp8266/LwipIntfDev.h +++ b/cores/esp8266/LwipIntfDev.h @@ -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))); @@ -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()) { @@ -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 diff --git a/libraries/lwIP_Ethernet/src/EthernetCompat.h b/libraries/lwIP_Ethernet/src/EthernetCompat.h index ee8d1fadc2..9ebd75ca15 100644 --- a/libraries/lwIP_Ethernet/src/EthernetCompat.h +++ b/libraries/lwIP_Ethernet/src/EthernetCompat.h @@ -103,6 +103,21 @@ class ArduinoEthernet: public LwipIntfDev return DHCP_CHECK_NONE; } + void MACAddress(uint8_t* mac) + { + LwipIntfDev::macAddress(mac); + } + + IPAddress dnsServerIP() const + { + return LwipIntfDev::dnsIP(0); + } + + void setDnsServerIP(const IPAddress dnsIP) + { + LwipIntfDev::setDNS(dnsIP); + } + protected: HardwareStatus _hardwareStatus; };