doublemintben

My init.lua

Mar 10th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. --wifi config--
  2. WIFI_SSID = "SSDNAME"
  3. WIFI_PASSWORD = "PASSWORD"
  4. WIFI_SIGNAL_MODE = wifi.PHYMODE_G
  5.  
  6. --ip config--
  7. IP = "10.10.10.250"
  8. NETMASK = "255.255.255.0"
  9. GATEWAY = "10.10.10.1"
  10.  
  11. --connect to wifi--
  12. wifi.setmode(wifi.STATION)
  13. wifi.setphymode(WIFI_SIGNAL_MODE)
  14. wifi.sta.config(WIFI_SSID, WIFI_PASSWORD)
  15. wifi.sta.connect()
  16.  
  17. if ip ~= "" then
  18.     wifi.sta.setip({ip=IP, netmask=NETMASK, gateway=GATEWAY})
  19. end
  20.  
  21. print(wifi.sta.getip())
  22.  
  23. -- Start server after 2.5 sec.
  24. tmr.alarm(0, 2500, 0, function()
  25.     uart.on("data") -- stop listening UART.
  26.     print "starting server..."
  27.     require "server"
  28. end)
  29.  
  30. -- Listen to UART data and stop the above timer in case of "qw" string was received.
  31. uart.on("data", "w", function(d)
  32.     if d == "qw" then
  33.         tmr.stop(0) -- Stop timer. Server won't start.
  34.         uart.on("data")
  35.         print "cancelled."
  36.     end
  37. end, 0)
Advertisement
Add Comment
Please, Sign In to add comment