When wifi shield goes out of network range for a period of time, the tcpServer dies and does not respawn. [imported]
This is Issue 1086 moved from a Google Code project. Added by 2012-10-29T00:03:28.000Z by [email protected]. Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Defect, Priority-Medium
Original description
What steps will reproduce the problem?
- Use any of the example sketches that instantiate the WiFiServer that come with the WiFi shield and load it up. ie. WiFiChatServer
- Take your arduino+wifi shield out of wifi range and leave it there for a few minutes.
- Take it back in to wifi range and it will be pingable, you'll be able to open a socket to the server, but it will just hang there. You can observe the TCP packets bouncing back and forth and eventually the wifishield disconnects you.
You should expect that when the wifi server is back in range, it will continue to serve new/old established connections.
I did some very superficial debugging and if you output server.status() you'll notice that at some point it returns 0, instead of 1. This is when you know it's dead. I've tried to add code that runs another server.begin(), to no avail. I've even added a new function to restart the server. Again, to no avail. I've yet to dig deeper.
I'm using the Arduino UNO + Arduino Wifi Shield, using 1.0.1 of the IDE in OS X Mountain Lion.
This function does not restart the server as I would expect when it dies, i've yet to debug why: void WiFiServer::restart() { uint8_t _sock = WiFiClass::getSocket(); ServerDrv::startServer(_port, _sock); }
I am experiencing the same problem, along with others in the wifi server library. I use these functions to troubleshoot, adding this first code to loop(). I press 's' to see the data from the wifi shield. If it stays disconnected for more than just a few seconds, the shield status returns failed, then locks up.
void loop() {
if(Serial.available()) {
char ch = Serial.read();
if(ch == 's') {
ShowSockStatus();
printCurrentNet();
}
}
// rest of your loop
}
void printCurrentNet() {
// print the SSID of the network you're attached to:
Serial.print(F("SSID: "));
Serial.println(WiFi.SSID());
// print the MAC address of the router you're attached to:
byte bssid[6];
WiFi.BSSID(bssid);
Serial.print(F("BSSID: "));
Serial.print(bssid[5],HEX);
Serial.print(F(":"));
Serial.print(bssid[4],HEX);
Serial.print(F(":"));
Serial.print(bssid[3],HEX);
Serial.print(F(":"));
Serial.print(bssid[2],HEX);
Serial.print(F(":"));
Serial.print(bssid[1],HEX);
Serial.print(F(":"));
Serial.println(bssid[0],HEX);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(F("signal strength (RSSI):"));
Serial.println(rssi);
// print the encryption type:
byte encryption = WiFi.encryptionType();
Serial.print(F("Encryption Type:"));
Serial.println(encryption,HEX);
// print the status:
byte wifistatus = WiFi.status();
Serial.print(F("Status:"));
switch(wifistatus) {
case 0: Serial.println(F("idle"));
break;
case 1: Serial.println(F("available"));
break;
case 2: Serial.println(F("completed"));
break;
case 3: Serial.println(F("connected"));
break;
case 4: Serial.println(F("failed"));
break;
case 5: Serial.println(F("lost"));
break;
case 6: Serial.println(F("disconnected"));
break;
case 255: Serial.println(F("no shield"));
break;
}
}
void ShowSockStatus() {
for(int x = 0; x < MAX_SOCK_NUM; x++) {
Serial.print(WiFi._state[x]);
Serial.print(" ");
Serial.println(WiFi._server_port[x]);
}
}
I have also the same problem.
Arduino UNO R3 WiFi Shield with the latest firmware Arduino IDE 1.0.6 Windows 8.1 x64
I'm using the example SimpleWifiWebServer.
The sample is working great, but if I turn off the wifi and turn it on again, then I can add a code to reconnect to wifi. It works, but the code server.status is 0 and not working. The webserver is dead. The only workaround is to hard reset arduino.
This issue was moved to arduino-libraries/WiFi#19