wifi-tally_Oostendam/nodemcu-firmware/lua_examples/tcp2uart.lua

19 lines
385 B
Lua
Raw Normal View History

2021-09-27 19:52:27 +00:00
do
uart.setup(0, 9600, 8, 0, 1, 0)
local sv = net.createServer(net.TCP, 60)
local global_c = nil
sv:listen(9999, function(c)
if global_c~=nil then
global_c:close()
end
global_c = c
c:on("receive",function(_, pl) uart.write(0, pl) end)
end)
uart.on("data", 4, function(data)
if global_c ~= nil then
global_c:send(data)
end
end, 0)
end