summaryrefslogtreecommitdiff
path: root/UDPExamples
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-05-11 22:18:20 +0200
committerChristoph Berg <myon@debian.org>2020-05-11 22:18:20 +0200
commita8edac06b534058e52126c4d55e23b217df2df91 (patch)
treef2c3567fae58aad676d544ee8f07ac78dd2eb1ec /UDPExamples
parent4f6c0156a70e8f2ff70fe5a1a39f5e9b22ffd026 (diff)
parent32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (diff)
Update upstream source from tag 'upstream/2.2.0_rc1+repack'
Update to upstream version '2.2.0~rc1+repack' with Debian dir fe177bc6cd2d4c1256a3775504f6010be54e7463
Diffstat (limited to 'UDPExamples')
-rw-r--r--UDPExamples/MessageServer.cpp591
-rw-r--r--UDPExamples/MessageServer.hpp121
-rw-r--r--UDPExamples/UDPDaemon.cpp2
3 files changed, 713 insertions, 1 deletions
diff --git a/UDPExamples/MessageServer.cpp b/UDPExamples/MessageServer.cpp
new file mode 100644
index 00000000..ce7cd6fb
--- /dev/null
+++ b/UDPExamples/MessageServer.cpp
@@ -0,0 +1,591 @@
+#include "MessageServer.hpp"
+
+#include <stdexcept>
+#include <limits>
+
+#include <QNetworkInterface>
+#include <QUdpSocket>
+#include <QString>
+#include <QTimer>
+#include <QHash>
+
+#include "Radio.hpp"
+#include "Network/NetworkMessage.hpp"
+#include "qt_helpers.hpp"
+
+#include "pimpl_impl.hpp"
+
+#include "moc_MessageServer.cpp"
+
+namespace
+{
+ auto quint32_max = std::numeric_limits<quint32>::max ();
+}
+
+class MessageServer::impl
+ : public QUdpSocket
+{
+ Q_OBJECT;
+
+public:
+ impl (MessageServer * self, QString const& version, QString const& revision)
+ : self_ {self}
+ , version_ {version}
+ , revision_ {revision}
+ , port_ {0u}
+ , clock_ {new QTimer {this}}
+ {
+ // register the required types with Qt
+ Radio::register_types ();
+
+ connect (this, &QIODevice::readyRead, this, &MessageServer::impl::pending_datagrams);
+ connect (this, static_cast<void (impl::*) (SocketError)> (&impl::error)
+ , [this] (SocketError /* e */)
+ {
+ Q_EMIT self_->error (errorString ());
+ });
+ connect (clock_, &QTimer::timeout, this, &impl::tick);
+ clock_->start (NetworkMessage::pulse * 1000);
+ }
+
+ enum StreamStatus {Fail, Short, OK};
+
+ void leave_multicast_group ();
+ void join_multicast_group ();
+ void parse_message (QHostAddress const& sender, port_type sender_port, QByteArray const& msg);
+ void tick ();
+ void pending_datagrams ();
+ StreamStatus check_status (QDataStream const&) const;
+ void send_message (QDataStream const& out, QByteArray const& message, QHostAddress const& address, port_type port)
+ {
+ if (OK == check_status (out))
+ {
+ writeDatagram (message, address, port);
+ }
+ else
+ {
+ Q_EMIT self_->error ("Error creating UDP message");
+ }
+ }
+
+ MessageServer * self_;
+ QString version_;
+ QString revision_;
+ port_type port_;
+ QHostAddress multicast_group_address_;
+ static BindMode constexpr bind_mode_ = ShareAddress | ReuseAddressHint;
+ struct Client
+ {
+ Client () = default;
+ Client (QHostAddress const& sender_address, port_type const& sender_port)
+ : sender_address_ {sender_address}
+ , sender_port_ {sender_port}
+ , negotiated_schema_number_ {2} // not 1 because it's broken
+ , last_activity_ {QDateTime::currentDateTime ()}
+ {
+ }
+ Client (Client const&) = default;
+ Client& operator= (Client const&) = default;
+
+ QHostAddress sender_address_;
+ port_type sender_port_;
+ quint32 negotiated_schema_number_;
+ QDateTime last_activity_;
+ };
+ QHash<QString, Client> clients_; // maps id to Client
+ QTimer * clock_;
+};
+
+MessageServer::impl::BindMode constexpr MessageServer::impl::bind_mode_;
+
+#include "MessageServer.moc"
+
+void MessageServer::impl::leave_multicast_group ()
+{
+ if (!multicast_group_address_.isNull () && BoundState == state ()
+#if QT_VERSION >= 0x050600
+ && multicast_group_address_.isMulticast ()
+#endif
+ )
+ {
+ for (auto const& interface : QNetworkInterface::allInterfaces ())
+ {
+ if (QNetworkInterface::CanMulticast & interface.flags ())
+ {
+ leaveMulticastGroup (multicast_group_address_, interface);
+ }
+ }
+ }
+}
+
+void MessageServer::impl::join_multicast_group ()
+{
+ if (BoundState == state ()
+ && !multicast_group_address_.isNull ()
+#if QT_VERSION >= 0x050600
+ && multicast_group_address_.isMulticast ()
+#endif
+ )
+ {
+ auto mcast_iface = multicastInterface ();
+ if (IPv4Protocol == multicast_group_address_.protocol ()
+ && IPv4Protocol != localAddress ().protocol ())
+ {
+ close ();
+ bind (QHostAddress::AnyIPv4, port_, bind_mode_);
+ }
+ bool joined {false};
+ for (auto const& interface : QNetworkInterface::allInterfaces ())
+ {
+ if (QNetworkInterface::CanMulticast & interface.flags ())
+ {
+ // Windows requires outgoing interface to match
+ // interface to be joined while joining, at least for
+ // IPv4 it seems to
+ setMulticastInterface (interface);
+
+ joined |= joinMulticastGroup (multicast_group_address_, interface);
+ }
+ }
+ if (!joined)
+ {
+ multicast_group_address_.clear ();
+ }
+ setMulticastInterface (mcast_iface);
+ }
+}
+
+void MessageServer::impl::pending_datagrams ()
+{
+ while (hasPendingDatagrams ())
+ {
+ QByteArray datagram;
+ datagram.resize (pendingDatagramSize ());
+ QHostAddress sender_address;
+ port_type sender_port;
+ if (0 <= readDatagram (datagram.data (), datagram.size (), &sender_address, &sender_port))
+ {
+ parse_message (sender_address, sender_port, datagram);
+ }
+ }
+}
+
+void MessageServer::impl::parse_message (QHostAddress const& sender, port_type sender_port, QByteArray const& msg)
+{
+ try
+ {
+ //
+ // message format is described in NetworkMessage.hpp
+ //
+ NetworkMessage::Reader in {msg};
+
+ auto id = in.id ();
+ if (OK == check_status (in))
+ {
+ if (!clients_.contains (id))
+ {
+ auto& client = (clients_[id] = {sender, sender_port});
+ QByteArray client_version;
+ QByteArray client_revision;
+
+ if (NetworkMessage::Heartbeat == in.type ())
+ {
+ // negotiate a working schema number
+ in >> client.negotiated_schema_number_;
+ if (OK == check_status (in))
+ {
+ auto sn = NetworkMessage::Builder::schema_number;
+ client.negotiated_schema_number_ = std::min (sn, client.negotiated_schema_number_);
+
+ // reply to the new client informing it of the
+ // negotiated schema number
+ QByteArray message;
+ NetworkMessage::Builder hb {&message, NetworkMessage::Heartbeat, id, client.negotiated_schema_number_};
+ hb << NetworkMessage::Builder::schema_number // maximum schema number accepted
+ << version_.toUtf8 () << revision_.toUtf8 ();
+ if (impl::OK == check_status (hb))
+ {
+ writeDatagram (message, client.sender_address_, client.sender_port_);
+ }
+ else
+ {
+ Q_EMIT self_->error ("Error creating UDP message");
+ }
+ }
+ // we don't care if this fails to read
+ in >> client_version >> client_revision;
+ }
+ Q_EMIT self_->client_opened (id, QString::fromUtf8 (client_version),
+ QString::fromUtf8 (client_revision));
+ }
+ clients_[id].last_activity_ = QDateTime::currentDateTime ();
+
+ //
+ // message format is described in NetworkMessage.hpp
+ //
+ switch (in.type ())
+ {
+ case NetworkMessage::Heartbeat:
+ //nothing to do here as time out handling deals with lifetime
+ break;
+
+ case NetworkMessage::Clear:
+ Q_EMIT self_->decodes_cleared (id);
+ break;
+
+ case NetworkMessage::Status:
+ {
+ // unpack message
+ Frequency f;
+ QByteArray mode;
+ QByteArray dx_call;
+ QByteArray report;
+ QByteArray tx_mode;
+ bool tx_enabled {false};
+ bool transmitting {false};
+ bool decoding {false};
+ quint32 rx_df {quint32_max};
+ quint32 tx_df {quint32_max};
+ QByteArray de_call;
+ QByteArray de_grid;
+ QByteArray dx_grid;
+ bool watchdog_timeout {false};
+ QByteArray sub_mode;
+ bool fast_mode {false};
+ quint8 special_op_mode {0};
+ quint32 frequency_tolerance {quint32_max};
+ quint32 tr_period {quint32_max};
+ QByteArray configuration_name;
+ in >> f >> mode >> dx_call >> report >> tx_mode >> tx_enabled >> transmitting >> decoding
+ >> rx_df >> tx_df >> de_call >> de_grid >> dx_grid >> watchdog_timeout >> sub_mode
+ >> fast_mode >> special_op_mode >> frequency_tolerance >> tr_period >> configuration_name;
+ if (check_status (in) != Fail)
+ {
+ Q_EMIT self_->status_update (id, f, QString::fromUtf8 (mode), QString::fromUtf8 (dx_call)
+ , QString::fromUtf8 (report), QString::fromUtf8 (tx_mode)
+ , tx_enabled, transmitting, decoding, rx_df, tx_df
+ , QString::fromUtf8 (de_call), QString::fromUtf8 (de_grid)
+ , QString::fromUtf8 (dx_grid), watchdog_timeout
+ , QString::fromUtf8 (sub_mode), fast_mode
+ , special_op_mode, frequency_tolerance, tr_period
+ , QString::fromUtf8 (configuration_name));
+ }
+ }
+ break;
+
+ case NetworkMessage::Decode:
+ {
+ // unpack message
+ bool is_new {true};
+ QTime time;
+ qint32 snr;
+ float delta_time;
+ quint32 delta_frequency;
+ QByteArray mode;
+ QByteArray message;
+ bool low_confidence {false};
+ bool off_air {false};
+ in >> is_new >> time >> snr >> delta_time >> delta_frequency >> mode
+ >> message >> low_confidence >> off_air;
+ if (check_status (in) != Fail)
+ {
+ Q_EMIT self_->decode (is_new, id, time, snr, delta_time, delta_frequency
+ , QString::fromUtf8 (mode), QString::fromUtf8 (message)
+ , low_confidence, off_air);
+ }
+ }
+ break;
+
+ case NetworkMessage::WSPRDecode:
+ {
+ // unpack message
+ bool is_new {true};
+ QTime time;
+ qint32 snr;
+ float delta_time;
+ Frequency frequency;
+ qint32 drift;
+ QByteArray callsign;
+ QByteArray grid;
+ qint32 power;
+ bool off_air {false};
+ in >> is_new >> time >> snr >> delta_time >> frequency >> drift >> callsign >> grid >> power
+ >> off_air;
+ if (check_status (in) != Fail)
+ {
+ Q_EMIT self_->WSPR_decode (is_new, id, time, snr, delta_time, frequency, drift
+ , QString::fromUtf8 (callsign), QString::fromUtf8 (grid)
+ , power, off_air);
+ }
+ }
+ break;
+
+ case NetworkMessage::QSOLogged:
+ {
+ QDateTime time_off;
+ QByteArray dx_call;
+ QByteArray dx_grid;
+ Frequency dial_frequency;
+ QByteArray mode;
+ QByteArray report_sent;
+ QByteArray report_received;
+ QByteArray tx_power;
+ QByteArray comments;
+ QByteArray name;
+ QDateTime time_on; // Note: LOTW uses TIME_ON for their +/- 30-minute time window
+ QByteArray operator_call;
+ QByteArray my_call;
+ QByteArray my_grid;
+ QByteArray exchange_sent;
+ QByteArray exchange_rcvd;
+ in >> time_off >> dx_call >> dx_grid >> dial_frequency >> mode >> report_sent >> report_received
+ >> tx_power >> comments >> name >> time_on >> operator_call >> my_call >> my_grid
+ >> exchange_sent >> exchange_rcvd;
+ if (check_status (in) != Fail)
+ {
+ Q_EMIT self_->qso_logged (id, time_off, QString::fromUtf8 (dx_call), QString::fromUtf8 (dx_grid)
+ , dial_frequency, QString::fromUtf8 (mode), QString::fromUtf8 (report_sent)
+ , QString::fromUtf8 (report_received), QString::fromUtf8 (tx_power)
+ , QString::fromUtf8 (comments), QString::fromUtf8 (name), time_on
+ , QString::fromUtf8 (operator_call), QString::fromUtf8 (my_call)
+ , QString::fromUtf8 (my_grid), QString::fromUtf8 (exchange_sent)
+ , QString::fromUtf8 (exchange_rcvd));
+ }
+ }
+ break;
+
+ case NetworkMessage::Close:
+ Q_EMIT self_->client_closed (id);
+ clients_.remove (id);
+ break;
+
+ case NetworkMessage::LoggedADIF:
+ {
+ QByteArray ADIF;
+ in >> ADIF;
+ if (check_status (in) != Fail)
+ {
+ Q_EMIT self_->logged_ADIF (id, ADIF);
+ }
+ }
+ break;
+
+ default:
+ // Ignore
+ break;
+ }
+ }
+ else
+ {
+ Q_EMIT self_->error ("MessageServer warning: invalid UDP message received");
+ }
+ }
+ catch (std::exception const& e)
+ {
+ Q_EMIT self_->error (QString {"MessageServer exception: %1"}.arg (e.what ()));
+ }
+ catch (...)
+ {
+ Q_EMIT self_->error ("Unexpected exception in MessageServer");
+ }
+}
+
+void MessageServer::impl::tick ()
+{
+ auto now = QDateTime::currentDateTime ();
+ auto iter = std::begin (clients_);
+ while (iter != std::end (clients_))
+ {
+ if (now > (*iter).last_activity_.addSecs (NetworkMessage::pulse))
+ {
+ Q_EMIT self_->clear_decodes (iter.key ());
+ Q_EMIT self_->client_closed (iter.key ());
+ iter = clients_.erase (iter); // safe while iterating as doesn't rehash
+ }
+ else
+ {
+ ++iter;
+ }
+ }
+}
+
+auto MessageServer::impl::check_status (QDataStream const& stream) const -> StreamStatus
+{
+ auto stat = stream.status ();
+ StreamStatus result {Fail};
+ switch (stat)
+ {
+ case QDataStream::ReadPastEnd:
+ result = Short;
+ break;
+
+ case QDataStream::ReadCorruptData:
+ Q_EMIT self_->error ("Message serialization error: read corrupt data");
+ break;
+
+ case QDataStream::WriteFailed:
+ Q_EMIT self_->error ("Message serialization error: write error");
+ break;
+
+ default:
+ result = OK;
+ break;
+ }
+ return result;
+}
+
+MessageServer::MessageServer (QObject * parent, QString const& version, QString const& revision)
+ : QObject {parent}
+ , m_ {this, version, revision}
+{
+}
+
+void MessageServer::start (port_type port, QHostAddress const& multicast_group_address)
+{
+ if (port != m_->port_
+ || multicast_group_address != m_->multicast_group_address_)
+ {
+ m_->leave_multicast_group ();
+ if (impl::BoundState == m_->state ())
+ {
+ m_->close ();
+ }
+ m_->multicast_group_address_ = multicast_group_address;
+ auto address = m_->multicast_group_address_.isNull ()
+ || impl::IPv4Protocol != m_->multicast_group_address_.protocol () ? QHostAddress::Any : QHostAddress::AnyIPv4;
+ if (port && m_->bind (address, port, m_->bind_mode_))
+ {
+ m_->port_ = port;
+ m_->join_multicast_group ();
+ }
+ else
+ {
+ m_->port_ = 0;
+ }
+ }
+}
+
+void MessageServer::clear_decodes (QString const& id, quint8 window)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Clear, id, (*iter).negotiated_schema_number_};
+ out << window;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::reply (QString const& id, QTime time, qint32 snr, float delta_time
+ , quint32 delta_frequency, QString const& mode
+ , QString const& message_text, bool low_confidence, quint8 modifiers)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Reply, id, (*iter).negotiated_schema_number_};
+ out << time << snr << delta_time << delta_frequency << mode.toUtf8 ()
+ << message_text.toUtf8 () << low_confidence << modifiers;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::replay (QString const& id)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Replay, id, (*iter).negotiated_schema_number_};
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::close (QString const& id)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Close, id, (*iter).negotiated_schema_number_};
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::halt_tx (QString const& id, bool auto_only)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::HaltTx, id, (*iter).negotiated_schema_number_};
+ out << auto_only;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::free_text (QString const& id, QString const& text, bool send)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::FreeText, id, (*iter).negotiated_schema_number_};
+ out << text.toUtf8 () << send;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::location (QString const& id, QString const& loc)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Location, id, (*iter).negotiated_schema_number_};
+ out << loc.toUtf8 ();
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::highlight_callsign (QString const& id, QString const& callsign
+ , QColor const& bg, QColor const& fg, bool last_only)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::HighlightCallsign, id, (*iter).negotiated_schema_number_};
+ out << callsign.toUtf8 () << bg << fg << last_only;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::switch_configuration (QString const& id, QString const& configuration_name)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::SwitchConfiguration, id, (*iter).negotiated_schema_number_};
+ out << configuration_name.toUtf8 ();
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
+
+void MessageServer::configure (QString const& id, QString const& mode, quint32 frequency_tolerance
+ , QString const& submode, bool fast_mode, quint32 tr_period, quint32 rx_df
+ , QString const& dx_call, QString const& dx_grid, bool generate_messages)
+{
+ auto iter = m_->clients_.find (id);
+ if (iter != std::end (m_->clients_))
+ {
+ QByteArray message;
+ NetworkMessage::Builder out {&message, NetworkMessage::Configure, id, (*iter).negotiated_schema_number_};
+ out << mode.toUtf8 () << frequency_tolerance << submode.toUtf8 () << fast_mode << tr_period << rx_df
+ << dx_call.toUtf8 () << dx_grid.toUtf8 () << generate_messages;
+ m_->send_message (out, message, iter.value ().sender_address_, (*iter).sender_port_);
+ }
+}
diff --git a/UDPExamples/MessageServer.hpp b/UDPExamples/MessageServer.hpp
new file mode 100644
index 00000000..f59c21fe
--- /dev/null
+++ b/UDPExamples/MessageServer.hpp
@@ -0,0 +1,121 @@
+#ifndef MESSAGE_SERVER_HPP__
+#define MESSAGE_SERVER_HPP__
+
+#include <QObject>
+#include <QTime>
+#include <QDateTime>
+#include <QHostAddress>
+#include <QColor>
+
+#include "udp_export.h"
+#include "Radio.hpp"
+
+#include "pimpl_h.hpp"
+
+class QString;
+
+//
+// MessageServer - a reference implementation of a message server
+// matching the MessageClient class at the other end
+// of the wire
+//
+// This class is fully functioning and suitable for use in C++
+// applications that use the Qt framework. Other applications should
+// use this classes' implementation as a reference implementation.
+//
+class UDP_EXPORT MessageServer
+ : public QObject
+{
+ Q_OBJECT;
+
+public:
+ using port_type = quint16;
+ using Frequency = Radio::Frequency;
+
+ MessageServer (QObject * parent = nullptr,
+ QString const& version = QString {}, QString const& revision = QString {});
+
+ // start or restart the server, if the multicast_group_address
+ // argument is given it is assumed to be a multicast group address
+ // which the server will join
+ Q_SLOT void start (port_type port,
+ QHostAddress const& multicast_group_address = QHostAddress {});
+
+ // ask the client to clear one or both of the decode windows
+ Q_SLOT void clear_decodes (QString const& id, quint8 window = 0);
+
+ // ask the client with identification 'id' to make the same action
+ // as a double click on the decode would
+ //
+ // note that the client is not obliged to take any action and only
+ // takes any action if the decode is present and is a CQ or QRZ message
+ Q_SLOT void reply (QString const& id, QTime time, qint32 snr, float delta_time, quint32 delta_frequency
+ , QString const& mode, QString const& message, bool low_confidence, quint8 modifiers);
+
+ // ask the client with identification 'id' to close down gracefully
+ Q_SLOT void close (QString const& id);
+
+ // ask the client with identification 'id' to replay all decodes
+ Q_SLOT void replay (QString const& id);
+
+ // ask the client with identification 'id' to halt transmitting
+ // auto_only just disables auto Tx, otherwise halt is immediate
+ Q_SLOT void halt_tx (QString const& id, bool auto_only);
+
+ // ask the client with identification 'id' to set the free text
+ // message and optionally send it ASAP
+ Q_SLOT void free_text (QString const& id, QString const& text, bool send);
+
+ // ask the client with identification 'id' to set the location provided
+ Q_SLOT void location (QString const& id, QString const& location);
+
+ // ask the client with identification 'id' to highlight the callsign
+ // specified with the given colors
+ Q_SLOT void highlight_callsign (QString const& id, QString const& callsign
+ , QColor const& bg = QColor {}, QColor const& fg = QColor {}
+ , bool last_only = false);
+
+ // ask the client with identification 'id' to switch to
+ // configuration 'configuration_name'
+ Q_SLOT void switch_configuration (QString const& id, QString const& configuration_name);
+
+ // ask the client with identification 'id' to change configuration
+ Q_SLOT void configure (QString const& id, QString const& mode, quint32 frequency_tolerance
+ , QString const& submode, bool fast_mode, quint32 tr_period, quint32 rx_df
+ , QString const& dx_call, QString const& dx_grid, bool generate_messages);
+
+ // the following signals are emitted when a client broadcasts the
+ // matching message
+ Q_SIGNAL void client_opened (QString const& id, QString const& version, QString const& revision);
+ Q_SIGNAL void status_update (QString const& id, Frequency, QString const& mode, QString const& dx_call
+ , QString const& report, QString const& tx_mode, bool tx_enabled
+ , bool transmitting, bool decoding, quint32 rx_df, quint32 tx_df
+ , QString const& de_call, QString const& de_grid, QString const& dx_grid
+ , bool watchdog_timeout, QString const& sub_mode, bool fast_mode
+ , quint8 special_op_mode, quint32 frequency_tolerance, quint32 tr_period
+ , QString const& configuration_name);
+ Q_SIGNAL void client_closed (QString const& id);
+ Q_SIGNAL void decode (bool is_new, QString const& id, QTime time, qint32 snr, float delta_time
+ , quint32 delta_frequency, QString const& mode, QString const& message
+ , bool low_confidence, bool off_air);
+ Q_SIGNAL void WSPR_decode (bool is_new, QString const& id, QTime time, qint32 snr, float delta_time, Frequency
+ , qint32 drift, QString const& callsign, QString const& grid, qint32 power
+ , bool off_air);
+ Q_SIGNAL void qso_logged (QString const& id, QDateTime time_off, QString const& dx_call, QString const& dx_grid
+ , Frequency dial_frequency, QString const& mode, QString const& report_sent
+ , QString const& report_received, QString const& tx_power, QString const& comments
+ , QString const& name, QDateTime time_on, QString const& operator_call
+ , QString const& my_call, QString const& my_grid
+ , QString const& exchange_sent, QString const& exchange_rcvd);
+ Q_SIGNAL void decodes_cleared (QString const& id);
+ Q_SIGNAL void logged_ADIF (QString const& id, QByteArray const& ADIF);
+
+ // this signal is emitted when a network error occurs
+ Q_SIGNAL void error (QString const&) const;
+
+private:
+ class UDP_NO_EXPORT impl;
+ pimpl<impl> m_;
+};
+
+#endif
diff --git a/UDPExamples/UDPDaemon.cpp b/UDPExamples/UDPDaemon.cpp
index 7caeb303..dea2c68c 100644
--- a/UDPExamples/UDPDaemon.cpp
+++ b/UDPExamples/UDPDaemon.cpp
@@ -147,7 +147,7 @@ public:
: server_ {new MessageServer {this}}
{
// connect up server
- connect (server_, &MessageServer::error, [this] (QString const& message) {
+ connect (server_, &MessageServer::error, [] (QString const& message) {
std::cerr << tr ("Network Error: %1").arg ( message).toStdString () << std::endl;
});
connect (server_, &MessageServer::client_opened, this, &Server::add_client);