|
From: Bill S. <g4...@cl...> - 2019-03-27 16:00:27
|
On 27/03/2019 03:12, Ed Stokes wrote: > // kGroupAddress = 127.0.0.1 > // kOutPort = 61880 > > Dim d As new Datagram > Dim clearMessage As String > > clearMessage = ChrB(&hAD) + ChrB(&hBC) + ChrB(&hCB) + ChrB(&hDA) > clearMessage = clearMessage + ChrB(&h0) + ChrB(&h0) + ChrB(&h0) + > ChrB(&h2) > clearMessage = clearMessage + ChrB(&h0) + ChrB(&h0) + ChrB(&h0) + > ChrB(&h3) > clearMessage = clearMessage + ChrB(&h2) // + ChrB(&h0) > > d.Address = kGroupAddress > d.Port = kOutPort > d.Data = clearMessage > > UdPSocket1.Write( d ) > > This did not produce any effect. So then, I thought perhaps I needed > another UDP socket as #1 was connected to port 2237. > Hi Ed, there's no problem with using the same socket for sending and receiving, that's pretty standard with UDP. You have a few issues remaining. It looks like you are hard coding the send address and port, don't do that as the port will change and the address might too. You must use the sender address and port as given to you from a previous datagram receive. The next issue is that you do not have the Clear message fields correct, there is an 'id' field after the message type field. It is a UTF-8 string field which can be empty or null as currently WSJT-X doesn't do anything with it. Either put your application name in, send an empty string 9an empty string is a count sub-field containing the value zero unsigned 32-bit), or send a null string (count as &hfffffffff). You are probably not using the right tools for the job, Xojo has some types that make network message parsing and building really easy. Here is how I would read a message: Const magic As UInt32 = &hadbccbda Dim dg As Datagram = WSJTXSocket.Read Dim is As New BinaryStream (dg.Data) If is.ReadUInt32 <> magic Then Return Dim schema As UInt32 = is.ReadUInt32 Dim msg_type As Uint32 = is.ReadUInt32 Dim length as UInt32 = is.ReadUInt32 Dim id As String if length > 0 And length < &hffffffff Then id = is.Read (length, Encodings.UTF8) Select Case msg_type Case 0 ' Heartbeat Case 2 ' Decode Dim is_new As Boolean = is.ReadBoolean Dim ms As UInt32 = is.ReadUInt32 ' ms since midnight Dim snr As UInt32 = is.ReadInt32 Dim dt As Double = is.ReadDouble Dim df As UInt32 = is.readUInt32 Dim mode As String = is.Read (is.ReadUInt32, Encodings.UTF8) Dim message As String = is.Read (is.ReadUInt32, Encodings.UTF8) Dim low_confidence As Boolean = is.ReadBoolean Dim off_air As Boolean = is.ReadBoolean Case 6 ' Close End Select The same applies to building outgoing messages: Dim mb As New MemoryBlock (0) Dim os As New BinaryStream (mb) os.LittleEndian = False os.WriteUInt32 (magic) os.WriteUInt32 (2) os.WriteUInt32 (3) ' Clear os.WriteUInt32 (&hffffffff) ' Null id string os.WriteUInt8 (0) ' Clear Band Activity window Dim msg As Datagram msg.Address = dg.Address msg.Port = dg.Port msg.Data = mb WSJTXSocket.Write (msg) 73 Bill G4WJS. |