From aad9b54e3df7252da780db2fbdd87e1b7dfbb954 Mon Sep 17 00:00:00 2001 From: Nonoo Date: Sun, 18 Oct 2020 11:24:44 +0200 Subject: [PATCH] Only check losses in pkt7 req/replies from us --- controlstream.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controlstream.go b/controlstream.go index c2ae5f3..6c5f3c4 100644 --- a/controlstream.go +++ b/controlstream.go @@ -35,12 +35,12 @@ func (s *controlStream) sendPkt7(replyID []byte, seq uint16) { replyID[1] = randID[1] replyID[2] = s.randIDByteForPktSeven[0] replyID[3] = 0x03 + + s.expectedPkt7ReplySeq = s.common.sendSeq } else { replyFlag = 0x01 } - s.expectedPkt7ReplySeq = s.common.sendSeq - s.common.send([]byte{0x15, 0x00, 0x00, 0x00, 0x07, 0x00, byte(seq), byte(seq >> 8), byte(s.common.localSID >> 24), byte(s.common.localSID >> 16), byte(s.common.localSID >> 8), byte(s.common.localSID), byte(s.common.remoteSID >> 24), byte(s.common.remoteSID >> 16), byte(s.common.remoteSID >> 8), byte(s.common.remoteSID), @@ -160,15 +160,15 @@ func (s *controlStream) sendRequestSerialAndAudio() { func (s *controlStream) handleRead(r []byte) { switch len(r) { case 21: - if bytes.Equal(r[1:6], []byte{0x00, 0x00, 0x00, 0x07, 0x00}) { + if bytes.Equal(r[1:6], []byte{0x00, 0x00, 0x00, 0x07, 0x00}) { // Note that the first byte can be 0x15 or 0x00, so we ignore that. gotSeq := binary.LittleEndian.Uint16(r[6:8]) if r[16] == 0x00 { // This is a pkt7 request from the radio. // Replying to the radio. // Example request from radio: 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x1c, 0x0e, 0xe4, 0x35, 0xdd, 0x72, 0xbe, 0xd9, 0xf2, 0x63, 0x00, 0x57, 0x2b, 0x12, 0x00 // Example answer from PC: 0x15, 0x00, 0x00, 0x00, 0x07, 0x00, 0x1c, 0x0e, 0xbe, 0xd9, 0xf2, 0x63, 0xe4, 0x35, 0xdd, 0x72, 0x01, 0x57, 0x2b, 0x12, 0x00 s.sendPkt7(r[17:21], gotSeq) - } else { - if s.expectedPkt7ReplySeq != gotSeq { // TODO + } else { // This is a pkt7 reply to our request. + if s.expectedPkt7ReplySeq != gotSeq { var missingPkts int if gotSeq > s.expectedPkt7ReplySeq { missingPkts = int(gotSeq) - int(s.expectedPkt7ReplySeq)