6#include <QtCore/QByteArray>
8#include <QtCore/QMutex>
9#include <QtCore/QString>
10#include <QtNetwork/QHostAddress>
21 UDPClient(
const QHostAddress &addr, quint16 portNum)
26 UDPClient(
const QString &host,
const QHostAddress &addr, quint16 portNum)
71 Q_INVOKABLE
void addHost(
const QString &host);
72 Q_INVOKABLE
void addHost(
const QString &host, quint16 port);
73 Q_INVOKABLE
void removeHost(
const QString &host);
74 Q_INVOKABLE
void removeHost(
const QString &host, quint16 port);
79 void loadSettings(QSettings &settings,
const QString &root)
override;
80 void saveSettings(QSettings &settings,
const QString &root)
const override;
81 QString
settingsURL()
const override {
return QStringLiteral(
"UdpSettings.qml"); }
82 QString
settingsTitle()
const override {
return tr(
"UDP Link Settings"); }
84 QStringList
hostList()
const {
return _hostList; }
85 QList<std::shared_ptr<UDPClient>>
targetHosts()
const {
return _targetHosts; }
95 void _updateHostList();
97 static QString _getIpAddress(
const QString &address);
99 QStringList _hostList;
100 QList<std::shared_ptr<UDPClient>> _targetHosts;
101 quint16 _localPort = 0;
130 void _onSocketConnected();
131 void _onSocketDisconnected();
132 void _onSocketReadyRead();
133 void _onSocketBytesWritten(qint64 bytes);
134 void _onSocketErrorOccurred(QAbstractSocket::SocketError socketError);
138 QUdpSocket *_socket =
nullptr;
139 QMutex _sessionTargetsMutex;
140 QList<std::shared_ptr<UDPClient>> _sessionTargets;
141 bool _isConnected =
false;
142 bool _errorEmitted =
false;
143 QSet<QHostAddress> _localAddresses;
145 static const QHostAddress _multicastGroup;
166 void _writeBytes(
const QByteArray &data)
override;
168 void _onDisconnected();
170 void _onDataReceived(
const QByteArray &data);
171 void _onDataSent(
const QByteArray &data);
176 QThread *_workerThread =
nullptr;
177 std::atomic<bool> _disconnectedEmitted{
false};
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
Interface holding link specific settings.
The link interface defines the interface for all links used to communicate with the ground station ap...
void saveSettings(QSettings &settings, const QString &root) const override
QList< std::shared_ptr< UDPClient > > targetHosts() const
quint16 localPort() const
QStringList hostList() const
QString settingsTitle() const override
Settings Title, Pure virtual method providing the Title for the (QML) settings dialog.
Q_INVOKABLE void removeHost(const QString &host)
void setAutoConnect(bool autoc=true) override
Set if this is this an Auto Connect configuration.
void setLocalPort(quint16 port)
Q_INVOKABLE void addHost(const QString &host)
void resolveHosts() const
virtual ~UDPConfiguration()
LinkType type() const override
void copyFrom(const LinkConfiguration *source) override
void loadSettings(QSettings &settings, const QString &root) override
QString settingsURL() const override
Settings URL, Pure virtual method providing the URL for the (QML) settings dialog.
bool isSecureConnection() const override
Returns true if the connection is secure (e.g. USB, wired ethernet)
bool isConnected() const override
bool _connect() override
connect is private since all links should be created through LinkManager::createConnectedLink calls
void disconnect() override
void dataReceived(const QByteArray &data)
void dataSent(const QByteArray &data)
void errorOccurred(const QString &errorString)
void writeData(const QByteArray &data)
UDPClient(const QString &host, const QHostAddress &addr, quint16 portNum)
UDPClient(const QHostAddress &addr, quint16 portNum)
UDPClient(const UDPClient *other)
bool operator==(const UDPClient &other) const
UDPClient & operator=(const UDPClient &other)