From 33446297fa3dc90213bd071cbcf16e80f2044c4c Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 31 Oct 2018 10:50:51 -0400 Subject: [PATCH] Update heartbeat to allow on demand only. Add AUTO requirement for ACKs --- Configuration.ui | 13 ++++++++----- mainwindow.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Configuration.ui b/Configuration.ui index 7647139..13d8184 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -633,23 +633,26 @@ text message. <html><head/><body><p>Number of minutes between unattended heartbeat transmissions.</p></body></html> + + Disabled + minutes - + every - 5 + 0 1440 - 1 + 5 - 15 + 30 @@ -676,7 +679,7 @@ text message. minutes - + after 1 diff --git a/mainwindow.cpp b/mainwindow.cpp index 6e3107e..419a842 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4381,7 +4381,22 @@ void MainWindow::guiUpdate() ui->labUTC->setText(utc); auto delta = t.secsTo(m_nextHeartbeat); - auto ping = ui->heartbeatButton->isChecked() ? delta > 0 ? QString("%1 s").arg(delta) : "queued!" : m_nextHeartPaused ? "paused" : "disabled"; + QString ping; + if(ui->heartbeatButton->isChecked()){ + if(heartbeatTimer.isActive()){ + if(delta > 0){ + ping = QString("%1 s").arg(delta); + } else { + ping = "queued!"; + } + } else { + ping = "on demand"; + } + } else if (m_nextHeartPaused) { + ping = "paused"; + } else { + ping = "disabled"; + } ui->labHeartbeat->setText(QString("Next Heartbeat: %1").arg(ping)); auto callLabel = m_config.my_callsign(); @@ -5498,6 +5513,12 @@ void MainWindow::scheduleHeartbeat(bool first){ auto timestamp = DriftingDateTime::currentDateTimeUtc(); auto orig = timestamp; + // if we have the heartbeat interval disabled, return early, unless this is a "heartbeat now" + if(!m_config.heartbeat() && !first){ + heartbeatTimer.stop(); + return; + } + // remove milliseconds auto t = timestamp.time(); t.setHMS(t.hour(), t.minute(), t.second()); @@ -8838,7 +8859,7 @@ void MainWindow::processCommandActivity() { } // PROCESS HEARTBEAT - else if (d.cmd == " HEARTBEAT" && ui->heartbeatButton->isChecked()){ + else if (d.cmd == " HEARTBEAT" && ui->heartbeatButton->isChecked() && ui->autoReplyButton->isChecked()){ reply = QString("%1 HEARTBEAT ACK %2").arg(d.from).arg(Varicode::formatSNR(d.snr)); enqueueHeartbeat(reply);