Open RulioHT2021 opened 1 year ago
Sorry, I'm new here, I'm having a memory problem, as each reconnection test consumes more memory.
Will test thanks
I am assuming you have removed your local callouts to timeClient, ping, client checks and you are not leaking memory in them ?
Make sure you are pulling git, there was an esp8266 fix recently
I am calling autoconnect in a loop and not leaking any memory.. Are you using blocking or non blocking mode? Let me try esp8266
Sorry I wasn't so clear, after connecting the network I turn off the router and with each reconnection attempt with the router turned off it consumes memory. I'm using it without blocking.
Ok so the configportal is starting each time? How do you get out of it, do you have a timeout?
and how do you know its not your code?
timeClient.update();
ping_test();
Not seeing it, what exact hardware you using ?
`bool ping_test(){ bool success = Ping.ping(p_url, 1); float avg_time_ms = Ping.averageTime(); if (success) { resp = "{\"avg_ping\":\"" + String(avg_time_ms) + "\"}"; } else { resp = "{\"avg_ping\":\"erro\"}"; } return success; }
if(((millis() - time_conect_broker) >= 60000)||(timeClient.getSeconds() == 50)){ Serial.println("Tempo atingido!"); time_conect_broker = millis(); digitalWrite(LED, HIGH); if(!client.connected()){ Serial.println("Chamando task_reconnect"); xTaskCreate( task_reconnect, //Nome da função "task_reconnect", //Nome da tarefa 10000, //Tamanho da tarefa NULL, //Parametros 2, //Prioridade NULL //Handle ); }else{ Serial.println("Conectado!"); } } `
I make a routine to check if 60 seconds have passed or if the timestamp is correct when it is 50 seconds, and I leave it inside the main loop.
Are you sure your tasks wrappers are cleaned up after each ? Sounds like it could be leaking there
I'll need to test other routines, I'll get back to you as soon as possible. Thanks.
16:39:29.378 -> ESP.getFreeHeap(): 207916 16:39:29.378 -> wm:AutoConnect 16:39:29.378 -> wm:Connecting to SAVED AP: Teste 16:39:29.892 -> wm:connectTimeout not set, ESP waitForConnectResult... 16:39:34.269 -> wm:AutoConnect: FAILED for 4902 ms 16:39:34.269 -> wm:StartAP with SSID: AFL_0212848844 16:39:34.784 -> wm:AP IP address: 192.168.4.1 16:39:34.784 -> Entrando em modo de configuração 16:39:34.784 -> Nome da rede WIFI, SSID: AFL_0212848844 16:39:34.784 -> Endereço de IP: 192.168.4.1 16:39:34.784 -> wm:Starting Web Portal 16:39:35.297 -> wm:config portal has timed out 16:39:35.297 -> wm:[ERROR] disconnect configportal - softAPdisconnect FAILED 16:39:36.278 -> wm:config portal exiting 16:39:36.278 -> ESP.getFreeHeap(): 206900 16:42:33.080 -> ESP.getFreeHeap(): 206852 16:42:33.080 -> wm:AutoConnect 16:42:33.080 -> wm:Connecting to SAVED AP: Teste 16:42:33.590 -> wm:connectTimeout not set, ESP waitForConnectResult... 16:42:38.012 -> wm:AutoConnect: FAILED for 4902 ms 16:42:38.012 -> wm:StartAP with SSID: AFL_0212848844 16:42:38.475 -> wm:AP IP address: 192.168.4.1 16:42:38.475 -> Entrando em modo de configuração 16:42:38.521 -> Nome da rede WIFI, SSID: AFL_0212848844 16:42:38.521 -> Endereço de IP: 192.168.4.1 16:42:38.521 -> wm:Starting Web Portal 16:42:38.988 -> wm:config portal has timed out 16:42:38.988 -> wm:[ERROR] disconnect configportal - softAPdisconnect FAILED 16:42:40.015 -> wm:config portal exiting 16:42:40.015 -> ESP.getFreeHeap(): 205848
void task_reconnect(void * parameter){
Serial.print("ESP.getFreeHeap(): ");
Serial.println(ESP.getFreeHeap());
wm.autoConnect(ssid, password);
Serial.print("ESP.getFreeHeap(): ");
Serial.println(ESP.getFreeHeap());
if(WiFi.status() == WL_CONNECTED){
Serial.println("WIFI OK");
timeClient.update();
ping_test();
Serial.println(resp);
if(client.connected()){
Serial.println("BROKER OK.");
}else if(client.connect((char*) s_id.c_str(), mqttUser, mqttPassword)){
Serial.println("BROKER OK.");
}else{
Serial.println("ERRO BROKER não conectado.");
}
}else{
Serial.println("ERRO WIFI não conectado");
}
vTaskDelete(NULL); // Delete task
}
I created a task to reconnect and as you can see, each call consumes a little memory after wm.autoConnect(ssid, password); The scenario I'm testing is: in case there is a power outage and the router does not come back on. Sooner or later it will restart due to lack of memory. The problem is that I'm running a routine that cannot be restarted.
Just set WM debug level to WM_DEBUG_MAX it will dump heap stats
Looks like leaking 1440 bytes, hmm I was not seeing this the other day.
I cant find it yet, but my memory jumps up and down but stays <100% so something is cleaning up, but maybe not under certain conditions. I will have to run memory deugging and find what on the heap. I thought It was the known DNSD issue but that might only be a tiny bit.
Do you have many AP found during scans? Are you using hostname or mdns? If you change the configportaltimeout to like 20 seconds does anything change memory wise?
I might also want to copy your config, what partition config are you using, and what esp32 and rev ? I am testing on an S3 with default partitions
partitions: LITTLEFS
If you change the configportaltimeout to like 20 seconds does anything change memory wise? yes, Do not change
Are you using hostname or mdns? no
I changed the code this way and solved the consumption problem.
void task_reconnect(void * parameter){
Serial.print("ESP.getFreeHeap(): ");
Serial.println(ESP.getFreeHeap());
WiFi.begin();
timeClient.begin();
//wm.autoConnect(ssid, password);
Serial.print("ESP.getFreeHeap(): ");
Serial.println(ESP.getFreeHeap());
if(WiFi.status() == WL_CONNECTED){
Serial.println("WIFI OK");
timeClient.update();
ping_test();
Serial.println(resp);
if(client.connected()){
Serial.println("BROKER OK.");
timeClient.begin();
}if(client.connect((char*) s_id.c_str(), mqttUser, mqttPassword)){
Serial.println("BROKER RECONECTADO.");
}else{
Serial.println("ERRO BROKER não RECONECTADO.");
}
}else{
Serial.println("ERRO WIFI não conectado");
}
vTaskDelete(NULL); // Delete task
}
12:38:56.216 -> ESP.getFreeHeap(): 207768 12:38:56.216 -> E (67820332) wifi:sta is connecting, return error 12:38:56.216 -> ESP.getFreeHeap(): 207476 12:39:56.854 -> ESP.getFreeHeap(): 207768 12:39:56.854 -> E (67880968) wifi:sta is connecting, return error 12:39:56.854 -> ESP.getFreeHeap(): 207476 12:40:57.179 -> ESP.getFreeHeap(): 207768 12:40:57.179 -> E (67941314) wifi:sta is connecting, return error 12:40:57.179 -> ESP.getFreeHeap(): 207476
Yeah I am not really sure what the issue is.. I will keep testing
My memory does this if i autoconnect loop
PLEASE TRY Latest Master BRANCH before submitting bugs, in case they were already fixed.
Issues without basic info will be ignored or closed!
Please fill the info fields, it helps to get you faster support ;)
if you have a stack dump decode it: https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/stack_dump.rst
for better debug messages: https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst
----------------------------- Remove above -----------------------------
Basic Infos
Hardware
WiFimanager Branch/Release: Master
Esp8266/Esp32:
Hardware: ESP-12e, esp01, esp25
Core Version: 2.4.0, staging
Description
Problem description
Settings in IDE
Module: NodeMcu, Wemos D1
Additional libraries:
Sketch
Debug Messages