telnet.lua 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. print("====Wicon, a LUA console over wifi.==========")
  2. print("Author: openthings@163.com. copyright&GPL V2.")
  3. print("Last modified 2014-11-19. V0.2")
  4. print("Wicon Server starting ......")
  5. function startServer()
  6. print("Wifi AP connected. Wicon IP:")
  7. print(wifi.sta.getip())
  8. sv=net.createServer(net.TCP, 180)
  9. sv:listen(8080, function(conn)
  10. print("Wifi console connected.")
  11. function s_output(str)
  12. if (conn~=nil) then
  13. conn:send(str)
  14. end
  15. end
  16. node.output(s_output,0)
  17. conn:on("receive", function(conn, pl)
  18. node.input(pl)
  19. if (conn==nil) then
  20. print("conn is nil.")
  21. end
  22. end)
  23. conn:on("disconnection",function(conn)
  24. node.output(nil)
  25. end)
  26. end)
  27. print("Wicon Server running at :8080")
  28. print("===Now,Using xcon_tcp logon and input LUA.====")
  29. end
  30. tmr.alarm(0, 1000, 1, function()
  31. if wifi.sta.getip()=="0.0.0.0" then
  32. print("Connect AP, Waiting...")
  33. else
  34. startServer()
  35. tmr.stop()
  36. end
  37. end)