Current Lua downloadable firmware will be posted here

User avatar
By RinusW
#45089 Hi, I noticed a curious thing. When I disconnect my NodeMCU ESP12 development board from power and after a while connect it again, the ESP12 will connect to my WiFi network with the same IP without a single line of code executed. There is no init.lua file, so there is nothing to execute.
I do not need to execute wifi.setmode() and wifi.sta.config() commands, the network connection is up automatically, with the correct credentials. And the wifi.sta.status() function returns 5 (STATION_GOT_IP).
So, is this a new feature? Should I check if the network is active already before I issue a wifi.setmode() and wifi.sta.config() command?

The ESP device on my development board (from Doit) is an ESP-12E. I flashed it with nodeMCU:
Code: Select allNodeMCU custom build by frightanic.com
   branch: master
   commit: c8037568571edb5c568c2f8231e4f8ce0683b883
   SSL: false
   modules: bit,file,gpio,i2c,net,node,pwm,spi,tmr,uart,wifi
 build    built on: 2016-03-16 12:38
 powered by Lua 5.1.4 on SDK 1.4.0
User avatar
By RinusW
#45164 I investigated this a bit further. It seems that the ESP12 tries to get a network connection immediately after power-on based on the known(?) credentials. If I start my init.lua with a timer (tmr.alarm()) of 4 s, and then test the connection, the ESP12 already got connected to my network.

It is not clear to me if this is a feature. It does mean that the network credentials (Ssid, password) are stored in non-volatile memory. Could this be a security risk?
User avatar
By dnc40085
#47058 It's a feature, the SDK has a section at the end of the flash that is reserved for storing the credentials of up to 5(or 6) Access Points. As for the security of this area, that question might be better asked on the Espressif forum.

if you would prefer, you can prevent the ESP8266 from connecting automatically at boot by using the command wifi.sta.config("ssid", "pwd", 0) or wifi.sta.autoconnect(0) after
wifi.sta.config("ssid", "pwd").

Almost forgot, the function wifi.setmode() also saves the WiFi mode in flash.