Hi,
WEMOS D1 R2, B4R 1.80, Arduino v1.8.1
UDP sending to broadcast address fails to send
Just trying to send a udp packet on broadcast (255.255.255.255=>port)
But monitoring the network packets (tcpdump) i dont see it even try to attempt to send..
'this does not seem to work?
udp.BeginPacket("255.255.255.255",4101)
udp.Write("test".GetBytes)
udp.SendPacket
Note: The code below is just a sample and not the full working code.
Any assistance is appreciated
EDIT: all udp seems to fail, so using
udp.BeginPacket("192.168.1.22",5211)
also fails to send... mmm... what am i missing?
Lee.
WEMOS D1 R2, B4R 1.80, Arduino v1.8.1
UDP sending to broadcast address fails to send
Just trying to send a udp packet on broadcast (255.255.255.255=>port)
But monitoring the network packets (tcpdump) i dont see it even try to attempt to send..
'this does not seem to work?
udp.BeginPacket("255.255.255.255",4101)
udp.Write("test".GetBytes)
udp.SendPacket
Note: The code below is just a sample and not the full working code.
Any assistance is appreciated
EDIT: all udp seems to fail, so using
udp.BeginPacket("192.168.1.22",5211)
also fails to send... mmm... what am i missing?
Lee.
B4X:
Sub Process_Globals
Private udp As WiFiUDP
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
udp.Initialize(4102,"udp_PacketArrived")
DoConnect ' connects fine, and i can see the Bootp/DHCP request
End Sub
Sub timer1_tick
If wifi.IsConnected = True Then
Log("MyIP ",wifi.LocalIp )
'this does not seem to work?
udp.BeginPacket("255.255.255.255",4101)
udp.Write("test".GetBytes)
udp.SendPacket
Else
Log("Wifi not connected")
End If
End Sub
Sub udp_PacketArrived (Data() As Byte, Ip() As Byte, Port As UInt)
Log("PacketArrived from:")
PrintIp(Ip)
log(Data.Length)
End Sub
Sub PrintIp(ip() As Byte)
Log(ip(0),".", ip(1),".", ip(2),".", ip(3))
End Sub
Sub DoConnect
Log("Wifi trying to connect")
If WifiConnect Then '(use Connect2 if a password is required).
Log("Connected to wireless network.")
Else
Log("Failed to connect.")
End If
End Sub
Sub WifiConnect() As Boolean
Dim l As Int
Log("Wifi ssid: digger ")
If wifi.Connect2("digger","apassword") Then Return True
Return False 'can not connect
End Sub
Last edited: