From 77f6637750362a8c319e2debc6f781ceb217675a Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 28 Jun 2020 11:04:20 +0200 Subject: [PATCH] quectel,shared: fix reporting supported location capabilities The method that reports what location capabilities are supported must report the capabilities provided by the parent interface plus the additional capabilities supported by the shared implementation. Also, simplify the logic a bit reducing the amount of implemented methods. --- plugins/quectel/mm-shared-quectel.c | 82 +++++++++++------------------ 1 file changed, 31 insertions(+), 51 deletions(-) diff --git a/plugins/quectel/mm-shared-quectel.c b/plugins/quectel/mm-shared-quectel.c index c6b3c1d2..2d3a0d72 100644 --- a/plugins/quectel/mm-shared-quectel.c +++ b/plugins/quectel/mm-shared-quectel.c @@ -263,65 +263,42 @@ mm_shared_quectel_location_load_capabilities_finish (MMIfaceModemLocation *self return (MMModemLocationSource)value; } -static void -build_provided_location_sources (GTask *task) -{ - MMModemLocationSource parent_sources; - MMSharedQuectel *self; - Private *priv; - - parent_sources = GPOINTER_TO_UINT (g_task_get_task_data (task)); - self = MM_SHARED_QUECTEL (g_task_get_source_object (task)); - priv = get_private (self); - - /* Only enable any location sources the modem supports gps - * Then only report supporting a location source - * if it's not already supported by the parent location source */ - if (priv->qgps_supported == FEATURE_SUPPORTED) { - if (!(parent_sources & MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) - priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_NMEA; - if (!(parent_sources & MM_MODEM_LOCATION_SOURCE_GPS_RAW)) - priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_RAW; - if (!(parent_sources & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) - priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED; - } - - /* So we're done, complete */ - g_task_return_int (task, priv->provided_sources); - g_object_unref (task); -} - static void probe_qgps_ready (MMBaseModem *_self, GAsyncResult *res, GTask *task) { - MMSharedQuectel *self; - Private *priv; - GError *error = NULL; + MMSharedQuectel *self; + Private *priv; + MMModemLocationSource sources; self = MM_SHARED_QUECTEL (g_task_get_source_object (task)); priv = get_private (self); - priv->qgps_supported = (!!mm_base_modem_at_command_full_finish (_self, res, &error) ? + priv->qgps_supported = (!!mm_base_modem_at_command_finish (_self, res, NULL) ? FEATURE_SUPPORTED : FEATURE_NOT_SUPPORTED); - build_provided_location_sources (task); -} + mm_obj_dbg (self, "GPS management with +QGPS is %ssupported", + priv->qgps_supported ? "" : "not "); -static void -probe_qgps (GTask *task) -{ - MMSharedQuectel *self; + /* Recover parent sources */ + sources = GPOINTER_TO_UINT (g_task_get_task_data (task)); - self = MM_SHARED_QUECTEL (g_task_get_source_object (task)); + /* Only flag as provided those sources not already provided by the parent */ + if (priv->qgps_supported == FEATURE_SUPPORTED) { + if (!(sources & MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) + priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_NMEA; + if (!(sources & MM_MODEM_LOCATION_SOURCE_GPS_RAW)) + priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_RAW; + if (!(sources & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) + priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED; - mm_base_modem_at_command (MM_BASE_MODEM (self), - "+QGPS?", - 3, - FALSE, /* not cached */ - (GAsyncReadyCallback)probe_qgps_ready, - task); + sources |= priv->provided_sources; + } + + /* So we're done, complete */ + g_task_return_int (task, sources); + g_object_unref (task); } static void @@ -341,14 +318,17 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self, return; } + /* Store parent supported sources in task data */ g_task_set_task_data (task, GUINT_TO_POINTER (sources), NULL); - if (priv->qgps_supported == FEATURE_SUPPORT_UNKNOWN) { - probe_qgps (task); - return; - } - - build_provided_location_sources (task); + /* Probe QGPS support */ + g_assert (priv->qgps_supported == FEATURE_SUPPORT_UNKNOWN); + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+QGPS?", + 3, + FALSE, /* not cached */ + (GAsyncReadyCallback)probe_qgps_ready, + task); } void