-->
Page 1 of 1

Restart webserver after reconnect or io change?

PostPosted: Thu Jun 06, 2019 1:51 am
by array81
This is the scenario:
1. my esp8266 device is run (connect to wifi, get ip address and run webserver);
2. I can access to webserver;
3. the ip address change (for example I change it from router, or restart router and it assign a new ip address after esp8266 reconnect);
4. I CANNOT access to webserver (ping works);

I think I need restart webserver after ip address change, but how?

How can I know when esp8266 reconnect to router? And how can I know when change ip?

Thanks

Re: Restart webserver after reconnect or io change?

PostPosted: Thu Jun 06, 2019 6:55 am
by rudy
Try this.

WiFi.localIP() will give you the IP. Save that and then periodically check to see if it has changed.

.close(); will disable the server. The restart it with begin().