Pages: [1]   Go Down
Author Topic: WiFi Shield - WiFi.begin returns "4"???  (Read 367 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I'm doing

status = WiFi.begin([ssid],[pass]);
Serial.println(status);

Status is neither WL_CONNECTED nor WL_IDLE_STATUS, which are the two possible responses outlined in the official reference
http://arduino.cc/en/Reference/WiFiBegin

Status is the number 4.
and of course, I couldn't connect to wifi
What???

I've pressed the reset button a million times, is there a more powerful factory restore button?
Logged

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

It would help to see all of your code. The number you're getting may be because of the network you're trying to connect to. If you're trying to connect to a WEP network, using "pass" is not going to work, as you have to provide the hex key to gain access. Again, seeing all of your code would be very helpful.
Logged

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

What values do WL_CONNECTED and WL_IDLE_STATUS correspond to?

Why are ssid and pass in square brackets in that call?
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What values do WL_CONNECTED and WL_IDLE_STATUS correspond to?

.../WiFi/utility/wl-definitions.h:
Code:
typedef enum {
WL_NO_SHIELD = 255,
        WL_IDLE_STATUS = 0,
        WL_NO_SSID_AVAIL,
        WL_SCAN_COMPLETED,
        WL_CONNECTED,
        WL_CONNECT_FAILED,
        WL_CONNECTION_LOST,
        WL_DISCONNECTED
} wl_status_t;

Status 4 is WL_CONNECT_FAILED. See .../WiFi/WiFi.cpp

Code:
int WiFiClass::begin(char* ssid, const char *passphrase)
{
uint8_t status = WL_IDLE_STATUS;
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;

    // set passphrase
    if (WiFiDrv::wifiSetPassphrase(ssid, strlen(ssid), passphrase, strlen(passphrase))!= WL_FAILURE)
    {
     do
     {
     delay(WL_DELAY_START_CONNECTION);
     status = WiFiDrv::getConnectionStatus();
     }
   while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
    }else{
    status = WL_CONNECT_FAILED;
    }
    return status;
}
« Last Edit: December 07, 2012, 10:00:06 am by dxw00d » Logged

Pages: [1]   Go Up
Jump to: