diff --git a/psk_reporter.cpp b/psk_reporter.cpp index 6a4a73a22..fdf54afd2 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 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 () < MAX_PAYLOAD_LENGTH) { + QHash 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,6 +116,7 @@ void PSK_Reporter::sendReport() if (!m_pskReporterAddress.isNull()) { m_messageClient->send_raw_datagram (report, m_pskReporterAddress, 4739); } + } } void PSK_Reporter::dnsLookupResult(QHostInfo info)