Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By pidloop
#73123 The following sketch would automatically reconnect using 2.3.0 but in 2.4.0 it never does. To test:

1. edit ssid and pw to your AP creds
2. turn on your Access Point radio, start sketch, it will soon report WL_CONNECTED
3. turn off the AP radio and it will soon report WL_DISCONNECTED
4. turn on AP radio. Version 2.3.0 will soon report WL_CONNECTED but 2.4.0 stays WL_DISCONNECTED forever
5. Note that in 2.4.0 even though the status stays WL_DISCONNECTED pinging the ESP IP does succeed, so it seems the ESP really does automatically reconnect but does not report this as status.

Thank you.


Code: Select all#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <WiFiServer.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>

char ssid[] = "xxx";
char pw[] = "yyy";

void setup()
{
    Serial.begin(115200);

    WiFi.enableSTA(true);

    WiFi.setAutoConnect (true);
    WiFi.setAutoReconnect (true);

    WiFi.begin (ssid, pw);

    Serial.println("start");
}

void loop()
{
    prWiFiStatus(WiFi.status());

    if (WiFi.isConnected())
        Serial.println (WiFi.localIP());

    delay(2000);
}

void prWiFiStatus (int s)
{
    #define     VALCASE(x)      case x: Serial.println(#x); break;

    switch (s) {
    VALCASE(WL_NO_SHIELD);
    VALCASE(WL_IDLE_STATUS);
    VALCASE(WL_NO_SSID_AVAIL);
    VALCASE(WL_SCAN_COMPLETED);
    VALCASE(WL_CONNECTED);
    VALCASE(WL_CONNECT_FAILED);
    VALCASE(WL_CONNECTION_LOST);
    VALCASE(WL_DISCONNECTED);
    default: Serial.println(s); break;
    }
}
User avatar
By dragondaud
#73157 using 1.4 will leave you vulnerable to various WiFi bugs that were fixed in the newer version (like KRACK). Instead of going backwards, I use this workaround which has worked for me:

Code: Select allvoid loop() {
  while (WiFi.status() != WL_CONNECTED || WiFi.localIP() == IPAddress(0,0,0,0)) {
    WiFi.reconnect();
    delay(1000);
  }
  [...]
}