Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
faee40e0
Commit
faee40e0
authored
Feb 05, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UDP link fixes
Maintain a list of address/port pairs instead of a address/port map.
parent
6baee573
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
214 deletions
+176
-214
UDPLink.cc
src/comm/UDPLink.cc
+132
-160
UDPLink.h
src/comm/UDPLink.h
+44
-54
No files found.
src/comm/UDPLink.cc
View file @
faee40e0
This diff is collapsed.
Click to expand it.
src/comm/UDPLink.h
View file @
faee40e0
...
...
@@ -34,10 +34,23 @@
#include "QGCConfig.h"
#include "LinkManager.h"
class
UDPCLient
{
public:
UDPCLient
(
const
QHostAddress
&
address_
,
quint16
port_
)
:
address
(
address_
)
,
port
(
port_
)
{}
UDPCLient
(
const
UDPCLient
*
other
)
:
address
(
other
->
address
)
,
port
(
other
->
port
)
{}
QHostAddress
address
;
quint16
port
;
};
class
UDPConfiguration
:
public
LinkConfiguration
{
Q_OBJECT
public:
Q_PROPERTY
(
quint16
localPort
READ
localPort
WRITE
setLocalPort
NOTIFY
localPortChanged
)
...
...
@@ -61,30 +74,7 @@ public:
*/
UDPConfiguration
(
UDPConfiguration
*
source
);
/*!
* @brief Begin iteration through the list of target hosts
*
* @param[out] host Host name
* @param[out] port Port number
* @return Returns false if list is empty
*/
bool
firstHost
(
QString
&
host
,
int
&
port
);
/*!
* @brief Continues iteration through the list of target hosts
*
* @param[out] host Host name
* @param[out] port Port number
* @return Returns false if reached the end of the list (in which case, both host and port are unchanged)
*/
bool
nextHost
(
QString
&
host
,
int
&
port
);
/*!
* @brief Get the number of target hosts
*
* @return Number of hosts in list
*/
int
hostCount
()
{
return
_hosts
.
count
();
}
~
UDPConfiguration
();
/*!
* @brief The UDP port we bind to
...
...
@@ -106,7 +96,7 @@ public:
* @param[in] host Host name, e.g. localhost or 192.168.1.1
* @param[in] port Port number
*/
void
addHost
(
const
QString
&
host
,
int
port
);
void
addHost
(
const
QString
&
host
,
quint16
port
);
/*!
* @brief Remove a target host from the list
...
...
@@ -127,6 +117,8 @@ public:
*/
QStringList
hostList
()
{
return
_hostList
;
}
const
QList
<
UDPCLient
*>
targetHosts
()
{
return
_targetHosts
;
}
/// From LinkConfiguration
LinkType
type
()
{
return
LinkConfiguration
::
TypeUdp
;
}
void
copyFrom
(
LinkConfiguration
*
source
);
...
...
@@ -142,13 +134,13 @@ signals:
private:
void
_updateHostList
();
void
_clearTargetHosts
();
void
_copyFrom
(
LinkConfiguration
*
source
);
private:
QMutex
_confMutex
;
QMap
<
QString
,
int
>::
iterator
_it
;
QMap
<
QString
,
int
>
_hosts
;
///< ("host", port)
QStringList
_hostList
;
///< Exposed to QML
quint16
_localPort
;
QList
<
UDPCLient
*>
_targetHosts
;
QStringList
_hostList
;
///< Exposed to QML
quint16
_localPort
;
};
class
UDPLink
:
public
LinkInterface
...
...
@@ -159,32 +151,28 @@ class UDPLink : public LinkInterface
friend
class
LinkManager
;
public:
void
requestReset
()
{
}
bool
isConnected
()
const
;
QString
getName
()
const
;
void
requestReset
()
override
{
}
bool
isConnected
()
const
override
;
QString
getName
()
const
override
;
// Extensive statistics for scientific purposes
qint64
getConnectionSpeed
()
const
;
qint64
getCurrentInDataRate
()
const
;
qint64
getCurrentOutDataRate
()
const
;
qint64
getConnectionSpeed
()
const
override
;
qint64
getCurrentInDataRate
()
const
;
qint64
getCurrentOutDataRate
()
const
;
void
run
();
// Thread
void
run
()
override
;
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool
connect
(
void
);
bool
disconnect
(
void
);
bool
connect
(
void
);
bool
disconnect
(
void
);
public
slots
:
/*! @brief Add a new host to broadcast messages to */
void
addHost
(
const
QString
&
host
);
/*! @brief Remove a host from broadcasting messages to */
void
removeHost
(
const
QString
&
host
);
void
readBytes
();
void
readBytes
();
private
slots
:
void
_writeBytes
(
const
QByteArray
data
)
;
void
_writeBytes
(
const
QByteArray
data
)
override
;
private:
// Links are only created/destroyed by LinkManager so constructor/destructor is not public
...
...
@@ -192,14 +180,14 @@ private:
~
UDPLink
();
// From LinkInterface
virtual
bool
_connect
(
void
)
;
v
irtual
void
_disconnect
(
void
)
;
bool
_connect
(
void
)
override
;
v
oid
_disconnect
(
void
)
override
;
bool
_hardwareConnect
();
void
_restartConnection
();
void
_registerZeroconf
(
uint16_t
port
,
const
std
::
string
&
regType
);
void
_deregisterZeroconf
(
);
bool
_hardwareConnect
();
void
_restartConnection
();
void
_registerZeroconf
(
uint16_t
port
,
const
std
::
string
&
regType
);
void
_deregisterZeroconf
(
);
void
_writeDataGram
(
const
QByteArray
data
,
const
UDPCLient
*
target
);
#if defined(QGC_ZEROCONF_ENABLED)
DNSServiceRef
_dnssServiceRef
;
...
...
@@ -209,6 +197,8 @@ private:
QUdpSocket
*
_socket
;
UDPConfiguration
*
_udpConfig
;
bool
_connectState
;
QList
<
UDPCLient
*>
_sessionTargets
;
};
#endif // UDPLINK_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment