Fix GPS modem selection and add a GPS-only time source
This commit is contained in:
1 parent
eaf08abcd4
commit
a50c01b416
18 files changed
+682
-16
No files matched your search
@@ -163,8 +163,26 @@ std::vector<std::string> splitCsv(const std::string& s) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// "mmcli -m any" is ambiguous on dual-SIM QMI targets such as the 2720 Flip:
|
||||
// ModemManager can resolve the wrong modem or reject the query outright. The
|
||||
// helper picks the modem that advertises the gps-nmea capability and falls
|
||||
// back to "any" when no modem is enumerated yet.
|
||||
std::string gpsModemArg() {
|
||||
static std::string cached;
|
||||
if (cached.empty()) {
|
||||
std::string path = trimStr(runCaptureCmd(
|
||||
"/usr/bin/bananarchy-gps-modem.sh path 2>/dev/null"));
|
||||
if (path.rfind("/org/freedesktop/ModemManager1/Modem/", 0) == 0)
|
||||
cached = "-m " + shellQuote(path);
|
||||
else
|
||||
cached = "-m any";
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
void pollModemGpsStatus(GpsStatus& st) {
|
||||
std::string raw = runCaptureCmd("mmcli -m any -K --location-get 2>/dev/null");
|
||||
std::string raw = runCaptureCmd(
|
||||
"mmcli " + gpsModemArg() + " -K --location-get 2>/dev/null");
|
||||
if (raw.empty()) return;
|
||||
|
||||
st.rawNmea.clear();
|
||||
@@ -559,7 +577,8 @@ int gps_run_main(int argc, char** argv) {
|
||||
else if (std::strcmp(argv[i], "--test") == 0) {
|
||||
// CLI GPS test mode
|
||||
GpsStatus st;
|
||||
runAsyncCmd("mmcli -m any --location-enable-gps-nmea --location-enable-gps-raw >/dev/null 2>&1");
|
||||
runAsyncCmd(std::string("/usr/bin/bananarchy-gps-modem.sh enable >/dev/null 2>&1; ") +
|
||||
"mmcli " + gpsModemArg() + " --location-enable-3gpp >/dev/null 2>&1");
|
||||
::usleep(300000);
|
||||
pollModemGpsStatus(st);
|
||||
std::printf("Fix: %s (%dD) Sats: %d/%d HDOP: %.1f UTC: %s\n",
|
||||
@@ -632,8 +651,11 @@ int gps_run_main(int argc, char** argv) {
|
||||
if (!gps.gpsEnabled) {
|
||||
gps.gpsEnabled = true;
|
||||
runAsyncCmd(
|
||||
"mmcli -m any --location-enable-gps-nmea --location-enable-gps-raw >/dev/null 2>&1; "
|
||||
"mmcli -m any --location-set-gps-refresh-rate=2 >/dev/null 2>&1");
|
||||
"mmcli " + gpsModemArg() +
|
||||
" --location-enable-gps-nmea --location-enable-gps-raw "
|
||||
"--location-enable-3gpp >/dev/null 2>&1; "
|
||||
"mmcli " + gpsModemArg() +
|
||||
" --location-set-gps-refresh-rate=2 >/dev/null 2>&1");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -641,7 +663,8 @@ int gps_run_main(int argc, char** argv) {
|
||||
if (gps.gpsEnabled && !keepGpsInBg) {
|
||||
gps.gpsEnabled = false;
|
||||
runAsyncCmd(
|
||||
"mmcli -m any --location-disable-gps-nmea --location-disable-gps-raw >/dev/null 2>&1");
|
||||
"mmcli " + gpsModemArg() +
|
||||
" --location-disable-gps-nmea --location-disable-gps-raw >/dev/null 2>&1");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user