Commit 6966133c authored by DonLakeFlyer's avatar DonLakeFlyer Committed by Don Gagne

Allow disconnect/reconnect of RTK GPS

parent 08deff4b
...@@ -23,14 +23,14 @@ GPSManager::GPSManager(QGCApplication* app, QGCToolbox* toolbox) ...@@ -23,14 +23,14 @@ GPSManager::GPSManager(QGCApplication* app, QGCToolbox* toolbox)
GPSManager::~GPSManager() GPSManager::~GPSManager()
{ {
cleanup(); disconnectGPS();
} }
void GPSManager::connectGPS(const QString& device) void GPSManager::connectGPS(const QString& device)
{ {
RTKSettings* rtkSettings = qgcApp()->toolbox()->settingsManager()->rtkSettings(); RTKSettings* rtkSettings = qgcApp()->toolbox()->settingsManager()->rtkSettings();
cleanup(); disconnectGPS();
_requestGpsStop = false; _requestGpsStop = false;
_gpsProvider = new GPSProvider(device, true, rtkSettings->surveyInAccuracyLimit()->rawValue().toDouble(), rtkSettings->surveyInMinObservationDuration()->rawValue().toInt(), _requestGpsStop); _gpsProvider = new GPSProvider(device, true, rtkSettings->surveyInAccuracyLimit()->rawValue().toDouble(), rtkSettings->surveyInMinObservationDuration()->rawValue().toInt(), _requestGpsStop);
_gpsProvider->start(); _gpsProvider->start();
...@@ -49,17 +49,7 @@ void GPSManager::connectGPS(const QString& device) ...@@ -49,17 +49,7 @@ void GPSManager::connectGPS(const QString& device)
emit onConnect(); emit onConnect();
} }
void GPSManager::GPSPositionUpdate(GPSPositionMessage msg) void GPSManager::disconnectGPS(void)
{
qCDebug(RTKGPSLog) << QString("GPS: got position update: alt=%1, long=%2, lat=%3").arg(msg.position_data.alt).arg(msg.position_data.lon).arg(msg.position_data.lat);
}
void GPSManager::GPSSatelliteUpdate(GPSSatelliteMessage msg)
{
qCDebug(RTKGPSLog) << QString("GPS: got satellite info update, %1 satellites").arg((int)msg.satellite_data.count);
emit satelliteUpdate(msg.satellite_data.count);
}
void GPSManager::cleanup()
{ {
if (_gpsProvider) { if (_gpsProvider) {
_requestGpsStop = true; _requestGpsStop = true;
...@@ -72,4 +62,17 @@ void GPSManager::cleanup() ...@@ -72,4 +62,17 @@ void GPSManager::cleanup()
if (_rtcmMavlink) { if (_rtcmMavlink) {
delete(_rtcmMavlink); delete(_rtcmMavlink);
} }
_gpsProvider = NULL;
_rtcmMavlink = NULL;
}
void GPSManager::GPSPositionUpdate(GPSPositionMessage msg)
{
qCDebug(RTKGPSLog) << QString("GPS: got position update: alt=%1, long=%2, lat=%3").arg(msg.position_data.alt).arg(msg.position_data.lon).arg(msg.position_data.lat);
}
void GPSManager::GPSSatelliteUpdate(GPSSatelliteMessage msg)
{
qCDebug(RTKGPSLog) << QString("GPS: got satellite info update, %1 satellites").arg((int)msg.satellite_data.count);
emit satelliteUpdate(msg.satellite_data.count);
} }
...@@ -28,8 +28,9 @@ public: ...@@ -28,8 +28,9 @@ public:
GPSManager(QGCApplication* app, QGCToolbox* toolbox); GPSManager(QGCApplication* app, QGCToolbox* toolbox);
~GPSManager(); ~GPSManager();
void connectGPS(const QString& device); void connectGPS (const QString& device);
bool connected(void) const { return _gpsProvider && _gpsProvider->isRunning(); } void disconnectGPS (void);
bool connected (void) const { return _gpsProvider && _gpsProvider->isRunning(); }
signals: signals:
void onConnect(); void onConnect();
...@@ -40,9 +41,8 @@ signals: ...@@ -40,9 +41,8 @@ signals:
private slots: private slots:
void GPSPositionUpdate(GPSPositionMessage msg); void GPSPositionUpdate(GPSPositionMessage msg);
void GPSSatelliteUpdate(GPSSatelliteMessage msg); void GPSSatelliteUpdate(GPSSatelliteMessage msg);
private:
void cleanup();
private:
GPSProvider* _gpsProvider = nullptr; GPSProvider* _gpsProvider = nullptr;
RTCMMavlink* _rtcmMavlink = nullptr; RTCMMavlink* _rtcmMavlink = nullptr;
......
...@@ -507,7 +507,7 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -507,7 +507,7 @@ void LinkManager::_updateAutoConnectLinks(void)
continue; continue;
} }
if (_autoconnectConfigurationsContainsPort(portInfo.systemLocation())) { if (_autoconnectConfigurationsContainsPort(portInfo.systemLocation()) || _autoConnectRTKPort == portInfo.systemLocation()) {
qCDebug(LinkManagerVerboseLog) << "Skipping existing autoconnect" << portInfo.systemLocation(); qCDebug(LinkManagerVerboseLog) << "Skipping existing autoconnect" << portInfo.systemLocation();
} else if (!_autoconnectWaitList.contains(portInfo.systemLocation())) { } else if (!_autoconnectWaitList.contains(portInfo.systemLocation())) {
// We don't connect to the port the first time we see it. The ability to correctly detect whether we // We don't connect to the port the first time we see it. The ability to correctly detect whether we
...@@ -545,7 +545,8 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -545,7 +545,8 @@ void LinkManager::_updateAutoConnectLinks(void)
#ifndef __mobile__ #ifndef __mobile__
case QGCSerialPortInfo::BoardTypeRTKGPS: case QGCSerialPortInfo::BoardTypeRTKGPS:
if (_autoConnectSettings->autoConnectRTKGPS()->rawValue().toBool() && !_toolbox->gpsManager()->connected()) { if (_autoConnectSettings->autoConnectRTKGPS()->rawValue().toBool() && !_toolbox->gpsManager()->connected()) {
qCDebug(LinkManagerLog) << "RTK GPS auto-connected"; qCDebug(LinkManagerLog) << "RTK GPS auto-connected" << portInfo.portName().trimmed();
_autoConnectRTKPort = portInfo.systemLocation();
_toolbox->gpsManager()->connectGPS(portInfo.systemLocation()); _toolbox->gpsManager()->connectGPS(portInfo.systemLocation());
} }
break; break;
...@@ -610,6 +611,14 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -610,6 +611,14 @@ void LinkManager::_updateAutoConnectLinks(void)
} }
} }
} }
// Check for RTK GPS connection gone
if (!_autoConnectRTKPort.isEmpty() && !currentPorts.contains(_autoConnectRTKPort)) {
qCDebug(LinkManagerLog) << "RTK GPS disconnected" << _autoConnectRTKPort;
_toolbox->gpsManager()->disconnectGPS();
_autoConnectRTKPort.clear();
}
#endif #endif
#endif // NO_SERIAL_LINK #endif // NO_SERIAL_LINK
} }
......
...@@ -217,6 +217,7 @@ private: ...@@ -217,6 +217,7 @@ private:
QList<SharedLinkInterfacePointer> _sharedLinks; QList<SharedLinkInterfacePointer> _sharedLinks;
QList<SharedLinkConfigurationPointer> _sharedConfigurations; QList<SharedLinkConfigurationPointer> _sharedConfigurations;
QList<SharedLinkConfigurationPointer> _sharedAutoconnectConfigurations; QList<SharedLinkConfigurationPointer> _sharedAutoconnectConfigurations;
QString _autoConnectRTKPort;
QmlObjectListModel _qmlConfigurations; QmlObjectListModel _qmlConfigurations;
QMap<QString, int> _autoconnectWaitList; ///< key: QGCSerialPortInfo.systemLocation, value: wait count QMap<QString, int> _autoconnectWaitList; ///< key: QGCSerialPortInfo.systemLocation, value: wait count
......
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