Closed shariq-azim closed 3 years ago
esp32 has no autoconnect you will have to use the event hooks and add your own or add some timed loop check and reconnect with standard esp methods begin() or reconnect()
esp32 should reconnect though, maybe it broke
@tablatronix hey that's what I am doing right in loop function? ` void loop() { Serial.println("Loop started"); Serial.print("Wifi status: "); Serial.println(WiFi.status()); if (WiFi.status() != WL_CONNECTED) { if (DEBUG_SW) Serial.println("Not Connected");
if( connected_once == true){
Serial.println("Reconnecting");
WiFi.reconnect();
//even tried // WiFi.disconnect(); // delay(1100); //custom // WiFi.begin(ssid, pass); } else{ Serial.println("Re-attempting to connect"); WiFi.begin(ssid, pass); } } else { if (DEBUG_SW) Serial.println(" Connected"); Blynk.run(); }
timer.run(); // Initiates SimpleTimer
server.handleClient(); //custom delay(400); //custom
if (MODE == 0) with_internet(); else without_internet(); // put your main code here, to run repeatedly: } `
btw, are you aware if wifi manager library updates ssid chars, during its operation in loop function? i put some logs, and saw "rm7pro" getting updated to either "rm7p " or "r 7pro".. it is even strangely updating the last saved ap ssid?
It does not , sounds like a memory issue something is clobbering that memory
Just do begin()
Hi there,
It definitely looks like memory issue.. But I was able to reconnect removing
if (WiFi.status() == WL_CONNECTED) { Serial.println( "connected once"); connected_once = true; }
in main function..
And adding a while loop in loop function.
` if (WiFi.status() != WL_CONNECTED) { Serial.println("Re-attempting to connect"); WiFi.reconnect();
int ct =0;
while(WiFi.status() != WL_CONNECTED){
delay(1000); //custom
Serial.print(".");
ct=ct+1000;
if(ct>10000){
break;
}
} }`
But, my question remains "How to know if the credentials is reconfigured or how can we get the last saved AP(ssid) name"?
you will want to add a timer for that probably, or else it will try on every loop when router is down or out of range
WiFi.begin(); is all you need you can get the ssid like you normally do for esps only diff with esp32 is it will be blank if wifi is not initialized yet ( remember no esp32 has no autoconnect)
Hello @tablatronix . I am late to properly understand and implement your suggestions. But , yes you are correct. Using Wifi.begin() instead of WiFi.reconnect() solved my issue.. Thanks
Hello @tablatronix , All this were still working well for a while and i also didnt check much to work on it.. Now all of a sudden when i thought to tweak it a little, i see the same issue coming up. the changes now done are just publishing into a new channel thats it.
My library version is 2.0.16-rc.2 now
Yeah I had to disable some stuff you have have wifi init on esp32 to read the stored flash config
Yeah I had to disable some stuff you have have wifi init on esp32 to read the stored flash config
Sorry little confused what should i be doing?
Basic Infos
I am trying to reconnect to the last known configurations or saved credentials(ssid, password) after the connection is lost temporarily for a while. In case it was reconfigured or had no wifi present before timeout ,it will return no proper/empty values. Thus, If I somehow know if there was a change of ssid somehow I can force restart on it to work properly.
Hardware
WiFimanager Branch/Release: Master- Developement 2.0.1 alpha
Esp32
Core Version: Not sure :/
Description
Now, with the code that i have compiled so far. I am facing two issues
Unfortunately, since my program is meant to run both online and offline, I cannot keep it struck in the blocking while(WiFi.status() != WL_CONNECTED) loop..
Settings in IDE
Module: Esp32 dev module
Additional libraries:
Sketch
Debug Messages
succesful case if manally rebooted and wifi available