Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tm = 0
- function wifiServer()
- local ap = {}
- ap.ssid = "blah"
- ap.pwd = "blah"
- local ip = {}
- ip.ip="10.1.1.1"
- ip.netmask="255.255.255.0"
- ip.gateway="10.1.1.1"
- wifi.setmode(wifi.SOFTAP)
- wifi.setphymode(wifi.PHYMODE_B)
- wifi.sleeptype(wifi.NONE_SLEEP)
- wifi.ap.setmac("99-99-99-99-99-99")
- wifi.ap.config(ap)
- wifi.ap.setip(ip)
- wifi.ap.dhcp.stop()
- end
- function netServer()
- local server = net.createServer( net.TCP, 10 )
- server:listen( 10000, function( conn )
- conn:on( "receive", function( socket, data )
- print( "DATA: "..data.."\n\r" )
- socket:send( "OK C:"..data.." on S:"..tmr.time() )
- print( "Drift: --> "..(tmr.time()-tm).." sec\n\r" )
- tm = tmr.time()
- end)
- conn:on( "connection", function()
- print( "Client connected\n\r")
- end)
- conn:on( "disconnection", function()
- print( "Client disconnected \n\r")
- end)
- conn:on( "reconnection", function()
- print( "Client re-connected\n\r")
- end)
- end)
- end
- wifiServer()
- netServer()
Advertisement
Add Comment
Please, Sign In to add comment