测试从wifi传数据到串口
cnt = 0
cl = net.createConnection(net.TCP, 0)
cl:connect(8080, "192.168.1.102")
cl:on("receive", function(sck, c)
-- print(c)
uart.write(0, c);
end)
cl:on("disconnection", function(sck, c) print("disconnection!") end)
cl:on("sent", function(c)
if cnt ~= 10 then
cl:send(cnt)
cnt = cnt + 1
end
end)
cl = net.createConnection(net.TCP, 0)
cl:connect(8080, "192.168.1.102")
cl:on("receive", function(sck, c)
uart.write(0, c);
end)
cl:on("disconnection", function(sck, c) print("disconnection!") end)
cl:on("sent", function(c)
end)
uart.on("data", 1,
function(data)
cl:send(data)
if data=="quit"then
uart.on("data") -- unregister callback function
end
end, 0)