Skip to content

Commit ec86d4e

Browse files
committed
eliminates error messages when using Ethernet Static IP
1 parent caa8d07 commit ec86d4e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libraries/WiFi/src/ETH.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,16 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
385385
info.gw.addr = 0;
386386
info.netmask.addr = 0;
387387
}
388+
389+
// avoid error messages or failure while DHCP still did not get stopped
390+
uint8_t tries = 5;
391+
do {
392+
const TickType_t xDelay = 50 / portTICK_PERIOD_MS;
393+
vTaskDelay( xDelay );
394+
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
395+
tries--;
396+
} while (tries && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED);
388397

389-
err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
390398
if(err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED){
391399
log_e("DHCP could not be stopped! Error: %d", err);
392400
return false;
@@ -396,7 +404,8 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
396404
if(err != ERR_OK){
397405
log_e("STA IP could not be configured! Error: %d", err);
398406
return false;
399-
}
407+
}
408+
400409
if(info.ip.addr){
401410
staticIP = true;
402411
} else {

0 commit comments

Comments
 (0)