I'm having a bit of trouble with the following code:
wifi.setmode(wifi.STATION)
wifi.sta.setmac("\002\001\002\003\003\006")
wifi.sta.config("xxx","yyy")
--tmr.delay(12000000)
--print(wifi.sta.getip())
uart.setup(0,9600,8,0,1,0)
sv=net.createServer(net.UDP, 3000)
global_c = nil
sv:listen(5568, function(c)
if global_c~=nil then
global_c:close()
end
global_c=c
c:on("receive",function(sck,pl) uart.write(0,pl) end)
end)
uart.on("data",1, function(data)
if global_c~=nil then
global_c:send(data)
end
end, 0)For some reason, I can't establish a UDP connection with this code. However, if I change net.UDP to net.TCP, I can establish a TCP connection and the code works perfectly. Does anyone have any insight as to what I am doing wrong?