Advertisement
dmitrij999

init.lua

Feb 18th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. --wifi.sta.autoconnect(1)
  2. i = 0
  3. --print(wifi.sta.getip())
  4. dofile("example.lua")
  5. wifi.setmode(wifi.STATION)
  6. wifi.sta.config("tp-link","00000000")
  7. wifi.sta.autoconnect(1)
  8. --gpio.mode(2, gpio.OUTPUT)
  9. tmr.register(1, 1000, 1, function()
  10. print(wifi.sta.getip())
  11. if wifi.sta.getip() == nil then
  12. print("Connecting...")
  13. --wifi.sta.connect();
  14. i = i+1
  15. if (i>10) then
  16. tmr.stop(1)
  17. i = 0
  18. print("Failed")
  19. end
  20. else
  21. --gpio.write(2, gpio.HIGH)
  22. getip=wifi.sta.getip()
  23. i = 0;
  24. print("Connected, IP is "..getip.."\n\r")
  25. tmr.stop(1)
  26. end
  27. end)
  28. tmr.start(1)
  29.  
  30. --collectgarbage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement