I want to connect 2 Esp to a wireless uart,but it isn't working.
Main:
--uart.setup(0,9600,8,0,1,0)
tmr.delay(2000000)
conn=net.createConnection(net.TCP, false)
global_c = nil
conn:on("receive",function(c)
if global_c~=nil then
global_c:close()
end
global_c=c
c:on("receive", function(c, pl) print(pl) end)
--c:send("hello world")
end)
uart.on("data","\r", function(data)
if global_c~=nil then
global_c:send(data)
end
--uart.write(0,data)
end, 0)
conn:connect(80,'192.168.4.1')Other module:
--uart.setup(0,115200,8,0,1,0)
uart.setup(0,9600,8,0,1,0)
sv=net.createServer(net.TCP, 240)
global_c = nil
sv:listen(80,function(c)
if global_c~=nil then
global_c:close()
end
global_c=c
c:on("receive", function(c, pl) print(pl) end)
--c:send("hello world")
end)
uart.on("data","\r", function(data)
if global_c~=nil then
global_c:send(data)
end
--uart.write(0,data)
end, 0)
What can I do?