Avoid memory clogging when WiFi disconnected #692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
395ff
The continous MQTT reconnect attempts - when the WiFi is disconnected - always eat up some memory from the heap.
If the WiFI is off for some hours, no memory is left and I get a
Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
when the WiFi is reconnecting and the device reboots.
I noticed this, since I have the outputs of my ESP8266 control luminaries and they turn on or off hazardously after the WiFi and MQTT reconnects. Some outputs are shared pins with builtin LEDs, but of course the
Homie.disableLedFeedback();
does not survive the reboot.The code only attempts to reconnect the MQTT if the WiFi is connected. This way, the memory is not eaten up while the station is offline.
Could not test with ESP32 if this needs to / can be done there as well since I do not have one. If it does work as well, the code could be simplified taking out the precompiler directives.
390:
since for ESP8266 we have set
WiFi.setAutoConnect(true)
andWiFi.setAutoReconnect()
, it is in my opinion not necessary to explicitly call_wifiConnect();
The WIFI_DISCONNECTED event is fired constantly, anyway (every 3 seconds or so).This however, does not lead to memory clogging.