From add63fb3748705718095fe5bcaadc6ff7cfb7a4c Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 4 Oct 2020 22:41:52 +0100 Subject: [PATCH] Adapt WSPRnet.org spotting to moveable Rx analysis window This allows spots at any frequency to be posted rather than just those in the 1400 to 1600 Hz range above the VFO dial frequency. --- Network/wsprnet.cpp | 39 ++++++++++++++++++++------------------- widgets/mainwindow.cpp | 32 +++++++++++++++++++++----------- widgets/mainwindow.h | 2 +- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/Network/wsprnet.cpp b/Network/wsprnet.cpp index 2ac173095..ba1e36c18 100644 --- a/Network/wsprnet.cpp +++ b/Network/wsprnet.cpp @@ -86,26 +86,29 @@ void WSPRNet::upload (QString const& call, QString const& grid, QString const& r m_file = fileName; // Open the wsprd.out file - QFile wsprdOutFile (fileName); - if (!wsprdOutFile.open (QIODevice::ReadOnly | QIODevice::Text) || !wsprdOutFile.size ()) + if (m_uploadType != 3) { - spot_queue_.enqueue (urlEncodeNoSpot ()); - m_uploadType = 1; - } - else - { - // Read the contents - while (!wsprdOutFile.atEnd()) + QFile wsprdOutFile (fileName); + if (!wsprdOutFile.open (QIODevice::ReadOnly | QIODevice::Text) || !wsprdOutFile.size ()) { - SpotQueue::value_type query; - if (decodeLine (wsprdOutFile.readLine(), query)) + spot_queue_.enqueue (urlEncodeNoSpot ()); + m_uploadType = 1; + } + else + { + // Read the contents + while (!wsprdOutFile.atEnd()) { - // Prevent reporting data ouside of the current frequency band - float f = fabs (m_rfreq.toFloat() - query.queryItemValue ("tqrg", QUrl::FullyDecoded).toFloat()); - if (f < 0.0002) + SpotQueue::value_type query; + if (decodeLine (wsprdOutFile.readLine(), query)) { - spot_queue_.enqueue(urlEncodeSpot (query)); - m_uploadType = 2; + // Prevent reporting data ouside of the current frequency band + float f = fabs (m_rfreq.toFloat() - query.queryItemValue ("tqrg", QUrl::FullyDecoded).toFloat()); + if (f < 0.01) // MHz + { + spot_queue_.enqueue(urlEncodeSpot (query)); + m_uploadType = 2; + } } } } @@ -133,10 +136,8 @@ void WSPRNet::post (QString const& call, QString const& grid, QString const& rfr if (!spot_queue_.size ()) { spot_queue_.enqueue (urlEncodeNoSpot ()); - m_uploadType = 1; + m_uploadType = 3; } - spots_to_send_ = spot_queue_.size (); - upload_timer_.start (200); } else { diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 7f5c0a681..16eec61b9 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -3248,7 +3248,14 @@ void MainWindow::decodeDone () if(m_mode=="QRA64") m_wideGraph->drawRed(0,0); if ("FST4W" == m_mode) { - uploadWSPRSpots (true); // DE station info and trigger posts + if (m_uploadWSPRSpots + && m_config.is_transceiver_online ()) { // need working rig control +#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0) + uploadTimer.start(QRandomGenerator::global ()->bounded (0, 20000)); // Upload delay +#else + uploadTimer.start(20000 * qrand()/((double)RAND_MAX + 1.0)); // Upload delay +#endif + } } auto tnow = QDateTime::currentDateTimeUtc (); double tdone = fmod(double(tnow.time().second()),m_TRperiod); @@ -7959,35 +7966,38 @@ void MainWindow::uploadWSPRSpots (bool direct_post, QString const& decode_text) { // do not spot if disabled, replays, or if rig control not working if(!m_uploadWSPRSpots || m_diskData || !m_config.is_transceiver_online ()) return; - if(m_uploading) { + if(m_uploading && !decode_text.size ()) { qDebug() << "Previous upload has not completed, spots were lost"; wsprNet->abortOutstandingRequests (); m_uploading = false; } - QString rfreq = QString("%1").arg((m_dialFreqRxWSPR + 1500) / 1e6, 0, 'f', 6); + QString rfreq = QString("%1").arg((m_dialFreqRxWSPR + m_wideGraph->rxFreq ()) / 1e6, 0, 'f', 6); QString tfreq = QString("%1").arg((m_dialFreqRxWSPR + ui->TxFreqSpinBox->value()) / 1e6, 0, 'f', 6); auto pct = QString::number (ui->autoButton->isChecked () ? ui->sbTxPercent->value () : 0); - if (!direct_post) + if (direct_post) { + // queues one FST4W spot + wsprNet->post (m_config.my_callsign (), m_config.my_grid (), rfreq, tfreq, + m_mode, m_TRperiod, pct, + QString::number (m_dBm), version (), decode_text); + } + else + { + // queues spots for each decode in wspr_spots.txt wsprNet->upload (m_config.my_callsign (), m_config.my_grid (), rfreq, tfreq, m_mode, m_TRperiod, pct, QString::number (m_dBm), version (), m_config.writeable_data_dir ().absoluteFilePath ("wspr_spots.txt")); } - else - { - wsprNet->post (m_config.my_callsign (), m_config.my_grid (), rfreq, tfreq, - m_mode, m_TRperiod, pct, - QString::number (m_dBm), version (), decode_text); - } + // trigger upload of any queued spots if (!decode_text.size ()) { m_uploading = true; } } -void MainWindow::uploadResponse(QString response) +void MainWindow::uploadResponse(QString const& response) { if (response == "done") { m_uploading=false; diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index 8c19c8302..3fbe6aa52 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -278,7 +278,7 @@ private slots: void WSPR_config(bool b); void uploadWSPRSpots (bool direct_post = false, QString const& decode_text = QString {}); void TxAgain(); - void uploadResponse(QString response); + void uploadResponse(QString const& response); void on_WSPRfreqSpinBox_valueChanged(int n); void on_sbFST4W_RxFreq_valueChanged(int n); void on_sbFST4W_FTol_valueChanged(int n);