From ce0ef359c4e2e390edfe2d87dec520e9cdd6a2ef Mon Sep 17 00:00:00 2001 From: Tom Early Date: Tue, 28 Dec 2021 00:46:31 -0700 Subject: [PATCH] M17 debugging --- reflector/M17Protocol.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/reflector/M17Protocol.cpp b/reflector/M17Protocol.cpp index a7cd617..ad55780 100644 --- a/reflector/M17Protocol.cpp +++ b/reflector/M17Protocol.cpp @@ -240,7 +240,8 @@ void CM17Protocol::HandleQueue(void) { // encode it SM17Frame frame; - + auto dvFrame = (CDvFramePacket *)packet.get(); +std::cout << "m_StreamsCache[" << module << "].m_iSeqCounter=" << m_StreamsCache[module].m_iSeqCounter << " packet.sequence=" << dvFrame->GetCodecPacket()->sequence << std::endl; EncodeM17Packet(frame, m_StreamsCache[module].m_dvHeader, (CDvFramePacket &)*packet.get(), m_StreamsCache[module].m_iSeqCounter++); // push it to all our clients linked to the module and who are not streaming in @@ -391,22 +392,22 @@ void CM17Protocol::EncodeM17Packet(SM17Frame &frame, const CDvHeaderPacket &Head // do the lich structure first - // first, the src callsign (the dest will be set HandleQueue) + // first, the src callsign (the lich.dest will be set in HandleQueue) CCallsign from = g_Reflector.GetCallsign(); from.SetCSModule(Header.GetPacketModule()); from.CodeOut(frame.lich.addr_src); - // then the frame type, if the incoming frame is NOT an M17 1600, then it will be Voice only + // then the frame type, if the incoming frame is M17 1600, then it will be Voice+Data only, otherwise Voice-Only frame.lich.frametype = htons((ECodecType::c2_1600==codec_in) ? 0x7U : 0x5U); memcpy(frame.lich.nonce, DvFrame.GetNonce(), 14); // now the main part of the packet memcpy(frame.magic, "M17 ", 4); // the frame number comes from the stream sequence counter - uint16_t fn = iSeq % 0x8000U; + uint16_t fn = (iSeq / 2) % 0x8000U; if (DvFrame.IsLastPacket()) fn |= 0x8000U; frame.framenumber = htons(fn); - memcpy(frame.payload, DvFrame.GetCodecData(codec_in), 16); + memcpy(frame.payload, DvFrame.GetCodecData(ECodecType::c2_3200), 16); frame.streamid = Header.GetStreamId(); // no host<--->network byte swapping since we never do any math on this value // the CRC will be set in HandleQueue, after lich.dest is set }