It's possible to use special name 'any' as a modem index. It's
especially useful if system has only single modem.
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Most users have only single modem. Commands with '-m any' will work
even if modem gets new index, because it's restarted or is replugged.
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Currently sequence messages are added to traces as they are
received. Therefore content of traces depends at the time, when
request is issued and data is reported. Sometimes not all sequence
traces are reported, because only first record was received yet and it
overwrote previous full sequence trace.
For example,
```
$GPGSV,3,1,12,01,35,282,,02,68,264,,03,02,243,,08,35,206,,1*68
$GPGSV,3,2,12,10,46,074,,14,16,312,,17,,,,22,16,327,,1*53
$GPGSV,3,3,12,23,07,068,,24,15,030,,27,14,181,,32,51,120,,1*60
$GLGSV,2,1,08,82,25,135,,76,11,029,,75,21,334,,69,11,201,,1*7A
```
one GSV sentence is missing and second later full sequence is
reported
```
$GPGSV,3,1,12,01,35,282,,02,68,264,,03,02,243,,08,35,206,,1*68
$GPGSV,3,2,12,10,46,074,,14,16,312,,17,,,,22,16,327,,1*53
$GPGSV,3,3,12,23,07,068,,24,15,030,,27,14,181,,32,51,120,,1*60
$GLGSV,2,1,08,82,25,135,,76,11,029,,75,21,334,,69,11,201,,1*7A
$GLGSV,2,2,08,84,40,306,,83,79,161,,67,56,056,,68,58,177,,1*7D
```
Therefore client software reports different number of visible
satellites.
Usually sequence sentences are reported consequently in NMEA
stream. Let's cache and join sequence sentences until new trace type
is received. In that case full sequence always overrides
previous full sequence.
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
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>
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>
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>
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>
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>
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>
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>
Otherwise only Setup() method for suboptimal polling is available to
non-privileged users.
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
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.
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;
```
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'
```