Pages: [1]   Go Down
Author Topic: Check WiFi link status before sending request ?  (Read 354 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: