Go Down

Topic: WiFi Shield - WiFi.begin returns "4"??? (Read 521 times) previous topic - next topic

shamkawai

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?

zdillman

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.

PaulS

What values do WL_CONNECTED and WL_IDLE_STATUS correspond to?

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

dxw00d

#3
Dec 07, 2012, 03:57 pm Last Edit: Dec 07, 2012, 04:00 pm by dxw00d Reason: 1

What values do WL_CONNECTED and WL_IDLE_STATUS correspond to?


.../WiFi/utility/wl-definitions.h:
Code: [Select]
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: [Select]
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;
}

Go Up