@@ -410,80 +410,6 @@ void LinkManager::_addMAVLinkForwardingLink()
410
410
_createDynamicForwardLink (_mavlinkForwardingLinkName, hostName);
411
411
}
412
412
413
- #ifdef QGC_ZEROCONF_ENABLED
414
- void LinkManager::_addZeroConfAutoConnectLink ()
415
- {
416
- if (!_autoConnectSettings->autoConnectZeroConf ()->rawValue ().toBool ()) {
417
- return ;
418
- }
419
-
420
- static QSharedPointer<QMdnsEngine::Server> server;
421
- static QSharedPointer<QMdnsEngine::Browser> browser;
422
- server.reset (new QMdnsEngine::Server ());
423
- browser.reset (new QMdnsEngine::Browser (server.get (), QMdnsEngine::MdnsBrowseType));
424
-
425
- const auto checkIfConnectionLinkExist = [this ](LinkConfiguration::LinkType linkType, const QString &linkName) {
426
- for (const SharedLinkInterfacePtr &link : std::as_const (_rgLinks)) {
427
- const SharedLinkConfigurationPtr linkConfig = link->linkConfiguration ();
428
- if ((linkConfig->type () == linkType) && (linkConfig->name () == linkName)) {
429
- return true ;
430
- }
431
- }
432
-
433
- return false ;
434
- };
435
-
436
- (void ) connect (browser.get (), &QMdnsEngine::Browser::serviceAdded, this , [checkIfConnectionLinkExist, this ](const QMdnsEngine::Service &service) {
437
- qCDebug (LinkManagerLog) << " Found Zero-Conf:" << service.type () << service.name () << service.hostname () << service.port () << service.attributes ();
438
-
439
- if (!service.type ().startsWith (" _mavlink" )) {
440
- qCWarning (LinkManagerLog) << " Invalid ZeroConf SericeType" << service.type ();
441
- return ;
442
- }
443
-
444
- // Windows doesnt accept trailling dots in mdns
445
- // http://www.dns-sd.org/trailingdotsindomainnames.html
446
- QString hostname = service.hostname ();
447
- if (hostname.endsWith (' .' )) {
448
- hostname.chop (1 );
449
- }
450
-
451
- if (service.type ().startsWith (" _mavlink._udp" )) {
452
- static const QString udpName = QStringLiteral (" ZeroConf UDP" );
453
- if (checkIfConnectionLinkExist (LinkConfiguration::TypeUdp, udpName)) {
454
- qCDebug (LinkManagerLog) << " Connection already exist" ;
455
- return ;
456
- }
457
-
458
- UDPConfiguration *const link = new UDPConfiguration (udpName);
459
- link->addHost (hostname, service.port ());
460
- link->setAutoConnect (true );
461
- link->setDynamic (true );
462
- SharedLinkConfigurationPtr config = addConfiguration (link);
463
- if (!createConnectedLink (config)) {
464
- qCWarning (LinkManagerLog) << " Failed to create" << udpName;
465
- }
466
- } else if (service.type ().startsWith (" _mavlink._tcp" )) {
467
- static QString tcpName = QStringLiteral (" ZeroConf TCP" );
468
- if (checkIfConnectionLinkExist (LinkConfiguration::TypeTcp, tcpName)) {
469
- qCDebug (LinkManagerLog) << " Connection already exist" ;
470
- return ;
471
- }
472
-
473
- TCPConfiguration *const link = new TCPConfiguration (tcpName);
474
- link->setHost (hostname);
475
- link->setPort (service.port ());
476
- link->setAutoConnect (true );
477
- link->setDynamic (true );
478
- SharedLinkConfigurationPtr config = addConfiguration (link);
479
- if (!createConnectedLink (config)) {
480
- qCWarning (LinkManagerLog) << " Failed to create" << tcpName;
481
- }
482
- }
483
- });
484
- }
485
- #endif
486
-
487
413
void LinkManager::_updateAutoConnectLinks ()
488
414
{
489
415
if (_connectionsSuspended) {
@@ -744,6 +670,89 @@ void LinkManager::_createDynamicForwardLink(const char *linkName, const QString
744
670
qCDebug (LinkManagerLog) << " New dynamic MAVLink forwarding port added:" << linkName << " hostname:" << hostName;
745
671
}
746
672
673
+ void LinkManager::resetMavlinkSigning ()
674
+ {
675
+ for (const SharedLinkInterfacePtr &sharedLink: _rgLinks) {
676
+ sharedLink->initMavlinkSigning ();
677
+ }
678
+ }
679
+
680
+ #ifdef QGC_ZEROCONF_ENABLED
681
+
682
+ void LinkManager::_addZeroConfAutoConnectLink ()
683
+ {
684
+ if (!_autoConnectSettings->autoConnectZeroConf ()->rawValue ().toBool ()) {
685
+ return ;
686
+ }
687
+
688
+ static QSharedPointer<QMdnsEngine::Server> server;
689
+ static QSharedPointer<QMdnsEngine::Browser> browser;
690
+ server.reset (new QMdnsEngine::Server ());
691
+ browser.reset (new QMdnsEngine::Browser (server.get (), QMdnsEngine::MdnsBrowseType));
692
+
693
+ const auto checkIfConnectionLinkExist = [this ](LinkConfiguration::LinkType linkType, const QString &linkName) {
694
+ for (const SharedLinkInterfacePtr &link : std::as_const (_rgLinks)) {
695
+ const SharedLinkConfigurationPtr linkConfig = link->linkConfiguration ();
696
+ if ((linkConfig->type () == linkType) && (linkConfig->name () == linkName)) {
697
+ return true ;
698
+ }
699
+ }
700
+
701
+ return false ;
702
+ };
703
+
704
+ (void ) connect (browser.get (), &QMdnsEngine::Browser::serviceAdded, this , [checkIfConnectionLinkExist, this ](const QMdnsEngine::Service &service) {
705
+ qCDebug (LinkManagerLog) << " Found Zero-Conf:" << service.type () << service.name () << service.hostname () << service.port () << service.attributes ();
706
+
707
+ if (!service.type ().startsWith (" _mavlink" )) {
708
+ qCWarning (LinkManagerLog) << " Invalid ZeroConf SericeType" << service.type ();
709
+ return ;
710
+ }
711
+
712
+ // Windows doesnt accept trailling dots in mdns
713
+ // http://www.dns-sd.org/trailingdotsindomainnames.html
714
+ QString hostname = service.hostname ();
715
+ if (hostname.endsWith (' .' )) {
716
+ hostname.chop (1 );
717
+ }
718
+
719
+ if (service.type ().startsWith (" _mavlink._udp" )) {
720
+ static const QString udpName = QStringLiteral (" ZeroConf UDP" );
721
+ if (checkIfConnectionLinkExist (LinkConfiguration::TypeUdp, udpName)) {
722
+ qCDebug (LinkManagerLog) << " Connection already exist" ;
723
+ return ;
724
+ }
725
+
726
+ UDPConfiguration *const link = new UDPConfiguration (udpName);
727
+ link->addHost (hostname, service.port ());
728
+ link->setAutoConnect (true );
729
+ link->setDynamic (true );
730
+ SharedLinkConfigurationPtr config = addConfiguration (link);
731
+ if (!createConnectedLink (config)) {
732
+ qCWarning (LinkManagerLog) << " Failed to create" << udpName;
733
+ }
734
+ } else if (service.type ().startsWith (" _mavlink._tcp" )) {
735
+ static QString tcpName = QStringLiteral (" ZeroConf TCP" );
736
+ if (checkIfConnectionLinkExist (LinkConfiguration::TypeTcp, tcpName)) {
737
+ qCDebug (LinkManagerLog) << " Connection already exist" ;
738
+ return ;
739
+ }
740
+
741
+ TCPConfiguration *const link = new TCPConfiguration (tcpName);
742
+ link->setHost (hostname);
743
+ link->setPort (service.port ());
744
+ link->setAutoConnect (true );
745
+ link->setDynamic (true );
746
+ SharedLinkConfigurationPtr config = addConfiguration (link);
747
+ if (!createConnectedLink (config)) {
748
+ qCWarning (LinkManagerLog) << " Failed to create" << tcpName;
749
+ }
750
+ }
751
+ });
752
+ }
753
+
754
+ #endif // QGC_ZEROCONF_ENABLED
755
+
747
756
bool LinkManager::isLinkUSBDirect (const LinkInterface *link)
748
757
{
749
758
#ifndef QGC_NO_SERIAL_LINK
@@ -766,14 +775,18 @@ bool LinkManager::isLinkUSBDirect(const LinkInterface *link)
766
775
return false ;
767
776
}
768
777
769
- void LinkManager::resetMavlinkSigning ()
778
+ #ifndef QGC_NO_SERIAL_LINK // Serial Only Functions
779
+
780
+ bool LinkManager::_isSerialPortConnected () const
770
781
{
771
- for (const SharedLinkInterfacePtr &sharedLink: _rgLinks) {
772
- sharedLink->initMavlinkSigning ();
782
+ for (const SharedLinkInterfacePtr &link: _rgLinks) {
783
+ if (qobject_cast<const SerialLink*>(link.get ())) {
784
+ return true ;
785
+ }
773
786
}
774
- }
775
787
776
- #ifndef QGC_NO_SERIAL_LINK // Serial Only Functions
788
+ return false ;
789
+ }
777
790
778
791
void LinkManager::_filterCompositePorts (QList<QGCSerialPortInfo> &portList)
779
792
{
@@ -997,15 +1010,4 @@ QStringList LinkManager::serialBaudRates()
997
1010
return SerialConfiguration::supportedBaudRates ();
998
1011
}
999
1012
1000
- bool LinkManager::_isSerialPortConnected () const
1001
- {
1002
- for (const SharedLinkInterfacePtr &link: _rgLinks) {
1003
- if (qobject_cast<const SerialLink*>(link.get ())) {
1004
- return true ;
1005
- }
1006
- }
1007
-
1008
- return false ;
1009
- }
1010
-
1011
1013
#endif // QGC_NO_SERIAL_LINK
0 commit comments