diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-06-28 11:04:20 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-06-29 08:53:00 +0000 |
commit | 77f6637750362a8c319e2debc6f781ceb217675a (patch) | |
tree | 6ebdbcf27f5ca3fc2eeec67dd871b98c4d15f818 | |
parent | 0f9d69fd355a05b51b8367fa75dbd49440a9bd7e (diff) |
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.
-rw-r--r-- | plugins/quectel/mm-shared-quectel.c | 78 |
1 files changed, 29 insertions, 49 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 @@ -264,67 +264,44 @@ mm_shared_quectel_location_load_capabilities_finish (MMIfaceModemLocation *self } static void -build_provided_location_sources (GTask *task) +probe_qgps_ready (MMBaseModem *_self, + GAsyncResult *res, + GTask *task) { - MMModemLocationSource parent_sources; MMSharedQuectel *self; Private *priv; + MMModemLocationSource sources; - 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 */ + priv->qgps_supported = (!!mm_base_modem_at_command_finish (_self, res, NULL) ? + FEATURE_SUPPORTED : FEATURE_NOT_SUPPORTED); + + mm_obj_dbg (self, "GPS management with +QGPS is %ssupported", + priv->qgps_supported ? "" : "not "); + + /* Recover parent sources */ + sources = GPOINTER_TO_UINT (g_task_get_task_data (task)); + + /* Only flag as provided those sources not already provided by the parent */ if (priv->qgps_supported == FEATURE_SUPPORTED) { - if (!(parent_sources & MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) + if (!(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)) + if (!(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)) + if (!(sources & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) priv->provided_sources |= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED; + + sources |= priv->provided_sources; } /* So we're done, complete */ - g_task_return_int (task, priv->provided_sources); + g_task_return_int (task, sources); g_object_unref (task); } static void -probe_qgps_ready (MMBaseModem *_self, - GAsyncResult *res, - GTask *task) -{ - MMSharedQuectel *self; - Private *priv; - GError *error = NULL; - - 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) ? - FEATURE_SUPPORTED : FEATURE_NOT_SUPPORTED); - - build_provided_location_sources (task); -} - -static void -probe_qgps (GTask *task) -{ - MMSharedQuectel *self; - - self = MM_SHARED_QUECTEL (g_task_get_source_object (task)); - - mm_base_modem_at_command (MM_BASE_MODEM (self), - "+QGPS?", - 3, - FALSE, /* not cached */ - (GAsyncReadyCallback)probe_qgps_ready, - task); -} - -static void parent_load_capabilities_ready (MMIfaceModemLocation *self, GAsyncResult *res, GTask *task) @@ -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 |