Closed goatchurchprime closed 2 years ago
This is by design to minimise flash wear. If you specify an SSID and PW these are written to flash, causing wear. If you want to change this behaviour so that it only connects to the specified network, I suggest you change the line you referenced to match ESP32 behaviour.
There may be a way to meet your needs and reduce wear by storing the last connection details in a file (whenever this changes), and doing a specified connect when the requested credentials don't match the stored ones.
I don't plan to change the code as I believe it suits the majority of applications.
But is there a way to read the stored SSID to compare it with what's put into the config? This would not produce any wear.
I don't know of any. You could ask in the forum.
I also checked and sadly didn't find an option to read the ssid of the current connection.. A workaround would be to manually connect to the network you want before starting the mqtt.connect(). It will make a write to the flash but a single write to the flash every time the device resets shouldn't cause enough wear to destroy the flash within a few years.
The function
wifi_connect()
has the line:Only after this times out does it then call:
Is there a way to check the name of the connection that the ESP8266 remembered, and compare it to the ssid that the programmer has asked for before assuming that it hasn't changed?