Commit Graph
19 Commits
Author SHA1 Message Date
Andrey Skvortsov c0f0c02ac1 tests: add tests for location-cache
only GGA NMEA sentences are supported by current implementation of
MMLocationGpsRaw. RMC and GLL messages are added, but currently test
are negative.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov 8b6116fe6c shared-qmi: handle inject position requests from the modem
To be able to have quick position fix GNSS engine needs to know
 - predicted orbits data,
 - current time,
 - approximate position.
Modem sends indications with requests, when it needs corresponding
information. Predicted orbits can be injected using
'mmcli -m any --location-inject-assistance-data=<file>'. But to
accelerate time to first fix after cold start extra information is
needed like time and coarse position.

Inject position requests are received, when GPS session is initiated
using QMI_LOC_START. In inject position request modem sends
information about its last known position. If last known position is
zero, when this is a cold start and inject position is needed to
improve TTFF.
Last position from the modem is cached in ModemManager and is injected
next time, when modem requests it. For example, if modem is restarted.

When timestamp on injected position is too old, than position is
ignored and location engine does cold start. Therefore current time is
used for injected position.

When injected position is far away the actual one (for example, after
flight), after some time location engine falls back to cold start.

Tested on Quectel EG25-G.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov a108a0fe7c build: Fix meson deprecation warnings
following warnings are fixed:
Dependency udev found: YES 258 (cached)
../meson.build:202: WARNING: Project targets '>= 0.60.0' but uses
   feature deprecated since '0.56.0':
   dependency.get_pkgconfig_variable. use
   dependency.get_variable(pkgconfig : ...) instead
Dependency systemd found: YES 258 (cached)
../meson.build:212: WARNING: Project targets '>= 0.60.0' but uses
   feature deprecated since '0.56.0':
   dependency.get_pkgconfig_variable. use
   dependency.get_variable(pkgconfig : ...) instead
Dependency libsystemd found: YES 258 (cached)
Dependency polkit-gobject-1 found: YES 126 (cached)
../meson.build:245: WARNING: Project targets '>= 0.60.0' but uses
   feature deprecated since '0.56.0':
   dependency.get_pkgconfig_variable. use
   dependency.get_variable(pkgconfig : ...) instead
Dependency mbim-glib found: YES 1.32.0 (cached)
Dependency qmi-glib found: YES 1.37.1 (cached)
../meson.build:302: WARNING: Project targets '>= 0.60.0' but uses
   feature deprecated since '0.56.0':
   dependency.get_pkgconfig_variable. use
   dependency.get_variable(pkgconfig : ...) instead

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov 8ac3dfb955 location-cache: add class to store cached location
This class allows to preserve cached position across ModemManager restarts.
Cached location can be used to improve time to first fix after device
start by injecting coarse position into location engine. Since there
wasn't any fix yet, position in ModemManager is unknown. To fix this
cached location is saved on disk (/var/lib/ModemManager/location.ini)
when location session is stopped or ModemManager is stopped and loaded
on the next start from the file.

install_emptydir is introduced in meson 0.60.

Distributions has to create directory to store cached location in
packaging, because ModemManager runs under systemd isolation with
limited rights and it can't create this directory by itself.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov 81101b0147 shared-qmi: handle inject time requests from the modem
To be able to have quick position fix GNSS engine needs to know
 - predicted orbits data,
 - current time,
 - approximate position.
Modem sends indications with requests, when it needs corresponding
information. Predicted orbits can be injected using
'mmcli -m any --location-inject-assistance-data=<file>'. But to
accelerate time to first fix after cold start extra information is
needed like time and coarse position. This commit injects UTC time.

UTC time inject requests are received, when GPS session is initiated
using QMI_LOC_START.

Tested on Quectel EG25-G.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-01-10 02:04:10 +03:00
Andrey Skvortsov 4023c61c71 iface-modem-location: Fix typo in error message
Fixes: 091bf4dbd8 ("shared-qmi: implement LOC-based GPS/A-GPS support")

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-11-05 23:29:36 +03:00
Andrey Skvortsov 9c4aeeb33a shared-qmi: unlock location engine at modem start
On SDM845 (OP6T) modem always starts with engine lock 'all'.
It doesn't allow to read assistance server settings at the beginning.
QMI call 'Get Predicted Orbits Data Source' (0x0036) fails with general
failure. As a result it's not possible to inject assistance data using
'mmcli -m any --location-inject-assistance-data=<file>'.

Commit 90843b7a0d ("shared-qmi: Lock and unlock GPS engine when
starting and stopping") unlocks engine on GNSS start, that allows
geolocation to work on SDM845, but it locks engine back on GNSS stop.
As a result after GNSS stop it's not possible to inject XTRA data again.

On EG25-G engine lock settings is stored in NV storage and is preserved after
modem restart. By default engine lock is 'none'. But currently on GNSS
stop this value is changed to 'all', that blocks location engine.
If previous ModemManager version is installed after
stopping geolocation and locking the engine, geolocation will not
work, since the engine is still locked and modem restart will not help.

This commit unlocks engine on modem start so all following operations
with an engine succeed. Engine isn't locked back.

Tested on SDM845 (OP6T) and Quectel EG25-G.

Fixes: 90843b7a0d ("shared-qmi: Lock and unlock GPS engine when starting and stopping")

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-10-20 15:30:54 -05:00
Andrey Skvortsov c0933d2f18 shared-qmi: replace tabs with whitespaces
Fixes: 103eb9cf29 ("shared-qmi,modem-helpers-qmi: Add support for NR5G band preference")

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-09-27 09:01:57 -05:00
Andrey Skvortsov 37f73c7b6b cli, location: Fix typo in error message
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-09-21 15:32:10 +03:00
Andrey Skvortsov 0e1bfdb5b6 shared-qmi: fix setting URL to supl server
Function mm_parse_suple_address returns TRUE on valid input data
regardless of its type (URL or IP). As a result
qmi_message_loc_set_server_input_set_ipv4 was always called on valid
data. If URL was provided, then 0.0.0.0 ip address was sent to the
modem instead of provided URL.

Fixes: 6e84f3d459 ("iface-modem-location: validate SUPL server address")

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-08-16 21:02:14 +00:00
Andrey Skvortsov f51cc9488b shared-qmi: fix byteorder for supl server IP
It was noted, that when supl server is set using IP address. Modem
doesn't connect to the SUPL server anymore. When IP address is inverted,
then modem connects to SUPL server successfuly.

IP address is stored as uint32_t. According to Telit's documentation [1]
numeric values are encoded in little-endian format in QMI.

After converting IP address from string to binary using inet_pton
IP address is stored in network byte order (big-endian). Therefore it's
needed another convertion from big-endian to host endianness. Final
conversion from host endianness to endianness needed for QMI will be
done in generated
qmi_message_pds_set_agps_config_input_set_location_server_address.

Vendor's Android GNSS hal uses htonl() to convert from struct in_addr
(already in big-endian) before sending QMI request as well [2].

Tested on Quectel EG25-G and SDM845 (OnePlus 6T).

1. FN980 Family Telit Proprietary QMI Command Reference Guide. 4.1.3.1 Byte Ordering
2. https://github.com/ugly-kid-af/device_xiaomi_violet/blob/snow/gps/gnss/GnssAdapter.cpp#L1110

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-08-10 21:05:13 +00:00
Andrey Skvortsov 07aca09af2 polkit,conf: give access to Signal.SetupThresholds() the same way as for Signal.Setup()
Otherwise only Setup() method for suboptimal polling is available to
non-privileged users.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-07-30 12:15:53 -05:00
Andrey Skvortsov f0a9aba63b libmm-glib,cell-info: fix documentation for some functions
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-07-30 11:25:07 -05:00
Andrey Skvortsov 7ff47d795c cli,signal: fix typo in debug message for async operations
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2025-07-30 17:28:45 +03:00
Andrey Skvortsov 4174575d5d quectel: fix debug output if QGPS isn't supported
FEATURE_NOT_SUPPORTED is equal 1 in the enum FeatureSupport, as a
result even if QGPS isn't supported by modem debug message printed
available support.
2023-07-13 08:15:10 +00:00
Andrey Skvortsov 5eb3acee0a shared-qmi: fix memory leak in set_supl_server command
ctx->supl is allocated in mm_shared_qmi_location_set_supl_server
using g_strdup. g_strdup requires to free string when unneeded.

The problem could be reproduced using following commands
```
 while true; do
       mmcli -m any --location-set-supl-server="supl.google.com:7276";
       mem=$(cat /proc/$(pgrep ModemManager)/statm | awk '{print $6}')
       echo $(date +"%s"), $mem | tee -a mm-leak.log;
 done;
```
2023-06-23 23:19:53 +03:00
Andrey Skvortsov 22ba849724 charsets: Add test_text_split_two_pdu_gsm7_extended_chars to use extended character 2022-09-13 20:49:01 +00:00
Andrey Skvortsov 4ebf8ca4e0 sms: fix spliting messages into chunks in gsm7 encoding
1) Not every allowed GSM7 character in UTF-8 incoding takes one
byte. Some (for example, 'à') take several bytes in input string, but
signle byte in GSM7.
2) Extended characters in GSM7 encoding take two bytes.

Otherwise for example sending following SMS fails:

```
 mmcli -m a --messaging-create-sms="text='[wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww',number='+XXXXXXXXXXX'"
Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/99
 mmcli --send -s 99
error: couldn't send the SMS: 'GDBus.Error:org.freedesktop.libqmi.Error.Protocol.WmsEncoding: Couldn't write SMS part: QMI protocol error (58): 'WmsEncoding''
```

```
mmcli -m a --messaging-create-sms="text='|àààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà',number='+XXXXXXXXXXX'"
Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/72
mmcli --send -s 72
error: couldn't send the SMS: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.InvalidArgs: Couldn't convert UTF-8 to GSM: input UTF-8 validation failed'
```
2022-09-13 20:49:01 +00:00
Andrey Skvortsov 2ece78c80f charsets: move mm_sms_part_3gpp_util_split_text to mm_charset_util_split_text 2022-09-13 20:49:01 +00:00