WiFi retry connect, how ?
Posted: Thu Jan 14, 2016 2:48 pm
Hi,
I have this construction :
and sometimes it ends up in the while and never connects, if i reboot the device it usually works so what is the best approach to wait say 5sec then retry to connect from start again ?
donnib
I have this construction :
Code: Select all
void LaunchWifi()
{
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
WiFi.config(ip,gateway,subnet);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
and sometimes it ends up in the while and never connects, if i reboot the device it usually works so what is the best approach to wait say 5sec then retry to connect from start again ?
donnib