PositionManager/LinkManager: fall back to internal GPS when NMEA disabled#14588
PositionManager/LinkManager: fall back to internal GPS when NMEA disabled#14588julianoes wants to merge 1 commit into
Conversation
Selecting Disabled (or otherwise switching off NMEA) in the Comm Links NMEA GPS section closed the UDP socket but left QGCPositionManager stuck on the now-dead NMEA source, so the GCS position froze and there was no way back to the device's own GPS. Add QGCPositionManager::resetNmeaSourceDevice() which tears down the NMEA source and, if it was active, reverts to the default/internal position source (e.g. the integrated Android GPS). Call it from LinkManager when NMEA is no longer configured, and also tear down a lingering serial NMEA port in that case.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (30.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #14588 +/- ##
==========================================
+ Coverage 25.47% 30.63% +5.16%
==========================================
Files 769 785 +16
Lines 65912 66796 +884
Branches 30495 30946 +451
==========================================
+ Hits 16788 20466 +3678
+ Misses 37285 32386 -4899
- Partials 11839 13944 +2105
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 434 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Build ResultsPlatform Status
All builds passed. Pre-commit
Pre-commit hooks: 0 passed, 0 failed, 0 skipped. Test Resultslinux-coverage-integration: 25 passed, 0 skipped Code CoverageCoverage: 66.3% No baseline available for comparison Artifact Sizes
Updated: 2026-07-06 03:23:40 UTC • Commit: 6da033d • Triggered by: Android |
There was a problem hiding this comment.
Pull request overview
This PR fixes a user-visible failure mode where disabling the NMEA GPS input (e.g. setting Disabled in Comm Links) closes the NMEA UDP socket but leaves QGCPositionManager stuck on the now-dead NMEA source, freezing the displayed GCS position. It adds an explicit teardown path for the NMEA position source and wires LinkManager to invoke it when NMEA is no longer configured.
Changes:
- Add
QGCPositionManager::resetNmeaSourceDevice()to tear down an activeQNmeaPositionInfoSourceand (when appropriate) fall back to the platform default position source. - Update
LinkManager::_updateAutoConnectLinks()to reset the position manager when NMEA is switched off and to clean up a lingering serial NMEA port.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/PositionManager/PositionManager.h | Declares resetNmeaSourceDevice() API for tearing down the NMEA source. |
| src/PositionManager/PositionManager.cpp | Implements NMEA source teardown and fallback behavior. |
| src/Comms/LinkManager.cc | Calls the new reset method when NMEA is disabled and cleans up NMEA serial resources. |
| } else { | ||
| _nmeaSocket->close(); | ||
| #ifndef QGC_NO_SERIAL_LINK | ||
| // NMEA was switched off (e.g. back to "Disabled"): also tear down any serial NMEA port | ||
| if (_nmeaPort) { | ||
| _nmeaPort->close(); | ||
| delete _nmeaPort; | ||
| _nmeaPort = nullptr; | ||
| _nmeaDeviceName = ""; | ||
| } | ||
| #endif | ||
| // Revert QGCPositionManager to the integrated GPS if it was using an NMEA source | ||
| QGCPositionManager::instance()->resetNmeaSourceDevice(); | ||
| } |
| void QGCPositionManager::resetNmeaSourceDevice() | ||
| { | ||
| if (!_nmeaSource) { | ||
| return; | ||
| } | ||
|
|
||
| const bool wasCurrent = (_currentSource == _nmeaSource); | ||
|
|
||
| _nmeaSource->stopUpdates(); | ||
| (void) disconnect(_nmeaSource); | ||
| if (wasCurrent) { | ||
| // Clear so _setPositionSource() doesn't try to touch the source we're about to delete | ||
| _currentSource = nullptr; | ||
| } | ||
|
|
||
| delete _nmeaSource; | ||
| _nmeaSource = nullptr; | ||
|
|
||
| if (wasCurrent) { | ||
| // Fall back to the platform's default position source (e.g. the integrated Android GPS) | ||
| _setPositionSource(QGCPositionManager::InternalGPS); | ||
| } | ||
| } |
|
@julianoes Can you address the review. I believe both of these are correct from a bug standpoint |
Switching NMEA off (e.g. Disabled in Comm Links) closed the UDP socket but left
QGCPositionManageron the dead NMEA source, freezing the GCS position with no way back to the built-in GPS.Add
QGCPositionManager::resetNmeaSourceDevice()to tear down the NMEA source and, if active, revert to the platform default (e.g. integrated Android GPS).LinkManagercalls it when NMEA is no longer configured, and also tears down a lingering serial NMEA port there.