diff options
author | Teemu Ikonen <tpikonen@mailbox.org> | 2021-10-24 23:09:15 +0300 |
---|---|---|
committer | Zeeshan Ali <zeenix@gmail.com> | 2021-11-07 20:31:35 +0000 |
commit | b89187e77147b797e317977579fc6486d05fdb65 (patch) | |
tree | 3c412f6e665a3db3aff700a38a1656259d87a4c8 | |
parent | 02395f50142718ddf4136ec47b0f599a6b6e3e95 (diff) |
modem: Make 'fix-gps' signal parameter a string array
Change the only parameter of the 'fix-gps' signal to a NULL terminated
array of strings, i.e. G_TYPE_STRV.
The on_get_gps_nmea_ready function in gclue-modem-manager.c now emits
'fix-gps' with NMEA GGA and RMC sentences read from ModemManager.
The signal handler on_fix_gps in gclue-modem-gps.c now accepts a string
array argument and calls gclue_location_create_from_nmeas to create a
new location.
Fixes #147.
-rw-r--r-- | src/gclue-modem-gps.c | 8 | ||||
-rw-r--r-- | src/gclue-modem-manager.c | 35 | ||||
-rw-r--r-- | src/gclue-modem.c | 4 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/gclue-modem-gps.c b/src/gclue-modem-gps.c index 4dfa9b7..78d5e2f 100644 --- a/src/gclue-modem-gps.c +++ b/src/gclue-modem-gps.c @@ -209,7 +209,7 @@ gclue_modem_gps_get_singleton (void) static void on_fix_gps (GClueModem *modem, - const char *nmea, + const char *nmeas[], gpointer user_data) { GClueLocationSource *source = GCLUE_LOCATION_SOURCE (user_data); @@ -218,9 +218,9 @@ on_fix_gps (GClueModem *modem, GError *error = NULL; prev_location = gclue_location_source_get_location (source); - location = gclue_location_create_from_nmea (nmea, - prev_location, - &error); + location = gclue_location_create_from_nmeas (nmeas, + prev_location, + &error); if (error != NULL) { g_warning ("Error: %s", error->message); diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c index ebbce9c..847efb4 100644 --- a/src/gclue-modem-manager.c +++ b/src/gclue-modem-manager.c @@ -405,7 +405,9 @@ on_get_gps_nmea_ready (GObject *source_object, GClueModemManagerPrivate *priv = manager->priv; MMModemLocation *modem_location = MM_MODEM_LOCATION (source_object); MMLocationGpsNmea *location_nmea; - const char *sentence; + static const gchar *sentences[3]; + const gchar *gga, *rmc; + gint i = 0; GError *error = NULL; location_nmea = mm_modem_location_get_gps_nmea_finish (modem_location, @@ -423,27 +425,28 @@ on_get_gps_nmea_ready (GObject *source_object, return; } - sentence = mm_location_gps_nmea_get_trace (location_nmea, "$GPGGA"); - if (sentence != NULL && gclue_nmea_is_gga (sentence)) { - if (is_location_gga_same (manager, sentence)) { - g_debug ("New GGA trace is same as last one: %s", sentence); + gga = mm_location_gps_nmea_get_trace (location_nmea, "$GPGGA"); + if (gga != NULL && gclue_nmea_is_gga (gga)) { + if (is_location_gga_same (manager, gga)) { + g_debug ("New GGA trace is same as last one: %s", gga); + g_object_unref (location_nmea); return; } - g_debug ("New GPGGA trace: %s", sentence); - goto new_trace; + g_debug ("New GPGGA trace: %s", gga); + sentences[i++] = gga; } - sentence = mm_location_gps_nmea_get_trace (location_nmea, "$GPRMC"); - if (sentence != NULL && gclue_nmea_is_rmc (sentence)) { - g_debug ("New GPRMC trace: %s", sentence); - goto new_trace; + rmc = mm_location_gps_nmea_get_trace (location_nmea, "$GPRMC"); + if (rmc != NULL && gclue_nmea_is_rmc (rmc)) { + g_debug ("New GPRMC trace: %s", rmc); + sentences[i++] = rmc; } + sentences[i] = NULL; - g_debug ("No GGA or RMC trace"); - goto out; + if (sentences[0] == NULL) + g_debug ("No GGA or RMC trace"); + else + g_signal_emit (manager, signals[FIX_GPS], 0, sentences); -new_trace: - g_signal_emit (manager, signals[FIX_GPS], 0, sentence); -out: g_clear_object (&priv->location_nmea); priv->location_nmea = location_nmea; } diff --git a/src/gclue-modem.c b/src/gclue-modem.c index 4ee8230..f587e17 100644 --- a/src/gclue-modem.c +++ b/src/gclue-modem.c @@ -105,10 +105,10 @@ gclue_modem_default_init (GClueModemInterface *iface) 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, + g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, - G_TYPE_STRING); + G_TYPE_STRV); } gboolean |