Page 1 of 1

How to delete a static IP?

Posted: Sun Jun 24, 2018 10:35 am
by ZKDMun
Hi,

I want to connect my ESP8266 to two different APs... on the first AP, the ESP8266 should have a static IP, but on the other AP it should be non-static.

But after the connection to the first AP with a static IP, and doing

Code: Select all

sta.disconnect() #from the first AP
sta.connect(<ESSID second AP>,<password second AP>)
my ESP8266 didnt get a new IP from the second AP... sta.ifconfig() shows me always the static IP from the first connection.

How can I delete this static IP from the first connection to get a new non-static IP from the second connection?

Re: How to delete a static IP?

Posted: Sun Jun 24, 2018 11:35 am
by ZKDMun
On the WiPy it is possible to use sta.ifconfig(config="dhcp")?
http://docs.micropython.org/en/latest/w ... n.ifconfig

But on the ESP8266?

Doing a reset will be a solution - it works for this but I guess but it is not the best solution.

Code: Select all

import machine
machine.reset()

Re: How to delete a static IP?

Posted: Mon Aug 13, 2018 11:17 am
by yeyeto2788
Hello!

You might want to retrieve the status before connecting to another AP.

See documentation for retrieving it (http://docs.micropython.org/en/latest/e ... lan.status)

Should be something like this:

Code: Select all

sta.disconnect() #from the first AP
if sta.status == "STAT_IDLE":
    sta.connect(<ESSID second AP>,<password second AP>)

Hope it helps.
Regards.