WiFi Shield 101 Stops Receiving UDP Packets

Hello,

I have an Arduino Mega ADK and WiFi Shield 101 that sits listening for UDP packets to trigger an action. It works great for a while, but after 8-12 hours it stops responding. I try pinging the IP address and don't get a response either. I get this response:

Pinging 192.168.0.10 with 32 bytes of data:
Reply from 192.168.0.109: Destination host unreachable.

(192.168.0.109 is my local computer I'm running the ping from, 192.168.0.10 is the Arduino).

Resetting the board seems to work. I was attempting to work out some solution that would do a software reset once it hasn't detected a packed for a while, but I had trouble getting this to work:

http://forum.arduino.cc/index.php?topic=189122.msg1516272#msg1516272

The code I'm using is quite similar to the example WiFiUdpSendReceiveString, except I don't send a reply. The problem with using the linked solution is that the code I'm using expects Udp to be an object, but the solution expects Udp to be a pointer so it can be checked against NULL and the delete command works.

Is there some better way to get this working? The thread I linked was from a few years ago, so I'm not sure if it still applies. If this is a good approach, any pointers on adapting the WiFiUdpSendReceiveString code to implement the solution suggested by MattS-UK in the linked thread above?

Thanks!

I fiddled around with this some more, and wrote some code to have it reset the connection if it hasn't received anything in five minutes. Unfortunately, even after the reset it doesn't receive any of the UDP packets being sent. I just added Udp.flush(); and Udp.stop(); to the start of my wifiConnect() function. I couldn't figure out how to delete and re-create the Udp object.

Any ideas? I tried running the CheckWifiFirmwareVersion code, and my firmware appears to be correct. Maybe I have a bad shield?

Ok, I tried disconnecting my project from the Arduino, in case something in there was messing things up, so now it is just the WiFi 101 shield and an Arduino Mega ADK. I also set up a python script to start beeping once it disconnects (it beeps on every ping fail).

This is a real pain to troubleshoot, since it takes up to around 12 hours to disconnect. Worst comes to worst, I'll just set up my raspberry pi to cycle the Arduino's power with a wireless switch or something when it disconnects, but ideally I wouldn't have to do that!

Having similar problem with an Arduino Uno Wifi. Does the Wifi shield have a configuration page which is accessible via Wifi? If yes, is this page accessible during connection lost?

No, the shield doesn't have a configuration page. The configuration (basically just telling it what the SSID and password are) is done in code.

Disconnecting my project from the Arduino didn't help, it still loses its connection after some period of time. I read on this thread that somebody was having disconnects when the WPA2 group key gets exchanged. So I tried reducing the time this happens to every 10 minutes, expecting to see a disconnect every 5 minutes, but that didn't happen.

Interestingly, I did get a disconnect when I changed the group key update period, so now I have a way to force it to disconnect so I can test other things, or maybe monitor what's happening on the network to see why it is happening. Unfortunately my router doesn't have detailed enough logs to see what's going on with the group key exchange.