Left here for archival purposes.

User avatar
By Starfix
#34674 Seems to be a strange problem with UDP working as broadcast:
- UDP packet sent on a specific IP are always sent. Works fine.
- same UDP packet sent on broadcast IP (xx.xx.xx.255) are sent randomly...
Checked with WireShark

Code: Select allfunction update()
   local payload
   if(UDP_test_toggle == 1) then
      UDP_test_toggle = 0
      payload = "Number 1"
   else
      UDP_test_toggle = 1
      payload = "Number 0"
   end
   print(payload)
   local broadcast_IP = wifi.ap.getbroadcast()
   cu=net.createConnection(net.UDP)
   cu:connect(5683, broadcast_IP)
   cu:send(payload)
   cu:close()
end

wifi.setmode(wifi.SOFTAP)
cfg={}
cfg.ssid="XXXXXXXX"
cfg.pwd="88888888"
cfg.hidden=1
wifi.ap.config(cfg)

tmr.alarm(0, 1000, 1, update)

Any idea ? I am really confused, because I made 4 UDP receiver boards and I am not able to make the sender one working !!! I think to use a workaround by coding directly in C on ESP07, but my fear is that the bug reside in Espressif API and so not working better... :roll:
User avatar
By Starfix
#35665 I made some more investigations. Thanks to the work of CHERTS I was able to quickly make the same firmware in C:
- with SDK_141, same trouble. So my first thought was right, it's not a NodeMCU LUA bug, but an Espressif SDK one...
- with the new fresh SDK_150, it works fine :P. Apparently they made a lot of improvements on UDP packets.

So when NodeMCU LUA based on that SDK will be released, it should be ok...