Go Down

Topic: Check WiFi link status before sending request ? (Read 529 times) previous topic - next topic

Hi all,

How do I check my WiFi link status before sending a network request? The only way I can see to check my WiFi status is by using the WiFi.begin() (http://arduino.cc/en/Reference/WiFiBegin) method.

What I'm seeing is that if my Arduino boots up and connects to the network, then has no activity for a long period of time, it loses the connection to the network. If this happens, the next action I take seems to reconnect it, but that request fails.

The symptoms I see on the board are as follows:
- Link light is green
- Push button to trigger network traffic
- Link light goes red
- Request fails
- Link light goes green
- Push button to generate network traffic
- Request succeeds

I'd like to check the link status on each button press to ensure that I have a valid link _before_ sending the request, and then attempt to re-establish the link if it's not valid.

Thanks,


PaulS

Is the Arduino a WiFi client or a WiFi server?

The WiFi class has a status() method. Have you tried that, to determine if you are (still) connected?


The Arduino is acting as a client.

I've looked at the documentation at http://arduino.cc/en/Reference/WiFi and I see no status method listed there. Where can I find documentation on that ?

PaulS

Quote
Where can I find documentation on that ?

In the source code. I looked at the WiFi client example. I see the method used there. It checks for the existence of the WiFi shield, but it might have other useful return values.

WiFi.status() doesn't seem useful. It appears to return 3 as long as I've had a successful connection.

It shows a result of 3 both when link LED is red and when it's green.

Go Up