Commit 7c4d31e5 authored by Willian Galvani's avatar Willian Galvani

LinkManager.cc: Add udp link to groundstation position

parent d1db6938
...@@ -479,6 +479,27 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -479,6 +479,27 @@ void LinkManager::_updateAutoConnectLinks(void)
createConnectedLink(config); createConnectedLink(config);
emit linkConfigurationsChanged(); emit linkConfigurationsChanged();
} }
#ifndef __mobile__
// check to see if nmea gps is configured for UDP input, if so, set it up to connect
if (_autoConnectSettings->autoConnectNmeaPort()->cookedValueString() == "UDP Port") {
if (_nmeaSocket.localPort() != _autoConnectSettings->nmeaUdpPort()->rawValue().toUInt()
|| _nmeaSocket.state() != UdpIODevice::BoundState) {
qCDebug(LinkManagerLog) << "Changing port for UDP NMEA stream";
_nmeaSocket.close();
_nmeaSocket.bind(QHostAddress::AnyIPv4, _autoConnectSettings->nmeaUdpPort()->rawValue().toUInt());
_toolbox->qgcPositionManager()->setNmeaSourceDevice(&_nmeaSocket);
}
//close serial port
if (_nmeaPort) {
_nmeaPort->close();
delete _nmeaPort;
_nmeaPort = nullptr;
_nmeaDeviceName = "";
}
} else {
_nmeaSocket.close();
}
#endif
#ifndef NO_SERIAL_LINK #ifndef NO_SERIAL_LINK
QStringList currentPorts; QStringList currentPorts;
...@@ -513,6 +534,7 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -513,6 +534,7 @@ void LinkManager::_updateAutoConnectLinks(void)
#ifndef NO_SERIAL_LINK #ifndef NO_SERIAL_LINK
#ifndef __mobile__ #ifndef __mobile__
// check to see if nmea gps is configured for current Serial port, if so, set it up to connect
if (portInfo.systemLocation().trimmed() == _autoConnectSettings->autoConnectNmeaPort()->cookedValueString()) { if (portInfo.systemLocation().trimmed() == _autoConnectSettings->autoConnectNmeaPort()->cookedValueString()) {
if (portInfo.systemLocation().trimmed() != _nmeaDeviceName) { if (portInfo.systemLocation().trimmed() != _nmeaDeviceName) {
_nmeaDeviceName = portInfo.systemLocation().trimmed(); _nmeaDeviceName = portInfo.systemLocation().trimmed();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
#if !defined(__mobile__) #if !defined(__mobile__)
#include "LogReplayLink.h" #include "LogReplayLink.h"
#include "UdpIODevice.h"
#endif #endif
#include "QmlObjectListModel.h" #include "QmlObjectListModel.h"
...@@ -241,6 +242,7 @@ private: ...@@ -241,6 +242,7 @@ private:
QString _nmeaDeviceName; QString _nmeaDeviceName;
QSerialPort* _nmeaPort; QSerialPort* _nmeaPort;
uint32_t _nmeaBaud; uint32_t _nmeaBaud;
UdpIODevice _nmeaSocket;
#endif #endif
#endif #endif
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment