B4R Question UDP SendPackets Multiple Devices from Arduino

ALEX BISSARO PITTA

Member
Licensed User
What is the correct way to send udp packets to multiple devices using UDP connection?
The only trick way I find out was as showed below. However it makes connection much more slower than with a single device.

And If I need to expand the connection to as many other devices I want it will make connection much more slower.


B4X:
Sub Process_Globals

Private serverIp1() As Byte = Array As Byte(192, 168, 1, 150) 'IP Cell Phone 1

Private serverIp2() As Byte = Array As Byte(192, 168, 1, 151) 'IP Cell Phone 2

Private serverIp3() As Byte = Array As Byte(192, 168, 1, 152) 'IP Cell Phone 3

End Sub

Private Sub sendPacket

    'Escreve nos dispositivos os status
    For i=1 To 3
        
        If i=1 Then
            udp.BeginPacket(serverIp1, serverPort)
        Else If i=2 Then
            udp.BeginPacket(serverIp2, serverPort)
        Else If i=3 Then
            udp.BeginPacket(serverIp3, serverPort)
        End If

        udp.Write(ser.ConvertArrayToBytes(Array ("CONNEC1",WatchDogStatus,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
        udp.SendPacket
                
    Next
    
End Sub
 

ALEX BISSARO PITTA

Member
Licensed User
I checked item 1 you mentioned (broadcast) but seems this fits only for ESP8266WiFi and WifiUDP. I could not identify a way to use it with Arduino Mega and Ethernet shield to broadcast with multiple users.

Is there a way to send both files from B4R and B4A than you can have a better idea what's in being done. Files size exceed the allowed for uploading.

Thanks!
 
Upvote 0

ALEX BISSARO PITTA

Member
Licensed User
Sorry but how can I broadcast address? Should be configured in B4A code? In the router?

I have never done it. If you could show how to do it I'd appreciate.

Tks.
 
Upvote 0
Top