Skip to content

Commit

Permalink
add support for QDataStream::Qt_5_4 (#40)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ftl authored Jul 12, 2024
1 parent c4f65c7 commit d9f2de1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 8 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9f2de1

Please sign in to comment.