init.lua 673 B

1234567891011121314151617181920212223242526
  1. -- Tell the chip to connect to the access point
  2. print('Welcome')
  3. wifi.setmode(wifi.STATION)
  4. print('set mode=STATION (mode='..wifi.getmode()..')')
  5. print('MAC: ',wifi.sta.getmac())
  6. print('chip: ',node.chipid())
  7. print('heap: ',node.heap())
  8. wifi.sta.config("Internet","")
  9. --require("httpserver")
  10. -- Wait until WiFi connection is established
  11. tmr.alarm(0, 2000, 1, function()
  12. if wifi.sta.getip() == nil then
  13. print("Connecting to AP...")
  14. else
  15. tmr.stop(0)
  16. print('IP: ',wifi.sta.getip())
  17. local port = 80
  18. --server = httpserver.start(port, 10)
  19. --print("nodemcu-httpserver started on port " .. port)
  20. end
  21. end)