18 Commits
Author SHA1 Message Date
Andrey Skvortsov f7da97989b location-gps-nmea: add complete sequence to traces at once
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>
2026-05-26 20:56:53 +00:00
Andrey Skvortsov 38548fedd3 location-gps-nmea: use g_autofree in location_gps_nmea_take_trace to track ownership
It allows simplify error handling.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
2026-05-26 20:56:53 +00:00
Aleksander Morgado 74fc5baca2 core: port GRegex/GMatchInfo to use autoptr()
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1
to pcre2. In some cases it was made more strict, which is fine, in
other cases it exposed some change in how it behaves on certain
matches that is not extremely clear whether it's ok or not.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621

Either way, one thing that was assumed was that initializing all
GRegex/GMatchInfo variables to NULL and making sure they're NULL
before they're initialized by glib (especially the GMatchInfo) was a
good and safer approach.

So, whenever possible, g_autoptr() is used to cleanup the allocated
GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used
to ensure that no free/unref is attempted unless the given variable is
not NULL, and also so that the variable is reseted to NULL after being
disposed.
2022-09-05 17:33:11 +00:00
Aleksander Morgado 21c775703c libmm-glib: fix license in sources
The libmm-glib library is LGPLv2+, not GPLv2+.
2021-11-16 17:54:26 +01:00
Teemu Ikonen d6dafe5cb4 location-gps-nmea: Fix handling of multi-sentence NMEA messages
Fixes the regexp in check_append_or_replace() to accept

 1. more multi-sentence NMEA messages (ALM, GSV, RTE, SFI)
 2. multi-sentence NMEA messages from all talkers, not just GPS
    (i.e. GPGSV, GLGSV, GAGSV etc.)
2021-08-30 06:49:59 +00:00
Aleksander Morgado 6363add86a libmm-glib,location-gps-nmea: move deprecated methods to compat source 2021-06-25 19:01:06 +02:00
Aleksander Morgado 49f52d9182 libmm-glib,location-gps-nmea: add missing type check in get_traces() 2021-06-25 19:01:06 +02:00
Aleksander Morgado 619b054e5c libmm-glib,location: avoid warnings when no traces available
ModemManager[201411]: <debug> [1593417744.011884] [modem0/ttyUSB1/gps] <-- '$GPVTG,,T,,M,,N,,K,N*2C<CR><LF>$GPGSA,A,1,,,,,,,,,,,,,,,*1E<CR><LF>$GPGGA,,,,,,0,,,,,,,,*66<CR><LF>$GPRMC,,V,,,,,,,,,,N*53<CR><LF>'

    (ModemManager:201411): GLib-CRITICAL **: 10:02:24.054: g_strjoinv: assertion 'str_array != NULL' failed

    Thread 1 "ModemManager" received signal SIGTRAP, Trace/breakpoint trap.
    0x00007ffff7832473 in g_logv () from /usr/lib/libglib-2.0.so.0
    (gdb) bt
    #0  0x00007ffff7832473 in g_logv () at /usr/lib/libglib-2.0.so.0
    #1  0x00007ffff78326f0 in g_log () at /usr/lib/libglib-2.0.so.0
    #2  0x00007ffff7846b5e in g_strjoinv () at /usr/lib/libglib-2.0.so.0
    #3  0x00007ffff7ee9663 in mm_location_gps_nmea_get_string_variant (self=0x5555557dde50) at mm-location-gps-nmea.c:246
    #4  0x00005555555e7c47 in build_location_dictionary (previous=0x0, location_3gpp=0x55555573e660, location_gps_nmea=0x5555557dde50, location_gps_raw=0x0, location_cdma_bs=0x0)
        at mm-iface-modem-location.c:183
    ...
    (gdb) fr 3
    #3  0x00007ffff7ee9663 in mm_location_gps_nmea_get_string_variant (self=0x5555557dde50) at mm-location-gps-nmea.c:246
    246	    built = g_strjoinv ("\r\n", traces);
    (gdb) p traces
    $1 = (GStrv) 0x0
2020-06-29 08:53:00 +00:00
Aleksander Morgado a61caff747 iface-modem-location: plug memleaks when updating gps raw variant
The helper method returning a variant from a MMLocationGpsRaw would
return already a full variant reference instead of a floating one, so
we were really increasing the refcount when doing g_variant_ref_sink()
in the location interface.

Fix this by consolidating all helper methods in libmm-glib that return
variants from the different MMLocationXX objects, so that they all
return full variants instead of floating ones.
2020-02-07 14:42:16 +00:00
Aleksander Morgado 11f04851ce libmm-glib,location-gps-nmea: avoid using deprecated build_full() method
mm-location-gps-nmea.c: In function ‘mm_location_gps_nmea_get_string_variant’:
  mm-location-gps-nmea.c:245:5: warning: ‘mm_location_gps_nmea_build_full’ is deprecated: Use 'mm_location_gps_nmea_get_traces' instead [-Wdeprecated-declarations]
    245 |     built = mm_location_gps_nmea_build_full (self);
        |     ^~~~~
2020-01-31 15:18:35 +01:00
Aleksander Morgado 70910a6713 libmm-glib,nmea: deprecate mm_location_gps_nmea_build_full()
The new mm_location_gps_nmea_get_traces() is a much more generic way
to retrieve the full list of traces and suits the libmm-glib API much
better.
2020-01-01 09:22:41 +01:00
Aleksander Morgado 9805ffe1b0 libmm-glib,nmea: new method to get list of traces
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/120
2019-12-31 16:42:44 +01:00
Aleksander Morgado 5dd829174f libmm-glib: flag as (skip) all non-API methods
So that the GI scanner ignores them.
2019-10-28 10:28:31 +01:00
Aleksander Morgado 08d23dd64d docs,libmm-glib: provide per-version indices 2019-10-28 10:28:31 +01:00
Ben Chan e33aa01963 location-gps-nmea: fix memory leaks
There are potential memory leaks in MMLocationGpsNmea:

- When the `trace' string provided to location_gps_nmea_take_trace() isn't
  added to the hash table, its ownership is still considered transferred.
  It should thus be freed. Similarly, the `trace_type' string isn't
  added the hash table and should thus be freed.

- mm_location_gps_nmea_add_trace() duplicates a given trace string and
  then passes the trace copy to location_gps_nmea_take_trace(). When
  location_gps_nmea_take_trace() returns FALSE, the ownership of the
  copy isn't transferred. mm_location_gps_nmea_add_trace() should thus
  free the copy.

This patch fixes the above memory leaks by having
location_gps_nmea_take_trace() always take the ownership of the `trace'
string and internally free `trace' and `trace_type' when necessary.
2017-08-04 15:07:56 +02:00
Aleksander Morgado e1c0621b09 libmm-glib: fix several introspection annotations 2013-10-24 17:16:33 +02:00
Aleksander Morgado 030daafc45 libmm-glib,location-gps-nmea: improve documentation 2012-10-04 10:17:12 +02:00
Aleksander Morgado b6d628b3a1 build: merge libmm-common into libmm-glib
It's pointless to have libmm-common around, just merge it into libmm-glib and
make ModemManager depend on libmm-glib directly. At the end, the non-common
stuff in libmm-glib is really minimal.
2012-10-04 10:17:05 +02:00