from static address to dhcp

VormsThierry
Posts: 8
Joined: Fri Mar 30, 2018 4:38 pm

from static address to dhcp

Postby VormsThierry » Fri Mar 10, 2023 6:17 pm

Hello,
I have a software that store different wifi conifguration.
Some are with dhcp other not.
The software try all configs with criterias.
When the esp try a config with fixed address and the next is with dhcp, the esp try to connect with the precedent ip.
How to forget the precedent ip ?

Basicaly, my code:
if (!currentWifi.dhcp){
if (!WiFi.config(currentWifi.ip, currentWifi.gateway, currentWifi.mask, currentWifi.dns, currentWifi.dns)) {
Serial.println("STA Failed to configure");
return false;
} else {
printIPAddress(", ip", currentWifi.ip);
printIPAddress(", dns", currentWifi.dns);
printIPAddress(", gateway", currentWifi.gateway);
printIPAddress(", mask", currentWifi.mask, true);
}
}
Serial.println("Wifi begin..");
WiFi.begin(currentWifi.SSID, currentWifi.PWD);

return true;

The Wifi.config remains. How to erase it ?

Many thanks

Thierry

VormsThierry
Posts: 8
Joined: Fri Mar 30, 2018 4:38 pm

Re: from static address to dhcp

Postby VormsThierry » Wed Mar 22, 2023 4:33 pm

no response.... not good..
I try to solve the issue by starting the dhcp with:
uint32_t error = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);

the result error is: E (9907) event: invalid static ip

any suggestions ?

Who is online

Users browsing this forum: No registered users and 65 guests