Hi,
I am trying to work out how to send a UDP message which contains binary 5 bytes and get the reply.
The device I am sending the message to is on the local network.
I have been told:
Use UDP to send the binary 5 bytes 0x007FFFFFFF to destination port 12345. The 7FFFFFFF is a mask for what you want returned.
I am currently trying to get it working in B4J for testing, but eventually I am planning to do this in B4A/B4i as well.
I have tired the following, but I am guessing I am doing it wrong as it doesn't return anything.
Anyone know how to do this, and where I have gone wrong ?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I am trying to work out how to send a UDP message which contains binary 5 bytes and get the reply.
The device I am sending the message to is on the local network.
I have been told:
Use UDP to send the binary 5 bytes 0x007FFFFFFF to destination port 12345. The 7FFFFFFF is a mask for what you want returned.
I am currently trying to get it working in B4J for testing, but eventually I am planning to do this in B4A/B4i as well.
I have tired the following, but I am guessing I am doing it wrong as it doesn't return anything.
Anyone know how to do this, and where I have gone wrong ?
			
				B4X:
			
		
		
		Sub Process_Globals
    
    Dim UDP_Listen As UDPSocket        'jnetwork lib
    Dim Packet1 As UDPPacket        'jnetwork lib
    
    Dim data() As Byte
    
End Sub
Sub AppStart (Args() As String)
    
    UDP_Listen.Initialize("UDP_Listen",12345,9999999)
    
    RunMe
    
    StartMessageLoop
    
End Sub
Sub RunMe
    
    Dim msg As String = "0x007FFFFFFF"
    
    data = msg.GetBytes("UTF8")
    Packet1.Initialize(data, "192.168.0.33", 12345)
    UDP_Listen.Send(Packet1)
        
End Sub
Sub UDP_Listen_PacketArrived (Packet As UDPPacket)
    
    Dim msg1 As String
    msg1 = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
    Log(msg1)
    
End Sub 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		