Add gpsd support to portduino/native (#10781)

* Add gpsd support to portduino

* copilot fixes

* emit gps config in emit_yaml

* Fix formating to standard

* Address coderabitai issues

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
jessm33
2026-06-30 14:44:36 -05:00
committed by GitHub
co-authored by Ben Meadors Jonathan Bennett
parent 23bb55d965
commit 2fdb722e00
7 changed files with 246 additions and 4 deletions
+13 -2
View File
@@ -25,6 +25,7 @@
#include "ubx.h"
#ifdef ARCH_PORTDUINO
#include "GpsdSerial.h"
#include "PortduinoGlue.h"
#include "meshUtils.h"
#include <algorithm>
@@ -97,8 +98,9 @@ struct GPSProbeCacheRecord {
bool isValidGnssModel(uint8_t model)
{
// Keep persisted values bounded to known enum range.
return model <= static_cast<uint8_t>(GNSS_MODEL_CM121);
// Only real chip identifiers belong in the probe cache.
// GNSS_MODEL_UNKNOWN and GNSS_MODEL_GENERIC_NMEA are runtime-only values.
return model != static_cast<uint8_t>(GNSS_MODEL_UNKNOWN) && model < static_cast<uint8_t>(GNSS_MODEL_GENERIC_NMEA);
}
bool isValidProbeBaud(uint32_t baud)
@@ -1901,6 +1903,10 @@ std::unique_ptr<GPS> GPS::createGps()
// They are not used for any hardware access.
_rx_gpio = 1;
_tx_gpio = 1;
if (!portduino_config.gpsd_host.empty()) {
gpsdSerial.setAddress(portduino_config.gpsd_host, portduino_config.gpsd_port);
_serial_gps = &gpsdSerial;
}
} else
return nullptr;
#endif
@@ -1910,6 +1916,11 @@ std::unique_ptr<GPS> GPS::createGps()
auto new_gps = std::unique_ptr<GPS>(new GPS());
new_gps->rx_gpio = _rx_gpio;
new_gps->tx_gpio = _tx_gpio;
#ifdef ARCH_PORTDUINO
// Skip chip-specific probing for gpsd — it's a generic NMEA stream.
if (!portduino_config.gpsd_host.empty())
new_gps->gnssModel = GNSS_MODEL_GENERIC_NMEA;
#endif
GpioVirtPin *virtPin = new GpioVirtPin();
new_gps->enablePin = virtPin; // Always at least populate a virtual pin
+2 -1
View File
@@ -42,7 +42,8 @@ typedef enum {
GNSS_MODEL_AG3335,
GNSS_MODEL_AG3352,
GNSS_MODEL_LS20031,
GNSS_MODEL_CM121
GNSS_MODEL_CM121,
GNSS_MODEL_GENERIC_NMEA // generic NMEA source (e.g. gpsd); skips chip-specific probe and init
} GnssModel_t;
typedef enum {