6#include <QtCore/QByteArray>
8#include <QtCore/QMutex>
9#include <QtCore/QString>
10#include <QtNetwork/QHostAddress>
21 UDPClient(
const QHostAddress &addr, quint16 portNum)
62 Q_INVOKABLE
void addHost(
const QString &host);
63 Q_INVOKABLE
void addHost(
const QString &host, quint16 port);
64 Q_INVOKABLE
void removeHost(
const QString &host);
65 Q_INVOKABLE
void removeHost(
const QString &host, quint16 port);
70 void loadSettings(QSettings &settings,
const QString &root)
override;
71 void saveSettings(QSettings &settings,
const QString &root)
const override;
72 QString
settingsURL()
const override {
return QStringLiteral(
"UdpSettings.qml"); }
73 QString
settingsTitle()
const override {
return tr(
"UDP Link Settings"); }
75 QStringList
hostList()
const {
return _hostList; }
76 QList<std::shared_ptr<UDPClient>>
targetHosts()
const {
return _targetHosts; }
85 void _updateHostList();
87 static QString _getIpAddress(
const QString &address);
89 QStringList _hostList;
90 QList<std::shared_ptr<UDPClient>> _targetHosts;
91 quint16 _localPort = 0;
120 void _onSocketConnected();
121 void _onSocketDisconnected();
122 void _onSocketReadyRead();
123 void _onSocketBytesWritten(qint64 bytes);
124 void _onSocketErrorOccurred(QAbstractSocket::SocketError socketError);
128 QUdpSocket *_socket =
nullptr;
129 QMutex _sessionTargetsMutex;
130 QList<std::shared_ptr<UDPClient>> _sessionTargets;
131 bool _isConnected =
false;
132 bool _errorEmitted =
false;
133 QSet<QHostAddress> _localAddresses;
135 static const QHostAddress _multicastGroup;
156 void _writeBytes(
const QByteArray &data)
override;
158 void _onDisconnected();
160 void _onDataReceived(
const QByteArray &data);
161 void _onDataSent(
const QByteArray &data);
166 QThread *_workerThread =
nullptr;
167 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)
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 QHostAddress &addr, quint16 portNum)
UDPClient(const UDPClient *other)
bool operator==(const UDPClient &other) const
UDPClient & operator=(const UDPClient &other)