summaryrefslogtreecommitdiff
path: root/psk_reporter.cpp
diff options
context:
space:
mode:
authorEnrico Rossi <e.rossi@tecnobrain.com>2018-11-03 17:52:26 +0100
committerEnrico Rossi <e.rossi@tecnobrain.com>2018-11-03 17:52:26 +0100
commitb4aebf2d137b892f53503b13785ecae900062ff7 (patch)
tree3ba99b2baec2292f2e13bfe90a5e401a5f4c47a5 /psk_reporter.cpp
parent37f727ac0746fd85504aa46c1f023c09b3eff33a (diff)
New upstream version 1.9.1+repackupstream/1.9.1+repack
* Drop local hamlib copy (commit d1b545be). * Drop local boost copy (1.63.0).
Diffstat (limited to 'psk_reporter.cpp')
-rw-r--r--psk_reporter.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/psk_reporter.cpp b/psk_reporter.cpp
index 38d10417..b68a9c34 100644
--- a/psk_reporter.cpp
+++ b/psk_reporter.cpp
@@ -12,6 +12,11 @@
#include "moc_psk_reporter.cpp"
+namespace
+{
+ int constexpr MAX_PAYLOAD_LENGTH {1400};
+}
+
PSK_Reporter::PSK_Reporter(MessageClient * message_client, QObject *parent) :
QObject {parent},
m_messageClient {message_client},
@@ -68,10 +73,7 @@ void PSK_Reporter::addRemoteStation(QString call, QString grid, QString freq, QS
void PSK_Reporter::sendReport()
{
- if (m_spotQueue.isEmpty()) {
- return;
- }
-
+ while (!m_spotQueue.isEmpty()) {
QString report_h;
// Header
@@ -91,15 +93,16 @@ void PSK_Reporter::sendReport()
// Sender information
QString txInfoData_h = "50E3llll";
- while (!m_spotQueue.isEmpty()) {
- QHash<QString,QString> spot = m_spotQueue.dequeue();
- txInfoData_h += QString("%1").arg(spot["call"].length(),2,16,QChar('0')) + spot["call"].toUtf8().toHex();
- txInfoData_h += QString("%1").arg(spot["freq"].toLongLong(),8,16,QChar('0'));
- txInfoData_h += QString("%1").arg(spot["snr"].toInt(),8,16,QChar('0')).right(2);
- txInfoData_h += QString("%1").arg(spot["mode"].length(),2,16,QChar('0')) + spot["mode"].toUtf8().toHex();
- txInfoData_h += QString("%1").arg(spot["grid"].length(),2,16,QChar('0')) + spot["grid"].toUtf8().toHex();
- txInfoData_h += QString("%1").arg(1,2,16,QChar('0')); // REPORTER_SOURCE_AUTOMATIC
- txInfoData_h += QString("%1").arg(spot["time"].toInt(),8,16,QChar('0'));
+ while (!m_spotQueue.isEmpty()
+ && (header_h.size () + m_rxInfoDescriptor_h.size () + m_txInfoDescriptor_h.size () + rxInfoData_h.size () + txInfoData_h.size ()) / 2 < MAX_PAYLOAD_LENGTH) {
+ QHash<QString,QString> spot = m_spotQueue.dequeue();
+ txInfoData_h += QString("%1").arg(spot["call"].length(),2,16,QChar('0')) + spot["call"].toUtf8().toHex();
+ txInfoData_h += QString("%1").arg(spot["freq"].toLongLong(),8,16,QChar('0'));
+ txInfoData_h += QString("%1").arg(spot["snr"].toInt(),8,16,QChar('0')).right(2);
+ txInfoData_h += QString("%1").arg(spot["mode"].length(),2,16,QChar('0')) + spot["mode"].toUtf8().toHex();
+ txInfoData_h += QString("%1").arg(spot["grid"].length(),2,16,QChar('0')) + spot["grid"].toUtf8().toHex();
+ txInfoData_h += QString("%1").arg(1,2,16,QChar('0')); // REPORTER_SOURCE_AUTOMATIC
+ txInfoData_h += QString("%1").arg(spot["time"].toInt(),8,16,QChar('0'));
}
txInfoData_h += "0000";
txInfoData_h.replace("50E3llll", "50E3" + QString("%1").arg(txInfoData_h.length()/2,4,16,QChar('0')));
@@ -113,14 +116,18 @@ void PSK_Reporter::sendReport()
if (!m_pskReporterAddress.isNull()) {
m_messageClient->send_raw_datagram (report, m_pskReporterAddress, 4739);
}
+ }
}
void PSK_Reporter::dnsLookupResult(QHostInfo info)
{
if (!info.addresses().isEmpty()) {
m_pskReporterAddress = info.addresses().at(0);
-// qDebug() << "PSK Reporter IP: " << m_pskReporterAddress;
+ // qDebug() << "PSK Reporter IP: " << m_pskReporterAddress;
+
+ // deal with miss-configured settings that attempt to set a
+ // Pskreporter Internet address for the WSJT-X UDP protocol
+ // server address
+ m_messageClient->add_blocked_destination (m_pskReporterAddress);
}
}
-
-