• Source
    1. -- start
    2. uart.setup(0,921600,8,0,1,0)
    3. wifi.sta.setip({ip="192.168.1.119",netmask="255.255.255.0",gateway="192.168.1.1"})
    4. --
    5. wifi.setmode(wifi.STATION)
    6. print('set mode=STATION (mode='..wifi.getmode()..')')
    7. --
    8. print('MAC: ',wifi.sta.getmac())
    9. print('chip: ',node.chipid())
    10. print('heap: ',node.heap())
    11. --
    12. wifi.sta.config("*********","*********")
    13. --
    14. tmr.alarm(0, 1000, 1, function()
    15. if wifi.sta.status() ~= 5 then
    16. print("Connecting to AP...")
    17. else
    18. print(wifi.sta.getip())
    19. tmr.stop(0)
    20. end
    21. end)
    22. -- a simple telnet server
    23. pin = 4
    24. gpio.mode(pin, gpio.OUTPUT)
    25. --
    26. s = net.createServer(net.TCP,180)
    27. s:listen(2323,function(c)
    28.  
    29. c:on("receive",function(c,l)
    30. gpio.write(pin, gpio.LOW)
    31. uart.write(0, l)
    32. gpio.write(pin, gpio.HIGH)
    33. end)
    34.  
    35. c:on("disconnection",function(c)
    36. -- client disconnected
    37. end)
    38.  
    39. uart.on("data", 0,
    40. function(data)
    41. -- resend from uart
    42. c:send(data)
    43. end, 0)
    44.  
    45. -- client connected
    46. end)