-- Constants SSID = "MessWLAN" APPWD = "UNVmpwbr6heQnMQ7ykXT" CMDFILE = "mqtt.lua" -- Some control variables wifiTrys = 0 NUMWIFITRYS = 200 function launch() print("A") print("B: " .. wifi.sta.getip()) tmr.alarm(0, 5000, 0, function() dofile(CMDFILE) end ) end function checkWIFI() if ( wifiTrys > NUMWIFITRYS ) then print("C") else ipAddr = wifi.sta.getip() if ( ( ipAddr ~= nil ) and ( ipAddr ~= "0.0.0.0" ) )then tmr.alarm( 1 , 500 , 0 , launch ) else tmr.alarm( 0 , 2500 , 0 , checkWIFI) print("D: " .. wifiTrys) wifiTrys = wifiTrys + 1 end end end print("E") ipAddr = wifi.sta.getip() if ( ( ipAddr == nil ) or ( ipAddr == "0.0.0.0" ) ) then print("F") wifi.setmode( wifi.STATION ) wifi.sta.config( SSID , APPWD) print("G") tmr.alarm( 0 , 2500 , 0 , checkWIFI ) else launch() end