if I have init.lua:
app = require("application")
config = require("config")
setup = require("setup")
function startup()
setup.start()
end
tmr.alarm(0,9000,0,startup)and in setup.lua:
local module = {}
module.timeout = 0;
local function wifi_wait_ip()
if wifi.sta.getip()== nil then
print("IP unavailable, Waiting..."..module.timeout)
module.timeout = module.timeout + 1
if(module.timeout >= 10) then
node.restart()
end
else
tmr.stop(1)
print("\n====================================")
print("ESP8266 mode is: " .. wifi.getmode())
print("MAC address is: " .. wifi.ap.getmac())
print("IP is "..wifi.sta.getip())
print("====================================")
app.start()
end
end
local function wifi_start(list_aps)
if list_aps then
for key,value in pairs(list_aps) do
if config.SSID and config.SSID[key] then
wifi.setmode(wifi.STATION);
wifi.sta.config(key,config.SSID[key])
wifi.sta.connect()
print("Connecting to " .. key .. " ...")
--config.SSID = nil -- can save memory
tmr.alarm(1, 2500, 1, wifi_wait_ip)
print("Connected!")
end
end
else
print("Error getting AP list")
node.restart()
end
end
function module.start()
print("Configuring Wifi ...")
wifi.setmode(wifi.STATION)
wifi.sta.getap(wifi_start)
end
return module will node.restart() in function wifi_wait_ip() restart whole NodeMcu?
I ask because for now instead of init.lua I have test.lua and this node.restart() shows some error in ESPlorer. Last night I went error, I will try to upload error that raise up, but now I'am not have my laptop and NodeMcu with me.
Thanx,
Faramon