From 3157b8f16e93166fd1bc8c3670e9666b84ec0175 Mon Sep 17 00:00:00 2001 From: Filippo Corri Date: Tue, 4 Nov 2025 09:57:32 +0100 Subject: [PATCH] Fix: Resolve ESP_ERR_ESP_NETIF_DHCP_NOT_STOPPED on static IP config --- src/Ethernet.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Ethernet.cpp b/src/Ethernet.cpp index 599404d..662bef5 100644 --- a/src/Ethernet.cpp +++ b/src/Ethernet.cpp @@ -80,8 +80,17 @@ void EthernetClass::begin(uint8_t *mac, IPAddress localIP, IPAddress dnsIP, IPAd } } // if (config(localIP, gatewayIP, netmask, dnsIP) && beginETH(mac)) { - if (beginETH(mac) && config(localIP, gatewayIP, netmask, dnsIP) ) { - hwStatus = EthernetHardwareFound; + if (beginETH(mac)) + { + if (esp_netif_dhcpc_stop(netif()) != ESP_OK) + { + log_e("Failed to stop dhcp client"); + return; + } + if (config(localIP, gatewayIP, netmask, dnsIP)) + { + hwStatus = EthernetHardwareFound; + } } const unsigned long start = millis(); while (!linkUp() && ((millis() - start) < 3000)) {