Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When wifi shield goes out of network range for a period of time, the tcpServer dies and does not respawn. [imported] #1086

Closed
cmaglie opened this issue Nov 15, 2012 · 3 comments
Assignees
Labels
Library: Wifi The Wifi Arduino library

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 1086 moved from a Google Code project.
Added by 2012-10-29T00:03:28.000Z by k...@vmfarms.com.
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?

  1. Use any of the example sketches that instantiate the WiFiServer that come with the WiFi shield and load it up. ie. WiFiChatServer
  2. Take your arduino+wifi shield out of wifi range and leave it there for a few minutes.
  3. 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);
}

@SurferTim
Copy link

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]);    
  }
}

@ffissore ffissore added the New label Feb 27, 2014
@cmaglie cmaglie removed the New label Feb 27, 2014
@ghost
Copy link

ghost commented Sep 27, 2014

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.

@agdl
Copy link
Member

agdl commented Jul 12, 2016

This issue was moved to arduino-libraries/WiFi#19

@agdl agdl closed this as completed Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: Wifi The Wifi Arduino library
Projects
None yet
Development

No branches or pull requests

4 participants