diff --git a/QnetModem.cpp b/QnetModem.cpp index 1080e0a..b91f23b 100644 --- a/QnetModem.cpp +++ b/QnetModem.cpp @@ -80,6 +80,11 @@ CQnetModem::~CQnetModem() { } +bool CQnetModem::VoicePacketIsSync(const unsigned char *text) +{ + return *text==0x55U && *(text+1)==0x2DU && *(text+2)==0x16U; +} + bool CQnetModem::GetBufferSize() { std::this_thread::sleep_for(std::chrono::seconds(2)); @@ -576,15 +581,18 @@ int CQnetModem::SendToModem(const unsigned char *buf) bool CQnetModem::ProcessGateway(const int len, const unsigned char *raw) { - static unsigned int sfcount = 0U; if (29==len || 58==len) { //here is dstar data SDSTR dstr; memcpy(dstr.pkt_id, raw, len); // transfer raw data to SDSTR struct - + if (LOG_DEBUG) { + if (58 == len) + printf("From Gateway id=%04X header='%.36s'\n", ntohs(dstr.vpkt.streamid), dstr.vpkt.hdr.flag+3); + else + printf("from Gateway id=%04X ctrl=%02X text=%02X:%02X:%02X\n", ntohs(dstr.vpkt.streamid), dstr.vpkt.ctrl, dstr.vpkt.vasd.text[0], dstr.vpkt.vasd.text[1], dstr.vpkt.vasd.text[2]); + } SMODEM frame; // destination frame.start = FRAME_START; if (58 == len) { // write a Header packet - sfcount = 20U; frame.length = 44U; frame.type = TYPE_HEADER; memcpy(frame.header.flag, dstr.vpkt.hdr.flag, 3); @@ -597,19 +605,11 @@ bool CQnetModem::ProcessGateway(const int len, const unsigned char *raw) queue.push(CFrame(&frame.start)); PacketWait.start(); g2_is_active = true; - if (LOG_QSO) + if (LOG_QSO && ! LOG_DEBUG) printf("Queued to %s flags=%02x:%02x:%02x ur=%.8s r1=%.8s r2=%.8s my=%.8s/%.4s\n", MODEM_DEVICE.c_str(), frame.header.flag[0], frame.header.flag[1], frame.header.flag[2], frame.header.ur, frame.header.r1, frame.header.r2, frame.header.my, frame.header.nm); } else { // write a voice data packet if (g2_is_active) { //const unsigned char sdsync[3] = { 0x55U, 0x2DU, 0x16U }; - if (0U == (0x3FU & dstr.vpkt.ctrl)) { - if (sfcount != 20U) - printf("Warning: Superframe count is %u\n", sfcount); - sfcount = 0U; - if (0x55U!=dstr.vpkt.vasd.text[0] || 0x2DU!=dstr.vpkt.vasd.text[1] || 0x16U!=dstr.vpkt.vasd.text[2]) - printf("Warning: Voice sync frame (ctrl=0x%02xU) contained text %02x:%02x:%02x!\n", dstr.vpkt.ctrl, dstr.vpkt.vasd.text[0], dstr.vpkt.vasd.text[1], dstr.vpkt.vasd.text[2]); - } else - sfcount++; if (dstr.vpkt.ctrl & 0x40U) { frame.length = 3U; frame.type = TYPE_EOT; @@ -617,8 +617,6 @@ bool CQnetModem::ProcessGateway(const int len, const unsigned char *raw) if (LOG_QSO) printf("Queued modem end of transmission\n"); } else { - if (sfcount != (dstr.vpkt.ctrl & 0x3FU)) - printf("Warning: frame ctrl should be %u, but it's %u!\n", sfcount, (dstr.vpkt.ctrl & 0x3FU)); frame.length = 15U; frame.type = TYPE_DATA; memcpy(frame.voice.ambe, dstr.vpkt.vasd.voice, 12); @@ -627,16 +625,42 @@ bool CQnetModem::ProcessGateway(const int len, const unsigned char *raw) PacketWait.start(); } } - } else - printf("DEBUG: ProcessGateway: unusual packet size read len=%d\n", len); + } else { + if (LOG_DEBUG) + printf("From gateway: unusual packet size len=%d\n", len); + } return false; } bool CQnetModem::ProcessModem(const SMODEM &frame) { + static bool in_stream = false; + static bool first_voice_packet = false; static short stream_id = 0U; static unsigned char ctrl = 0U; + if (LOG_DEBUG) { + switch (frame.type) { + case TYPE_HEADER: + printf("Header from modem: %.36s\n", frame.header.flag+3); + break; + case TYPE_DATA: + printf("Data from modem: text is %02X:%02X:%02X\n", frame.voice.text[0], frame.voice.text[1], frame.voice.text[2]); + break; + case TYPE_EOT: + printf("EOT From modem\n"); + break; + case TYPE_LOST: + printf("Lost Transmission from modem\n"); + break; + default: + printf("Other packet from modem: %02X", frame.start); + for (unsigned int i=0; i> $outFile [ -z "${link_max_dongles+x}" ] || echo "link_max_dongles=${link_max_dongles}" >> $outFile # log_ section - [ -z "${log_qso+x}" ] || echo "log_qso=${log_qso}" >> $outFile - [ -z "${log_irc+x}" ] || echo "log_irc=${log_irc}" >> $outFile - [ -z "${log_dtmf+x}" ] || echo "log_dtmf=${log_dtmf}" >> $outFile + [ -z "${log_qso+x}" ] || echo "log_qso=${log_qso}" >> $outFile + [ -z "${log_irc+x}" ] || echo "log_irc=${log_irc}" >> $outFile + [ -z "${log_dtmf+x}" ] || echo "log_dtmf=${log_dtmf}" >> $outFile + [ -z "${log_debug+x}" ] || echo "log_debug=${log_debug}" >> $outFile # dplus_ section [ -z "${dplus_authorize+x}" ] || echo "dplus_authorize=${dplus_authorize}" >> $outFile [ -z "${dplus_priority+x}" ] || echo "dplus_priority=${dplus_priority}" >> $outFile