From bedc6dd96c5d092261ad93b548896ca721af30d7 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Tue, 1 Jan 2019 10:12:09 -0500 Subject: [PATCH] Fixed bug with hearing command response. Added status response shortcode. --- mainwindow.cpp | 31 ++++++++++++++++++++++++++++--- mainwindow.h | 1 + varicode.cpp | 6 +++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 98e2a7c..a65fe7a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4185,6 +4185,20 @@ void MainWindow::playSoundNotification(const QString &path){ QSound::play(path); } +bool MainWindow::hasExistingMessageBufferToMe(int *pOffset){ + foreach(auto offset, m_messageBuffer.keys()){ + auto buffer = m_messageBuffer[offset]; + + // if this is a valid buffer and it's to me... + if(buffer.cmd.utcTimestamp.isValid() && (buffer.cmd.to == m_config.my_callsign() || buffer.cmd.to == Radio::base_callsign(m_config.my_callsign()))){ + if(pOffset) *pOffset = offset; + return true; + } + } + + return false; +} + bool MainWindow::hasExistingMessageBuffer(int offset, bool drift, int *pPrevOffset){ if(m_messageBuffer.contains(offset)){ if(pPrevOffset) *pPrevOffset = offset; @@ -9005,6 +9019,8 @@ void MainWindow::processRxActivity() { int freqOffset = currentFreqOffset(); + qDebug() << m_messageBuffer.count() << "message buffers open"; + while (!m_rxActivityQueue.isEmpty()) { ActivityDetail d = m_rxActivityQueue.dequeue(); @@ -9472,7 +9488,7 @@ void MainWindow::processCommandActivity() { // QUERIED ACTIVE else if (d.cmd == " STATUS?" && !isAllCall) { - reply = QString("%1 %2").arg(d.from).arg(generateStatus()); + reply = QString("%1 STATUS %2").arg(d.from).arg(generateStatus()); } // QUERIED GRID @@ -9588,7 +9604,7 @@ void MainWindow::processCommandActivity() { m_rxCallsignCommandQueue[d.from].append(d); QTimer::singleShot(500, this, [this, d](){ - MessageBox::information_message(this, QString("A new message has been received at %1 UTC").arg(d.utcTimestamp.time().toString())); + MessageBox::information_message(this, QString("A new message was received at %1 UTC").arg(d.utcTimestamp.time().toString())); }); } } @@ -9717,7 +9733,7 @@ void MainWindow::processCommandActivity() { // do not queue a reply if it's a HB and HB is not active if((!ui->hbMacroButton->isChecked() || m_hbInterval <= 0) && d.cmd.contains("HB")){ - + continue; } // do not queue for reply if there's text in the window @@ -9725,6 +9741,15 @@ void MainWindow::processCommandActivity() { continue; } + // do not queue for reply if there's a buffer open to us + int bufferOffset = 0; + if(hasExistingMessageBufferToMe(&bufferOffset)){ + + qDebug() << "skipping reply due to open buffer" << bufferOffset << m_messageBuffer.count(); + + continue; + } + // add @ALLCALLs to the @ALLCALL cache if(isAllCall){ m_txAllcallCommandCache.insert(d.from, new QDateTime(now), 25); diff --git a/mainwindow.h b/mainwindow.h index 5ba7fae..023e61a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -132,6 +132,7 @@ public slots: void fastPick(int x0, int x1, int y); void playSoundNotification(const QString &path); + bool hasExistingMessageBufferToMe(int *pOffset); bool hasExistingMessageBuffer(int offset, bool drift, int *pPrevOffset); void logCallActivity(CallDetail d, bool spot=true); QString lookupCallInCompoundCache(QString const &call); diff --git a/varicode.cpp b/varicode.cpp index 44a323f..4602c25 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -61,7 +61,7 @@ QMap directed_cmds = { {" STATUS?", 6 }, // query idle message - //{"!", 7 }, // unused + {" STATUS", 7 }, // this is my status {" HEARING", 8 }, // these are the stations i'm hearing @@ -98,7 +98,7 @@ QMap directed_cmds = { {" ", 31 }, // send freetext }; -QSet allowed_cmds = {-1, 0, 1, 2, 3, 4, 5, 6, /*7,*/ /*8,*/ 9, /*10,*/ /*11,*/ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /*24,*/ 25, 26, 27, 28, 29, 30, 31}; +QSet allowed_cmds = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /*10,*/ /*11,*/ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, /*24,*/ 25, 26, 27, 28, 29, 30, 31}; QSet buffered_cmds = {3, 5, /*6,*/ /*7,*/ 12, 13, 14, 15}; @@ -113,7 +113,7 @@ QMap checksum_cmds = { }; QString callsign_pattern = QString("(?[@]?[A-Z0-9/]+)"); -QString optional_cmd_pattern = QString("(?\\s?(?:AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|SNR[?]|QTC[?]|QTH[?]|GRID[?]|STATUS[?]|HEARING[?]|(?:(?:HEARING|QUERY CALL|QUERY|ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|TU)(?=[ ]|$))|[?> ]))?"); +QString optional_cmd_pattern = QString("(?\\s?(?:AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|SNR[?]|QTC[?]|QTH[?]|GRID[?]|STATUS[?]|HEARING[?]|(?:(?:STATUS|HEARING|QUERY CALL|QUERY|ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|TU)(?=[ ]|$))|[?> ]))?"); QString optional_grid_pattern = QString("(?\\s?[A-R]{2}[0-9]{2})?"); QString optional_extended_grid_pattern = QString("^(?\\s?(?:[A-R]{2}[0-9]{2}(?:[A-X]{2}(?:[0-9]{2})?)*))?"); QString optional_num_pattern = QString("(?(?<=SNR|ACK)\\s?[-+]?(?:3[01]|[0-2]?[0-9]))?");