diff options
| author | Christoph Berg <myon@debian.org> | 2020-11-16 21:54:50 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-11-16 21:54:50 +0100 |
| commit | 77922fa33547ce24535f2e514c9a112dcb496f18 (patch) | |
| tree | 9f82b0ee01281b315f43a4c60d678927b4c6ca59 /Network/wsprnet.cpp | |
| parent | 7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (diff) | |
New upstream version 2.3.0~rc2+repackupstream/2.3.0_rc2+repack
Diffstat (limited to 'Network/wsprnet.cpp')
| -rw-r--r-- | Network/wsprnet.cpp | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/Network/wsprnet.cpp b/Network/wsprnet.cpp index 669ab155..e01be1b5 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 { @@ -144,9 +145,11 @@ void WSPRNet::post (QString const& call, QString const& grid, QString const& rfr if (match.hasMatch ()) { SpotQueue::value_type query; - // Prevent reporting data ouside of the current frequency band + // Prevent reporting data ouside of the current frequency + // band - removed by G4WJS to accommodate FST4W spots + // outside of WSPR segments auto tqrg = match.captured ("freq").toInt (); - if (tqrg >= 1400 && tqrg <= 1600) + // if (tqrg >= 1400 && tqrg <= 1600) { query.addQueryItem ("function", "wspr"); // use time as at 3/4 of T/R period before current to @@ -208,7 +211,7 @@ void WSPRNet::networkReply (QNetworkReply * reply) } } -bool WSPRNet::decodeLine (QString const& line, SpotQueue::value_type& query) +bool WSPRNet::decodeLine (QString const& line, SpotQueue::value_type& query) const { auto const& rx_match = wspr_re.match (line); if (rx_match.hasMatch ()) { @@ -268,7 +271,23 @@ bool WSPRNet::decodeLine (QString const& line, SpotQueue::value_type& query) return true; } -auto WSPRNet::urlEncodeNoSpot () -> SpotQueue::value_type +QString WSPRNet::encode_mode () const +{ + if (m_mode == "WSPR") return "2"; + if (m_mode == "WSPR-15") return "15"; + if (m_mode == "FST4W") + { + auto tr = static_cast<int> ((TR_period_ / 60.)+.5); + if (2 == tr || 15 == tr) + { + tr += 1; // distinguish from WSPR-2 and WSPR-15 + } + return QString::number (tr); + } + return ""; +} + +auto WSPRNet::urlEncodeNoSpot () const -> SpotQueue::value_type { SpotQueue::value_type query; query.addQueryItem ("function", "wsprstat"); @@ -279,28 +298,18 @@ auto WSPRNet::urlEncodeNoSpot () -> SpotQueue::value_type query.addQueryItem ("tqrg", m_tfreq); query.addQueryItem ("dbm", m_dbm); query.addQueryItem ("version", m_vers); - if (m_mode == "WSPR") query.addQueryItem ("mode", "2"); - if (m_mode == "WSPR-15") query.addQueryItem ("mode", "15"); - if (m_mode == "FST4W") - { - query.addQueryItem ("mode", QString::number (static_cast<int> ((TR_period_ / 60.)+.5))); - } + query.addQueryItem ("mode", encode_mode ()); return query;; } -auto WSPRNet::urlEncodeSpot (SpotQueue::value_type& query) -> SpotQueue::value_type +auto WSPRNet::urlEncodeSpot (SpotQueue::value_type& query) const -> SpotQueue::value_type { query.addQueryItem ("version", m_vers); query.addQueryItem ("rcall", m_call); query.addQueryItem ("rgrid", m_grid); query.addQueryItem ("rqrg", m_rfreq); - if (m_mode == "WSPR") query.addQueryItem ("mode", "2"); - if (m_mode == "WSPR-15") query.addQueryItem ("mode", "15"); - if (m_mode == "FST4W") - { - query.addQueryItem ("mode", QString::number (static_cast<int> ((TR_period_ / 60.)+.5))); - } - return query; + query.addQueryItem ("mode", encode_mode ()); + return query; } void WSPRNet::work() |
