Go Down

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


When I'm doing

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

Status is neither WL_CONNECTED nor WL_IDLE_STATUS, which are the two possible responses outlined in the official reference

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

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


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.


What values do WL_CONNECTED and WL_IDLE_STATUS correspond to?

Why are ssid and pass in square brackets in that call?
The art of getting good answers lies in asking good questions.


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?

Code: [Select]
typedef enum {
       WL_IDLE_STATUS = 0,
} 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)
   status = WiFiDrv::getConnectionStatus();
   while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
    status = WL_CONNECT_FAILED;
    return status;

Go Up