From d9f2de191c800017059d3ad4c946ef0d294ecea4 Mon Sep 17 00:00:00 2001 From: Florian Thienel Date: Sat, 13 Jul 2024 01:18:06 +0200 Subject: [PATCH] add support for QDataStream::Qt_5_4 (#40) QDataStream::Qt_5_4 is used by newer versions of WSJT-X. The difference to QDataStream::Qt_5_2 are not relevant for WSJT-X. --- encoder.go | 2 +- parser.go | 2 +- server.go | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/encoder.go b/encoder.go index fe9e61f..d293d9f 100644 --- a/encoder.go +++ b/encoder.go @@ -127,7 +127,7 @@ func newEncoder() encoder { e := encoder{bytes.NewBuffer(make([]byte, bufLen))} e.buf.Reset() e.encodeUint32(magic) - e.encodeUint32(schema) + e.encodeUint32(qDataStream5_2) return e } diff --git a/parser.go b/parser.go index 6b6817b..25feb1e 100644 --- a/parser.go +++ b/parser.go @@ -37,7 +37,7 @@ func parseMessage(buffer []byte, length int) (interface{}, error) { if err != nil { return nil, ParseError } - if sch != schema { + if !supportedSchemas[sch] { return nil, fmt.Errorf("%w: got a schema version I wasn't expecting: %d", ParseError, sch) } diff --git a/server.go b/server.go index 540e777..f42855c 100644 --- a/server.go +++ b/server.go @@ -8,13 +8,20 @@ import ( ) const magic = 0xadbccbda -const schema = 2 const qDataStreamNull = 0xffffffff const bufLen = 1024 const localhostAddr = "127.0.0.1" const multicastAddr = "224.0.0.1" const wsjtxPort = 2237 +const qDataStream5_2 uint32 = 2 +const qDataStream5_4 uint32 = 3 + +var supportedSchemas = map[uint32]bool{ + qDataStream5_2: true, + qDataStream5_4: true, +} + type Server struct { ServingAddr net.Addr conn *net.UDPConn