From 7da30200f55d8d9f577eb538b8fd34a775613282 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Sun, 28 Oct 2018 10:06:03 -0400 Subject: [PATCH] Heartbeat commands instead --- Configuration.cpp | 24 ++++++++++++------------ Configuration.hpp | 4 ++-- Configuration.ui | 6 +++--- decodedtext.cpp | 2 +- mainwindow.cpp | 46 +++++++++++++++++++++++----------------------- varicode.cpp | 16 ++++++++-------- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index 42a0b66..419d082 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -628,7 +628,7 @@ private: bool spot_to_reporting_networks_; bool transmit_directed_; bool autoreply_off_at_startup_; - bool ping_anywhere_; + bool heartbeat_anywhere_; bool relay_disabled_; bool monitor_off_at_startup_; bool monitor_last_used_; @@ -642,7 +642,7 @@ private: bool miles_; bool quick_call_; bool disable_TX_on_73_; - int ping_; + int heartbeat_; int watchdog_; bool TX_messages_; bool enable_VHF_features_; @@ -759,7 +759,7 @@ void Configuration::set_spot_to_reporting_networks (bool spot) bool Configuration::transmit_directed() const { return m_->transmit_directed_; } bool Configuration::autoreply_off_at_startup () const {return m_->autoreply_off_at_startup_;} -bool Configuration::ping_anywhere() const { return m_->ping_anywhere_;} +bool Configuration::heartbeat_anywhere() const { return m_->heartbeat_anywhere_;} bool Configuration::relay_off() const { return m_->relay_disabled_; } bool Configuration::monitor_off_at_startup () const {return m_->monitor_off_at_startup_;} bool Configuration::monitor_last_used () const {return m_->rig_is_dummy_ || m_->monitor_last_used_;} @@ -773,7 +773,7 @@ bool Configuration::clear_DX () const {return m_->clear_DX_;} bool Configuration::miles () const {return m_->miles_;} bool Configuration::quick_call () const {return m_->quick_call_;} bool Configuration::disable_TX_on_73 () const {return m_->disable_TX_on_73_;} -int Configuration::ping () const {return m_->ping_;} +int Configuration::heartbeat () const {return m_->heartbeat_;} int Configuration::watchdog () const {return m_->watchdog_;} bool Configuration::TX_messages () const {return m_->TX_messages_;} bool Configuration::enable_VHF_features () const {return m_->enable_VHF_features_;} @@ -1338,7 +1338,7 @@ void Configuration::impl::initialize_models () ui_->psk_reporter_check_box->setChecked (spot_to_reporting_networks_); ui_->transmit_directed_check_box->setChecked(transmit_directed_); ui_->autoreply_off_check_box->setChecked (autoreply_off_at_startup_); - ui_->ping_anywhere_check_box->setChecked(ping_anywhere_); + ui_->heartbeat_anywhere_check_box->setChecked(heartbeat_anywhere_); ui_->relay_disabled_check_box->setChecked(relay_disabled_); ui_->monitor_off_check_box->setChecked (monitor_off_at_startup_); ui_->monitor_last_used_check_box->setChecked (monitor_last_used_); @@ -1350,7 +1350,7 @@ void Configuration::impl::initialize_models () ui_->miles_check_box->setChecked (miles_); ui_->quick_call_check_box->setChecked (quick_call_); ui_->disable_TX_on_73_check_box->setChecked (disable_TX_on_73_); - ui_->ping_spin_box->setValue (ping_); + ui_->heartbeat_spin_box->setValue (heartbeat_); ui_->tx_watchdog_spin_box->setValue (watchdog_); ui_->enable_VHF_features_check_box->setChecked(enable_VHF_features_); ui_->decode_at_52s_check_box->setChecked(decode_at_52s_); @@ -1596,7 +1596,7 @@ void Configuration::impl::read_settings () transmit_directed_ = settings_->value ("TransmitDirected", true).toBool(); autoreply_off_at_startup_ = settings_->value ("AutoreplyOFF", false).toBool (); - ping_anywhere_ = settings_->value("BeaconAnywhere", false).toBool(); + heartbeat_anywhere_ = settings_->value("BeaconAnywhere", false).toBool(); relay_disabled_ = settings_->value ("RelayOFF", false).toBool (); monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool (); monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool (); @@ -1657,7 +1657,7 @@ void Configuration::impl::read_settings () miles_ = settings_->value ("Miles", false).toBool (); quick_call_ = settings_->value ("QuickCall", false).toBool (); disable_TX_on_73_ = settings_->value ("73TxDisable", false).toBool (); - ping_ = settings_->value ("TxBeacon", 30).toInt (); + heartbeat_ = settings_->value ("TxBeacon", 30).toInt (); watchdog_ = settings_->value ("TxIdleWatchdog", 60).toInt (); if(watchdog_){ watchdog_ = qMax(5, watchdog_); @@ -1762,7 +1762,7 @@ void Configuration::impl::write_settings () settings_->setValue ("Type2MsgGen", QVariant::fromValue (type_2_msg_gen_)); settings_->setValue ("TransmitDirected", transmit_directed_); settings_->setValue ("AutoreplyOFF", autoreply_off_at_startup_); - settings_->setValue ("BeaconAnywhere", ping_anywhere_); + settings_->setValue ("BeaconAnywhere", heartbeat_anywhere_); settings_->setValue ("RelayOFF", relay_disabled_); settings_->setValue ("MonitorOFF", monitor_off_at_startup_); settings_->setValue ("MonitorLastUsed", monitor_last_used_); @@ -1791,7 +1791,7 @@ void Configuration::impl::write_settings () settings_->setValue ("Miles", miles_); settings_->setValue ("QuickCall", quick_call_); settings_->setValue ("73TxDisable", disable_TX_on_73_); - settings_->setValue ("TxBeacon", ping_); + settings_->setValue ("TxBeacon", heartbeat_); settings_->setValue ("TxIdleWatchdog", watchdog_); settings_->setValue ("Tx2QSO", TX_messages_); settings_->setValue ("CATForceDTR", rig_params_.force_dtr); @@ -2260,7 +2260,7 @@ void Configuration::impl::accept () tx_qsy_allowed_ = ui_->tx_qsy_check_box->isChecked (); transmit_directed_ = ui_->transmit_directed_check_box->isChecked(); autoreply_off_at_startup_ = ui_->autoreply_off_check_box->isChecked (); - ping_anywhere_ = ui_->ping_anywhere_check_box->isChecked(); + heartbeat_anywhere_ = ui_->heartbeat_anywhere_check_box->isChecked(); relay_disabled_ = ui_->relay_disabled_check_box->isChecked(); monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked (); monitor_last_used_ = ui_->monitor_last_used_check_box->isChecked (); @@ -2272,7 +2272,7 @@ void Configuration::impl::accept () miles_ = ui_->miles_check_box->isChecked (); quick_call_ = ui_->quick_call_check_box->isChecked (); disable_TX_on_73_ = ui_->disable_TX_on_73_check_box->isChecked (); - ping_ = ui_->ping_spin_box->value (); + heartbeat_ = ui_->heartbeat_spin_box->value (); watchdog_ = ui_->tx_watchdog_spin_box->value (); data_mode_ = static_cast (ui_->TX_mode_button_group->checkedId ()); save_directory_ = ui_->save_path_display_label->text (); diff --git a/Configuration.hpp b/Configuration.hpp index 9140e4c..59eb24a 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -121,7 +121,7 @@ public: void set_spot_to_reporting_networks (bool); bool transmit_directed() const; bool autoreply_off_at_startup () const; - bool ping_anywhere() const; + bool heartbeat_anywhere() const; bool relay_off() const; bool monitor_off_at_startup () const; bool monitor_last_used () const; @@ -135,7 +135,7 @@ public: bool miles () const; bool quick_call () const; bool disable_TX_on_73 () const; - int ping () const; + int heartbeat () const; int watchdog () const; bool TX_messages () const; bool split_mode () const; diff --git a/Configuration.ui b/Configuration.ui index 2c0a022..440b2b1 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -613,9 +613,9 @@ text message. - + - Allow transmitting heartbeat pings outside of heartbeat sub-channel (500Hz - 1000Hz) + Allow heartbeat transmissions outside of heartbeat sub-channel (500Hz - 1000Hz) @@ -629,7 +629,7 @@ text message. - + <html><head/><body><p>Number of minutes between unattended pings</p></body></html> diff --git a/decodedtext.cpp b/decodedtext.cpp index a2c02aa..3441415 100644 --- a/decodedtext.cpp +++ b/decodedtext.cpp @@ -131,7 +131,7 @@ bool DecodedText::tryUnpackHeartbeat(){ cmp.append(parts.at(1)); } compound_ = cmp.join("/"); - message_ = QString("%1: %2 %3 ").arg(compound_).arg(isAlt ? Varicode::cqString(bits3) : "PING").arg(extra_); + message_ = QString("%1: %2 %3 ").arg(compound_).arg(isAlt ? Varicode::cqString(bits3) : "HEARTBEAT").arg(extra_); frameType_ = type; return true; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 2d27359..fb4afe1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1372,7 +1372,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight)); ui->tableWidgetCalls->setPalette(p); - // Don't block ping's first run... + // Don't block heartbeat's first run... m_lastTxTime = DriftingDateTime::currentDateTimeUtc().addSecs(-300); @@ -3644,7 +3644,7 @@ void MainWindow::readFromStdout() //readFromStdout cd.utcTimestamp = DriftingDateTime::currentDateTimeUtc(); cd.bits = decodedtext.bits(); - // Only respond to PINGS...remember that CQ messages are "Alt" pings + // Only respond to HEARTBEATS...remember that CQ messages are "Alt" pings if(decodedtext.isHeartbeat()){ if(decodedtext.isAlt()){ @@ -3653,10 +3653,10 @@ void MainWindow::readFromStdout() //readFromStdout logCallActivity(cd, true); } else { - // convert PING to a directed command and process... + // convert HEARTBEAT to a directed command and process... cmd.from = cd.call; cmd.to = "@ALLCALL"; - cmd.cmd = " PING"; + cmd.cmd = " HEARTBEAT"; cmd.snr = cd.snr; cmd.bits = cd.bits; cmd.grid = cd.grid; @@ -5480,7 +5480,7 @@ void MainWindow::scheduleHeartbeat(bool first){ // round to 15 second increment int secondsSinceEpoch = (timestamp.toMSecsSinceEpoch()/1000); - int delta = roundUp(secondsSinceEpoch, 15) + 1 + (first ? 0 : qMax(1, m_config.ping()) * 60) - secondsSinceEpoch; + int delta = roundUp(secondsSinceEpoch, 15) + 1 + (first ? 0 : qMax(1, m_config.heartbeat()) * 60) - secondsSinceEpoch; timestamp = timestamp.addSecs(delta); // 25% of the time, switch intervals @@ -5537,7 +5537,7 @@ void MainWindow::prepareHeartbeat(){ // JS8Call Style if(m_txHeartbeatQueue.isEmpty()){ - lines.append(QString("%1: PING %2").arg(mycall).arg(mygrid)); + lines.append(QString("%1: HEARTBEAT %2").arg(mycall).arg(mygrid)); } else { while(!m_txHeartbeatQueue.isEmpty() && lines.length() < 1){ lines.append(m_txHeartbeatQueue.dequeue()); @@ -5545,7 +5545,7 @@ void MainWindow::prepareHeartbeat(){ } // Choose a ping frequency - auto f = m_config.ping_anywhere() ? -1 : findFreeFreqOffset(500, 1000, 50); + auto f = m_config.heartbeat_anywhere() ? -1 : findFreeFreqOffset(500, 1000, 50); auto text = lines.join(QChar('\n')); if(text.isEmpty()){ @@ -6538,7 +6538,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ addMessageText(QString("%1>[MESSAGE]").arg(selectedCall), true, true); }); - auto qsoQueryAction = menu->addAction(QString("%1 PING REQ [CALLSIGN]? - Please acknowledge you can communicate directly with [CALLSIGN]").arg(call).trimmed()); + auto qsoQueryAction = menu->addAction(QString("%1 HEARTBEAT REQ [CALLSIGN]? - Please acknowledge you can communicate directly with [CALLSIGN]").arg(call).trimmed()); connect(qsoQueryAction, &QAction::triggered, this, [this](){ QString selectedCall = callsignSelected(); @@ -6546,7 +6546,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){ return; } - addMessageText(QString("%1 PING REQ [CALLSIGN]?").arg(selectedCall), true, true); + addMessageText(QString("%1 HEARTBEAT REQ [CALLSIGN]?").arg(selectedCall), true, true); }); menu->addSeparator(); @@ -8212,7 +8212,7 @@ void MainWindow::processRxActivity() { continue; } - if(d.isDirected && d.text.contains(": PING")){ + if(d.isDirected && d.text.contains(": HEARTBEAT")){ continue; } @@ -8494,7 +8494,7 @@ void MainWindow::processCommandActivity() { cd.snr = d.snr; cd.freq = d.freq; cd.bits = d.bits; - cd.ackTimestamp = d.text.contains("PING ACK") || toMe ? d.utcTimestamp : QDateTime{}; + cd.ackTimestamp = d.text.contains("HEARTBEAT ACK") || toMe ? d.utcTimestamp : QDateTime{}; cd.utcTimestamp = d.utcTimestamp; logCallActivity(cd, true); @@ -8535,7 +8535,7 @@ void MainWindow::processCommandActivity() { bool shouldDisplay = true; // don't display ping allcalls - if(isAllCall && (ad.text.contains(": PING") || d.cmd == " PING")){ + if(isAllCall && (ad.text.contains(": HEARTBEAT") || d.cmd == " HEARTBEAT")){ shouldDisplay = false; } @@ -8546,7 +8546,7 @@ void MainWindow::processCommandActivity() { // ACKs are the most likely source of items to be overwritten (multiple responses at once)... // so don't overwrite those (i.e., print each on a new line) - bool shouldOverwrite = (!d.cmd.contains("PING ACK")); /* && isRecentOffset(d.freq);*/ + bool shouldOverwrite = (!d.cmd.contains("HEARTBEAT ACK")); /* && isRecentOffset(d.freq);*/ if(shouldOverwrite && ui->textEditRX->find(d.utcTimestamp.time().toString(), QTextDocument::FindBackward)){ // ... maybe we could delete the last line that had this message on this frequency... @@ -8588,7 +8588,7 @@ void MainWindow::processCommandActivity() { // if this is an allcall, check to make sure we haven't replied to their allcall recently (in the past ping interval) // that way we never get spammed by allcalls at a higher frequency than what we would normally ping - if (isAllCall && m_txAllcallCommandCache.contains(d.from) && m_txAllcallCommandCache[d.from]->secsTo(now) / 60 < m_config.ping()) { + if (isAllCall && m_txAllcallCommandCache.contains(d.from) && m_txAllcallCommandCache[d.from]->secsTo(now) / 60 < m_config.heartbeat()) { continue; } @@ -8748,9 +8748,9 @@ void MainWindow::processCommandActivity() { reply = m_lastTxMessage; } - // PROCESS PING - else if (d.cmd == " PING" && ui->heartbeatButton->isChecked()){ - reply = QString("%1 PING ACK %2").arg(d.from).arg(Varicode::formatSNR(d.snr)); + // PROCESS HEARTBEAT + else if (d.cmd == " HEARTBEAT" && ui->heartbeatButton->isChecked()){ + reply = QString("%1 HEARTBEAT ACK %2").arg(d.from).arg(Varicode::formatSNR(d.snr)); enqueueHeartbeat(reply); @@ -8762,8 +8762,8 @@ void MainWindow::processCommandActivity() { continue; } - // PROCESS BUFFERED PING REQ QUERY - else if (d.cmd == " PING REQ" && ui->heartbeatButton->isChecked()){ + // PROCESS BUFFERED HEARTBEAT REQ QUERY + else if (d.cmd == " HEARTBEAT REQ" && ui->heartbeatButton->isChecked()){ auto who = d.text; if(who.isEmpty()){ continue; @@ -8850,7 +8850,7 @@ void MainWindow::processCommandActivity() { } // do not queue @ALLCALL replies if auto-reply is not checked or it's a ping reply - if(!ui->autoReplyButton->isChecked() && isAllCall && !d.cmd.contains("PING")){ + if(!ui->autoReplyButton->isChecked() && isAllCall && !d.cmd.contains("HEARTBEAT")){ continue; } @@ -9029,7 +9029,7 @@ void MainWindow::processTxQueue(){ // check to see if this is a high priority message, or if we have autoreply enabled, or if this is a ping and the ping button is enabled if(message.priority >= PriorityHigh || (ui->autoReplyButton->isChecked()) || - (ui->heartbeatButton->isChecked() && message.message.contains("PING")) + (ui->heartbeatButton->isChecked() && message.message.contains("HEARTBEAT")) ){ // then try to set the frequency... setFreqOffsetForRestore(f, true); @@ -9161,7 +9161,7 @@ void MainWindow::displayBandActivity() { if (!isOffsetSelected && activityAging && item.utcTimestamp.secsTo(now) / 60 >= activityAging) { continue; } - if (!pingEnabled && (item.text.contains(": PING") || item.text.contains("PING ACK"))){ + if (!pingEnabled && (item.text.contains(": HEARTBEAT") || item.text.contains("HEARTBEAT ACK"))){ // hide pings if we're not pinging. continue; } @@ -9480,7 +9480,7 @@ void MainWindow::networkMessage(Message const &message) auto type = message.type(); - if(type == "PING"){ + if(type == "HEARTBEAT"){ return; } diff --git a/varicode.cpp b/varicode.cpp index c55b207..71fbf52 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -59,9 +59,9 @@ QMap directed_cmds = { {" ACTIVE", 10 }, // i have been active in the past 10 minutes {" IDLE", 11 }, // i have not been active in the past 10 minutes - {" PING", -1 }, // this is my ping (unused except for faux processing of pings as directed commands) - {" PING ACK", 12 }, // i acknowledge your ping at this SNR - {" PING REQ", 13 }, // can you transmit a ping to callsign? + {" HEARTBEAT", -1 }, // this is my ping (unused except for faux processing of pings as directed commands) + {" HEARTBEAT ACK", 12 }, // i acknowledge your ping at this SNR + {" HEARTBEAT REQ", 13 }, // can you transmit a ping to callsign? {" APRS:", 14 }, // send an aprs packet @@ -100,7 +100,7 @@ QMap checksum_cmds = { }; QString callsign_pattern = QString("(?[@]?[A-Z0-9/]+)"); -QString optional_cmd_pattern = QString("(?\\s?(?:PING (ACK|REQ)|AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|QRZ[?]|(?:(?:ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|ACTIVE|IDLE)(?=[ ]|$))|[?@&$%#^>* ]))?"); +QString optional_cmd_pattern = QString("(?\\s?(?:HEARTBEAT (ACK|REQ)|AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|QRZ[?]|(?:(?:ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|ACTIVE|IDLE)(?=[ ]|$))|[?@&$%#^>* ]))?"); 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]))?"); @@ -110,7 +110,7 @@ QRegularExpression directed_re("^" + optional_cmd_pattern + optional_num_pattern); -QRegularExpression heartbeat_re(R"(^\s*(?CQCQCQ|CQ QRPP?|CQ DX|CQ TEST|CQ( CQ){0,2}|PING)(?:\s(?[A-R]{2}[0-9]{2}))?\b)"); +QRegularExpression heartbeat_re(R"(^\s*(?CQCQCQ|CQ QRPP?|CQ DX|CQ TEST|CQ( CQ){0,2}|HEARTBEAT)(?:\s(?[A-R]{2}[0-9]{2}))?\b)"); QRegularExpression compound_re("^\\s*[`]" + callsign_pattern + @@ -1107,7 +1107,7 @@ bool Varicode::isCompoundCallsign(const QString &callsign){ // CQCQCQ EM73 // CQ DX EM73 // CQ QRP EM73 -// PING EM73 +// HEARTBEAT EM73 QString Varicode::packHeartbeatMessage(QString const &text, const QString &callsign, int *n){ QString frame; @@ -1121,7 +1121,7 @@ QString Varicode::packHeartbeatMessage(QString const &text, const QString &calls // Heartbeat Alt Type // --------------- - // 1 0 PING + // 1 0 HEARTBEAT // 1 1 CQCQCQ auto type = parsedText.captured("type"); @@ -1649,7 +1649,7 @@ QStringList Varicode::buildMessageFrames( if(!selectedCall.isEmpty() && !line.startsWith(selectedCall) && !line.startsWith("`")){ bool lineStartsWithBaseCall = ( line.startsWith("@ALLCALL") || - line.startsWith("PING") || + line.startsWith("HEARTBEAT") || Varicode::startsWithCQ(line) );