B4R Question UDP SendPackets Multiple Devices from Arduino

Discussion in 'B4R Questions' started by ALEX BISSARO PITTA, Jan 13, 2018.

  1. ALEX BISSARO PITTA

    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.


    Code:
    Sub Process_Globals

    Private serverIp1() As Byte = Array As Byte(1921681150'IP Cell Phone 1

    Private serverIp2() As Byte = Array As Byte(1921681151'IP Cell Phone 2

    Private serverIp3() As Byte = Array As Byte(1921681152'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
     
    spairo likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. ALEX BISSARO PITTA

    ALEX BISSARO PITTA Member Licensed User

    1. I'll have a look on this item.

    2. What do you mean with creating 3WifiUDP objects? How can it be done?
    I'm using Arduino Mega by the way.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    My mistake. It will not help.
     
  5. ALEX BISSARO PITTA

    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!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Just try to send the messages to the broadcast address. Note that it is not very reliable. Some of the messages will be lost.
     
  7. ALEX BISSARO PITTA

    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.
     
  8. ALEX BISSARO PITTA

    ALEX BISSARO PITTA Member Licensed User

    I understood how to broadcast..
    thanks!
     
Loading...