Fix GPS modem selection and add a GPS-only time source

This commit is contained in:
Luxferre committed 2026-11-10 13:18:14 +02:00
1 parent eaf08abcd4
commit a50c01b416
18 files changed
+682 -16

No files matched your search

+26 -8
View File
@@ -1,24 +1,36 @@
#!/bin/sh
# Bananarchy GPS reception & coordinate detection CLI utility
# Queries Qualcomm QDSP6 / ModemManager GNSS (gps-nmea + gps-raw + 3gpp-lac-ci).
# The modem path is resolved by bananarchy-gps-modem.sh: "mmcli -m any" can
# pick the wrong modem (or fail) on the dual-SIM 2720 Flip.
set -u
ACTION="${1:-status}"
MMCLI="${BANANARCHY_MMCLI:-/usr/bin/mmcli}"
GPS_MODEM="${BANANARCHY_GPS_MODEM:-/usr/bin/bananarchy-gps-modem.sh}"
modem_path() {
m="$("$GPS_MODEM" path 2>/dev/null | head -n1)"
case "$m" in ''|*[!0-9a-zA-Z/_-]*) m=any ;; esac
printf '%s\n' "$m"
}
enable_gps() {
mmcli -m any --location-enable-gps-nmea --location-enable-gps-raw >/dev/null 2>&1 || true
mmcli -m any --location-set-gps-refresh-rate=2 >/dev/null 2>&1 || true
"$GPS_MODEM" enable >/dev/null 2>&1 || true
}
disable_gps() {
mmcli -m any --location-disable-gps-nmea --location-disable-gps-raw >/dev/null 2>&1 || true
"$GPS_MODEM" disable >/dev/null 2>&1 || true
}
print_status() {
enable_gps
RAW="$(mmcli -m any -K --location-get 2>/dev/null)"
m="$(modem_path)"
RAW="$("$MMCLI" -m "$m" -K --location-get 2>/dev/null)"
if [ -z "$RAW" ]; then
echo "GPS Status: Modem not ready"
exit 1
echo "GPS Status: Modem not ready (modem=$m)"
"$GPS_MODEM" status 2>/dev/null || true
return 1
fi
MCC="$(printf '%s\n' "$RAW" | awk -F': ' '/location\.3gpp\.mcc/{print $2}')"
MNC="$(printf '%s\n' "$RAW" | awk -F': ' '/location\.3gpp\.mnc/{print $2}')"
@@ -29,6 +41,7 @@ print_status() {
ALT="$(printf '%s\n' "$RAW" | awk -F': ' '/location\.gps\.altitude/{print $2}')"
UTC="$(printf '%s\n' "$RAW" | awk -F': ' '/location\.gps\.utc/{print $2}')"
echo "=== Bananarchy GNSS / GPS Reception Status ==="
echo "Modem : $m"
echo "3GPP Cell : MCC=${MCC:--} MNC=${MNC:--} TAC=${TAC:--} CID=${CID:--}"
echo "GPS Fix : Lat=${LAT:---} Lon=${LON:---} Alt=${ALT:---}m UTC=${UTC:---}"
echo "--- NMEA Sentences ---"
@@ -38,7 +51,7 @@ print_status() {
case "$ACTION" in
enable)
enable_gps
echo "GPS enabled (2s refresh)"
echo "GPS enabled on $(modem_path) (2s refresh)"
;;
disable)
disable_gps
@@ -46,7 +59,8 @@ case "$ACTION" in
;;
nmea)
enable_gps
mmcli -m any -K --location-get 2>/dev/null | awk -F': ' '/location\.gps\.nmea\.value/{print $2}'
"$MMCLI" -m "$(modem_path)" -K --location-get 2>/dev/null |
awk -F': ' '/location\.gps\.nmea\.value/{print $2}'
;;
watch)
enable_gps
@@ -59,7 +73,11 @@ case "$ACTION" in
gui|open)
exec xgps
;;
modem|status-detail)
"$GPS_MODEM" status
;;
status|test|*)
print_status
;;
esac
exit 0