Go Down

Topic: Serial.println(Wifi.status); Codes Meaning (Read 425 times) previous topic - next topic

thomascoope

I'm outputting Serial.println(Wifi.status); from my ESP8266 when it is trying to connect to a WIFI hub.

  • I'm getting a return of 6 when the device is trying to connect.
  • I believe that I'm getting a return of 3 when it connects
  • 1 when it cannot connect (I've modified the SSID to a non existent station in the ESP)
  • 4 when it cannot connect due to a bad password


I have found this reference https://www.arduino.cc/en/Reference/WiFiStatus however it would be handy if there is any official documentation explaining what these return codes mean.

Is there anything available?

thomascoope

#1
Oct 17, 2017, 08:36 pm Last Edit: Oct 17, 2017, 09:04 pm by thomascoope
...Surfer Tim gives an informative response here:

http://forum.arduino.cc/index.php?topic=162674.0

PieterP

#2
Oct 17, 2017, 09:07 pm Last Edit: Oct 17, 2017, 09:40 pm by PieterP
You can always find these kinds of things in the source code:
Code: [Select]
typedef enum {
    WL_NO_SHIELD        = 255,   // for compatibility with WiFi Shield library
    WL_IDLE_STATUS      = 0,
    WL_NO_SSID_AVAIL    = 1,
    WL_SCAN_COMPLETED   = 2,
    WL_CONNECTED        = 3,
    WL_CONNECT_FAILED   = 4,
    WL_CONNECTION_LOST  = 5,
    WL_DISCONNECTED     = 6
} wl_status_t;

You could write your own function to print it:
Code: [Select]
const char* wl_status_to_string(wl_status_t status) {
  switch (status) {
    case WL_NO_SHIELD: return "WL_NO_SHIELD";
    case WL_IDLE_STATUS: return "WL_IDLE_STATUS";
    case WL_NO_SSID_AVAIL: return "WL_NO_SSID_AVAIL";
    case WL_SCAN_COMPLETED: return "WL_SCAN_COMPLETED";
    case WL_CONNECTED: return "WL_CONNECTED";
    case WL_CONNECT_FAILED: return "WL_CONNECT_FAILED";
    case WL_CONNECTION_LOST: return "WL_CONNECTION_LOST";
    case WL_DISCONNECTED: return "WL_DISCONNECTED";
  }
}

Code: [Select]
Serial.println(wl_status_to_string(WiFi.status()));
Pieter

thomascoope

Thats a nice way of doing it!  Thanks.

Go Up