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
06ae441e
Commit
06ae441e
authored
Jun 02, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1628 from dogmaphobic/Zeroconf
Enabling Zeroconf (Bonjour) on Mac OS/iOS
parents
235b986f
ab7f1679
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
0 deletions
+70
-0
QGCExternalLibs.pri
QGCExternalLibs.pri
+18
-0
UDPLink.cc
src/comm/UDPLink.cc
+41
-0
UDPLink.h
src/comm/UDPLink.h
+11
-0
No files found.
QGCExternalLibs.pri
View file @
06ae441e
...
...
@@ -278,3 +278,21 @@ else:WindowsBuild {
DEFINES += QGC_SPEECH_ENABLED
LIBS += -lOle32
}
#
# [OPTIONAL] Zeroconf for UDP links
#
contains (DEFINES, DISABLE_ZEROCONF) {
message("Skipping support for Zeroconf (manual override from command line)")
DEFINES -= DISABLE_ZEROCONF
# Otherwise the user can still disable this feature in the user_config.pri file.
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, DISABLE_ZEROCONF) {
message("Skipping support for Zeroconf (manual override from user_config.pri)")
# Mac support is built into OS
} else:MacBuild|iOSBuild {
message("Including support for Zeroconf (Bonjour)")
DEFINES += QGC_ZEROCONF_ENABLED
} else {
message("Skipping support for Zeroconf (unsupported platform)")
}
src/comm/UDPLink.cc
View file @
06ae441e
...
...
@@ -39,6 +39,8 @@ This file is part of the QGROUNDCONTROL project
#include "QGC.h"
#include <QHostInfo>
static
const
char
*
kZeroconfRegistration
=
"_qgroundcontrol._udp"
;
static
bool
is_ip
(
const
QString
&
address
)
{
int
a
,
b
,
c
,
d
;
...
...
@@ -75,6 +77,9 @@ static QString get_ip_address(const QString& address)
UDPLink
::
UDPLink
(
UDPConfiguration
*
config
)
:
_socket
(
NULL
)
,
_connectState
(
false
)
#if defined(QGC_ZEROCONF_ENABLED)
,
_dnssServiceRef
(
NULL
)
#endif
{
Q_ASSERT
(
config
!=
NULL
);
_config
=
config
;
...
...
@@ -108,6 +113,7 @@ void UDPLink::run()
_hardwareConnect
();
exec
();
if
(
_socket
)
{
_deregisterZeroconf
();
_socket
->
close
();
}
}
...
...
@@ -267,6 +273,7 @@ bool UDPLink::_hardwareConnect()
_socket
->
setProxy
(
QNetworkProxy
::
NoProxy
);
_connectState
=
_socket
->
bind
(
host
,
_config
->
localPort
(),
QAbstractSocket
::
ReuseAddressHint
);
if
(
_connectState
)
{
_registerZeroconf
(
_config
->
localPort
(),
kZeroconfRegistration
);
QObject
::
connect
(
_socket
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readBytes
()));
emit
connected
();
}
else
{
...
...
@@ -300,6 +307,40 @@ qint64 UDPLink::getCurrentOutDataRate() const
return
0
;
}
void
UDPLink
::
_registerZeroconf
(
uint16_t
port
,
const
std
::
string
&
regType
)
{
#if defined(QGC_ZEROCONF_ENABLED)
DNSServiceErrorType
result
=
DNSServiceRegister
(
&
_dnssServiceRef
,
0
,
0
,
0
,
regType
.
c_str
(),
NULL
,
NULL
,
htons
(
port
),
0
,
NULL
,
NULL
,
NULL
);
if
(
result
!=
kDNSServiceErr_NoError
)
{
emit
communicationError
(
"UDP Link Error"
,
"Error registering Zeroconf"
);
_dnssServiceRef
=
NULL
;
}
#else
Q_UNUSED
(
port
);
Q_UNUSED
(
regType
);
#endif
}
void
UDPLink
::
_deregisterZeroconf
()
{
#if defined(QGC_ZEROCONF_ENABLED)
if
(
_dnssServiceRef
)
{
DNSServiceRefDeallocate
(
_dnssServiceRef
);
_dnssServiceRef
=
NULL
;
}
#endif
}
//--------------------------------------------------------------------------
//-- UDPConfiguration
...
...
src/comm/UDPLink.h
View file @
06ae441e
...
...
@@ -37,6 +37,10 @@ This file is part of the QGROUNDCONTROL project
#include <QMutex>
#include <QUdpSocket>
#if defined(QGC_ZEROCONF_ENABLED)
#include <dns_sd.h>
#endif
#include "QGCConfig.h"
#include "LinkManager.h"
...
...
@@ -201,6 +205,13 @@ private:
bool
_hardwareConnect
();
void
_restartConnection
();
void
_registerZeroconf
(
uint16_t
port
,
const
std
::
string
&
regType
);
void
_deregisterZeroconf
();
#if defined(QGC_ZEROCONF_ENABLED)
DNSServiceRef
_dnssServiceRef
;
#endif
signals:
//Signals are defined by LinkInterface
...
...
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