From d3a2aebf16ac4a5cd3c57ee6077e68d1f9e552bd Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Sat, 6 Apr 2024 20:43:26 +0200 Subject: mbm: don't stop GPS interface on reinitialization if it should be running Since commit 63dd4ad2 it is possible that the GPS interface is in use at the time of modem reinitialization so it should not be stopped in such case. Otherwise "mmcli --location-status" will still say that GPS is enabled but no GPS traces are going to be coming. --- src/plugins/mbm/mm-broadband-modem-mbm.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/mbm/mm-broadband-modem-mbm.c b/src/plugins/mbm/mm-broadband-modem-mbm.c index 0c362a70..cdc2b255 100644 --- a/src/plugins/mbm/mm-broadband-modem-mbm.c +++ b/src/plugins/mbm/mm-broadband-modem-mbm.c @@ -1429,15 +1429,20 @@ setup_ports (MMBroadbandModem *_self) /* NMEA GPS monitoring */ gps_data_port = mm_base_modem_peek_port_gps (MM_BASE_MODEM (self)); if (gps_data_port) { - /* make sure GPS is stopped incase it was left enabled */ - mm_base_modem_at_command_full (MM_BASE_MODEM (self), - mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), - "AT*E2GPSCTL=0", - 3, FALSE, FALSE, NULL, NULL, NULL); - /* Add handler for the NMEA traces */ - mm_port_serial_gps_add_trace_handler (gps_data_port, - (MMPortSerialGpsTraceFn)gps_trace_received, - self, NULL); + /* make sure GPS is stopped if it should be in case it was left enabled */ + if (!(self->priv->enabled_sources & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA | + MM_MODEM_LOCATION_SOURCE_GPS_RAW | + MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED))) { + mm_base_modem_at_command_full (MM_BASE_MODEM (self), + mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)), + "AT*E2GPSCTL=0", + 3, FALSE, FALSE, NULL, NULL, NULL); + + /* Add handler for the NMEA traces */ + mm_port_serial_gps_add_trace_handler (gps_data_port, + (MMPortSerialGpsTraceFn)gps_trace_received, + self, NULL); + } } } -- cgit v1.2.3-70-g09d2