quectel,shared: only flag GPS source as enabled if it was successful

This commit is contained in:
Aleksander Morgado
2020-06-29 10:13:44 +02:00
parent 619b054e5c
commit af8afcc6c9

View File

@@ -346,6 +346,9 @@ gps_startup_ready (MMBaseModem *self,
{ {
MMModemLocationSource source; MMModemLocationSource source;
GError *error = NULL; GError *error = NULL;
Private *priv;
priv = get_private (MM_SHARED_QUECTEL (self));
mm_base_modem_at_sequence_finish (self, res, NULL, &error); mm_base_modem_at_sequence_finish (self, res, NULL, &error);
if (error) { if (error) {
@@ -369,10 +372,16 @@ gps_startup_ready (MMBaseModem *self,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_FAILED, MM_CORE_ERROR_FAILED,
"Couldn't open raw GPS serial port"); "Couldn't open raw GPS serial port");
} else } else {
/* GPS port was successfully opened */
priv->enabled_sources |= source;
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
} else }
} else {
/* No need to open GPS port */
priv->enabled_sources |= source;
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
}
g_object_unref (task); g_object_unref (task);
} }
@@ -428,8 +437,6 @@ mm_shared_quectel_enable_location_gathering (MMIfaceModemLocation *self,
MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_RAW |
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED))); MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)));
priv->enabled_sources |= source;
if (start_gps) { if (start_gps) {
mm_base_modem_at_sequence ( mm_base_modem_at_sequence (
MM_BASE_MODEM (self), MM_BASE_MODEM (self),
@@ -442,6 +449,7 @@ mm_shared_quectel_enable_location_gathering (MMIfaceModemLocation *self,
} }
/* If the GPS is already running just return */ /* If the GPS is already running just return */
priv->enabled_sources |= source;
g_task_return_boolean (task, TRUE); g_task_return_boolean (task, TRUE);
g_object_unref (task); g_object_unref (task);
} }