-4
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

#ifndef STASSID
#define STASSID "wlanName"
#define STAPSK  "wlanPassword"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

const char* host = "api.github.com";
const int httpsPort = 443;

const char fingerprint[] PROGMEM = "5F F1 60 31 09 04 3E F2 90 D2 B0 8A 50 38 04 E8 37 9F BC 76";

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.println();
  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (true) {
    delay(500);
    Serial.print(WiFi.status());
  }
}

void loop() {
  // put your main code here, to run repeatedly:
}

If I run this code, I will get 6 as output from Wifi.status(), and once I also got 4. What do 4 and 6 stand for? Is it connected or not? What other status codes do I have to know?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I haven't said that it is an error code, i just wanted to know what the code stands for? If you don't find a website you will get a 404 status code back to know that it hasn't found what you are looking at so i thought 6 could mean something like, you are connected or invalid passwort etc – Stephan Stieger Mar 28 '21 at 17:25
  • in title you have esp32 but your sketch is for esp8266 https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/station-class.html#status – Juraj Mar 28 '21 at 17:29
  • Oh sry i thought they are the same, thanks for the information, i change it immediately – Stephan Stieger Mar 28 '21 at 17:33
  • it is called "a lack of research". you should search for answers before asking questions – Juraj Mar 31 '21 at 05:09
  • don't be so toxic – Stephan Stieger Apr 03 '21 at 08:58

1 Answers1

-1

There is publicly available documentation https://www.arduino.cc/en/Reference/WiFiStatus

Arduino sources are open source. You can browse the sources.

Type in google "Arduino esp8266 source github" and you may find https://github.com/esp8266/Arduino . From there you can ex. type WL_CONNECTED in search bar above and find this line of code:

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_WRONG_PASSWORD   = 6,
    WL_DISCONNECTED     = 7
} wl_status_t;
KamilCuk
  • 120,984
  • 8
  • 59
  • 111