From bd4133426523cc4db35588add881f5ab78f8f4c4 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 18 Mar 2021 00:53:53 +0200 Subject: [PATCH] Fix ETH not enabling DHCP when configured with INADDR_NONE Fixes: https://github.com/espressif/arduino-esp32/issues/4778 --- libraries/WiFi/src/ETH.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/WiFi/src/ETH.cpp b/libraries/WiFi/src/ETH.cpp index d9855fcd..e3afd1ef 100644 --- a/libraries/WiFi/src/ETH.cpp +++ b/libraries/WiFi/src/ETH.cpp @@ -118,7 +118,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I esp_err_t err = ESP_OK; tcpip_adapter_ip_info_t info; - if(local_ip != (uint32_t)0x00000000){ + if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){ info.ip.addr = static_cast(local_ip); info.gw.addr = static_cast(gateway); info.netmask.addr = static_cast(subnet); @@ -153,13 +153,13 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I ip_addr_t d; d.type = IPADDR_TYPE_V4; - if(dns1 != (uint32_t)0x00000000) { + if(dns1 != (uint32_t)0x00000000 && dns1 != INADDR_NONE) { // Set DNS1-Server d.u_addr.ip4.addr = static_cast(dns1); dns_setserver(0, &d); } - if(dns2 != (uint32_t)0x00000000) { + if(dns2 != (uint32_t)0x00000000 && dns2 != INADDR_NONE) { // Set DNS2-Server d.u_addr.ip4.addr = static_cast(dns2); dns_setserver(1, &d);