Change telnet server to work on the console rather than the uart

This commit is contained in:
Ryan Voots 2016-05-01 15:33:56 -07:00
parent cdfb1b8071
commit dd25fdee4d

View file

@ -1,19 +1,19 @@
return function(port) return function(port)
function connected(conn) -- a simple telnet server
negotiate = string.char(255, 253, 34, 255, 250, 34, 1, 0, 255, 240, 255, 251, 1) s=net.createServer(net.TCP,180)
conn:send(negotiate) s:listen(port,function(c)
conn:on("receive", function(conn, pl) function s_output(str)
conn:send('.') if(c~=nil)
uart.write(0, pl) then c:send(str)
end) end
end end
node.output(s_output, 0) -- re-direct output to function s_ouput.
function startTelnet() c:on("receive",function(c,l)
print("Starting Telnet server") node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
sv = net.createServer(net.TCP, 180) end)
sv:listen(23, connected) c:on("disconnection",function(c)
print("Telnet server now started") node.output(nil) -- un-regist the redirect output function, output goes to serial
end end)
startTelnet() print("Welcome to NodeMcu world.")
-- uart.setup(0, 9600, 8, 0, 1, 0) end)
end end