Closed
Description
Platform
- Hardware: ESP12 / ESP01 / Nodemcu
- Core Version: 2.3 (work) vs 2.4.2 (fails)
- Development Env: Arduino IDE
- Operating System: Ubuntu
Settings in IDE
- Module: Generic ESP8266
- Flash Size: 4MB/1MB
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|160MHz]
- Upload Using: [SERIAL]
Problem Description
I'm having problems migrating from core 2.3.0 to core 2.4.2. At first, I thought it was a MQTT problem, so I opened issue #5271 because I was losing connection to the server and after that, I coudn't reconnect any more.
I've done more research on it. The problem happends when you use wifi in STA and SOFTAP mode, when you change the SoftAP SSID.
I provide a sketch where you can check that. The sketch connects every "loop" to a HTTP server and shows the HTTP result code. If every so often the SoftAP SSID is changed, works with 2.3.0 core, but fails with 2.4.2.
Thanks in advance and best regards!!!!!!
MCVE Sketch
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
byte counter = 0;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_AP_STA);
WiFi.softAP("OPEN-SSID");
WiFi.begin("my-router", "my-passwd");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
/* EVERY SO OFTEN WE CHANGE SOFT AP SSID */
counter++;
if(counter%5==0) {
WiFi.softAP("OPEN-SSID");
}
if(counter%5==4) {
WiFi.softAP("LOCK-SSID","mypassword123");
}
/* END SOFT AP SSID CHANGE */
HTTPClient http;
Serial.print("[HTTP] begin...\n");
//http.begin("http://api.ipify.org?format=json"); //HTTP
http.begin("http://jsonplaceholder.typicode.com/todos/1");
Serial.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
//Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
delay(10000);
}
Debug Messages
VERSIÓN 2.4.2
==========================
Connecting...Connected, IP address: 192.168.120.76
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... failed, error: connection refused
// Never connects again.....
VERSIÓN 2.3.0
==========================
⸮Connecting......Connected, IP address: 192.168.120.76
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
[HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
// Never fails when connecting.....