Wifi Shield 2.0 (RN-171, Seeedstudio, WiFly): How to reconnect to AP

Maybe I should add my straight observations as well...

If I run my above code, the arduino/shield does exactly what it is supposed to:

  • Connects to my AP alright
  • Provides a web page (I can get the page in my PC browser when typing in the arduino IP number)

If I then switch off my AP for like a minute and then switch it on again, the arduino does not reestablish the connection again.

Second observation:
If I add the following lines to my code:

void loop()
{
    if(wifly.available())       // the wifi shield has data available
    {
        ...
    }
    else
        if (!wifly.isAssociated())
             Serial.println("Lost connection to access point!");
}

in other words, if I try to find out whether the AP is still connected, I get the following behavior:

  • Connecting to the AP works fine.
  • In the very moment I try to get the web page by calling the IP in my browser, the arduino/shield is disconnected from the AP.

How do I know it disconnects?

  • The green LED D5 on the shield immediately changes from static on to blinking.
  • The browser reports that the http server cannot be contacted.

Hope this helps in addition. Any assistence would be really appreciated.