Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --wifi config--
- WIFI_SSID = "SSDNAME"
- WIFI_PASSWORD = "PASSWORD"
- WIFI_SIGNAL_MODE = wifi.PHYMODE_G
- --ip config--
- IP = "10.10.10.250"
- NETMASK = "255.255.255.0"
- GATEWAY = "10.10.10.1"
- --connect to wifi--
- wifi.setmode(wifi.STATION)
- wifi.setphymode(WIFI_SIGNAL_MODE)
- wifi.sta.config(WIFI_SSID, WIFI_PASSWORD)
- wifi.sta.connect()
- if ip ~= "" then
- wifi.sta.setip({ip=IP, netmask=NETMASK, gateway=GATEWAY})
- end
- print(wifi.sta.getip())
- -- Start server after 2.5 sec.
- tmr.alarm(0, 2500, 0, function()
- uart.on("data") -- stop listening UART.
- print "starting server..."
- require "server"
- end)
- -- Listen to UART data and stop the above timer in case of "qw" string was received.
- uart.on("data", "w", function(d)
- if d == "qw" then
- tmr.stop(0) -- Stop timer. Server won't start.
- uart.on("data")
- print "cancelled."
- end
- end, 0)
Advertisement
Add Comment
Please, Sign In to add comment