Skip to content

Commit f5dab40

Browse files
committed
eliminates error messages when using Ethernet Static IP
1 parent 4b1a6fb commit f5dab40

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

libraries/Ethernet/src/ETH.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,10 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
386386
info.netmask.addr = 0;
387387
}
388388

389-
// avoid error messages or failure while DHCP still did not get stopped
390-
uint8_t tries = 5;
391-
do {
392-
delay(50);
393-
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
394-
tries--;
395-
} while (tries && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED);
389+
// this delay forces changing FreeRTOS task context
390+
// it avoids DHCP error messages by running DHCP LwIP Events correctly before setting static IP
391+
delay(50);
392+
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
396393

397394
if(err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED){
398395
log_e("DHCP could not be stopped! Error: %d", err);

0 commit comments

Comments
 (0)