cinterion: setup GPS port only if GPS support detected
i.e. if AT^SGPSS not supported, we don't even add traces handler to the GPS data port.
This commit is contained in:
@@ -1550,18 +1550,6 @@ after_sim_unlock (MMIfaceModem *self,
|
|||||||
after_sim_unlock_context_step (ctx);
|
after_sim_unlock_context_step (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Setup ports (Broadband modem class) */
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_ports (MMBroadbandModem *self)
|
|
||||||
{
|
|
||||||
/* Call parent's setup ports first always */
|
|
||||||
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_cinterion_parent_class)->setup_ports (self);
|
|
||||||
|
|
||||||
mm_common_cinterion_setup_gps_port (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Create Bearer (Modem interface) */
|
/* Create Bearer (Modem interface) */
|
||||||
|
|
||||||
@@ -1832,11 +1820,9 @@ static void
|
|||||||
mm_broadband_modem_cinterion_class_init (MMBroadbandModemCinterionClass *klass)
|
mm_broadband_modem_cinterion_class_init (MMBroadbandModemCinterionClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
|
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (MMBroadbandModemCinterionPrivate));
|
g_type_class_add_private (object_class, sizeof (MMBroadbandModemCinterionPrivate));
|
||||||
|
|
||||||
/* Virtual methods */
|
/* Virtual methods */
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
broadband_modem_class->setup_ports = setup_ports;
|
|
||||||
}
|
}
|
||||||
|
@@ -34,18 +34,6 @@ static void iface_modem_location_init (MMIfaceModemLocation *iface);
|
|||||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiCinterion, mm_broadband_modem_qmi_cinterion, MM_TYPE_BROADBAND_MODEM_QMI, 0,
|
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiCinterion, mm_broadband_modem_qmi_cinterion, MM_TYPE_BROADBAND_MODEM_QMI, 0,
|
||||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init))
|
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init))
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Setup ports (Broadband modem class) */
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_ports (MMBroadbandModem *self)
|
|
||||||
{
|
|
||||||
/* Call parent's setup ports first always */
|
|
||||||
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_qmi_cinterion_parent_class)->setup_ports (self);
|
|
||||||
|
|
||||||
mm_common_cinterion_setup_gps_port (self);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
MMBroadbandModemQmiCinterion *
|
MMBroadbandModemQmiCinterion *
|
||||||
@@ -85,8 +73,4 @@ iface_modem_location_init (MMIfaceModemLocation *iface)
|
|||||||
static void
|
static void
|
||||||
mm_broadband_modem_qmi_cinterion_class_init (MMBroadbandModemQmiCinterionClass *klass)
|
mm_broadband_modem_qmi_cinterion_class_init (MMBroadbandModemQmiCinterionClass *klass)
|
||||||
{
|
{
|
||||||
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
|
|
||||||
|
|
||||||
/* Virtual methods */
|
|
||||||
broadband_modem_class->setup_ports = setup_ports;
|
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "mm-common-cinterion.h"
|
#include "mm-common-cinterion.h"
|
||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
|
||||||
static MMIfaceModemLocation *iface_modem_location_parent;
|
static MMIfaceModemLocation *iface_modem_location_parent;
|
||||||
|
|
||||||
@@ -69,6 +70,38 @@ get_location_context (MMBaseModem *self)
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* GPS trace received */
|
||||||
|
|
||||||
|
static void
|
||||||
|
trace_received (MMPortSerialGps *port,
|
||||||
|
const gchar *trace,
|
||||||
|
MMIfaceModemLocation *self)
|
||||||
|
{
|
||||||
|
/* Helper to debug GPS location related issues. Don't depend on a real GPS
|
||||||
|
* fix for debugging, just use some random values to update */
|
||||||
|
#if 0
|
||||||
|
if (g_str_has_prefix (trace, "$GPGGA")) {
|
||||||
|
GString *str;
|
||||||
|
GDateTime *now;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_utc ();
|
||||||
|
str = g_string_new ("");
|
||||||
|
g_string_append_printf (str,
|
||||||
|
"$GPGGA,%02u%02u%02u,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
|
||||||
|
g_date_time_get_hour (now),
|
||||||
|
g_date_time_get_minute (now),
|
||||||
|
g_date_time_get_second (now));
|
||||||
|
mm_iface_modem_location_gps_update (self, str->str);
|
||||||
|
g_string_free (str, TRUE);
|
||||||
|
g_date_time_unref (now);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mm_iface_modem_location_gps_update (self, trace);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Location capabilities loading (Location interface) */
|
/* Location capabilities loading (Location interface) */
|
||||||
|
|
||||||
@@ -107,8 +140,15 @@ sgpss_test_ready (MMBaseModem *self,
|
|||||||
location_ctx = get_location_context (self);
|
location_ctx = get_location_context (self);
|
||||||
if (!mm_base_modem_at_command_finish (self, res, NULL))
|
if (!mm_base_modem_at_command_finish (self, res, NULL))
|
||||||
location_ctx->sgpss_support = FEATURE_NOT_SUPPORTED;
|
location_ctx->sgpss_support = FEATURE_NOT_SUPPORTED;
|
||||||
else
|
else {
|
||||||
|
/* ^SGPSS supported! */
|
||||||
location_ctx->sgpss_support = FEATURE_SUPPORTED;
|
location_ctx->sgpss_support = FEATURE_SUPPORTED;
|
||||||
|
/* It may happen that the modem was started with GPS already enabled, or
|
||||||
|
* maybe ModemManager got rebooted and it was left enabled before. We'll
|
||||||
|
* make sure that it is disabled when we initialize the modem. */
|
||||||
|
mm_base_modem_at_command (MM_BASE_MODEM (self), "AT^SGPSS=0", 3, FALSE, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
probe_gps_features (task);
|
probe_gps_features (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +175,12 @@ probe_gps_features (GTask *task)
|
|||||||
ctx->sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
ctx->sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED);
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED);
|
||||||
|
|
||||||
|
/* Add handler for the NMEA traces in the GPS data port */
|
||||||
|
mm_port_serial_gps_add_trace_handler (mm_base_modem_peek_port_gps (MM_BASE_MODEM (self)),
|
||||||
|
(MMPortSerialGpsTraceFn)trace_received,
|
||||||
|
self,
|
||||||
|
NULL);
|
||||||
} else
|
} else
|
||||||
mm_dbg ("No GPS command supported: no GPS capabilities");
|
mm_dbg ("No GPS command supported: no GPS capabilities");
|
||||||
|
|
||||||
@@ -568,61 +614,6 @@ mm_common_cinterion_enable_location_gathering (MMIfaceModemLocation *self,
|
|||||||
task);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Setup ports (Broadband modem class) */
|
|
||||||
|
|
||||||
static void
|
|
||||||
trace_received (MMPortSerialGps *port,
|
|
||||||
const gchar *trace,
|
|
||||||
MMIfaceModemLocation *self)
|
|
||||||
{
|
|
||||||
/* Helper to debug GPS location related issues. Don't depend on a real GPS
|
|
||||||
* fix for debugging, just use some random values to update */
|
|
||||||
#if 0
|
|
||||||
if (g_str_has_prefix (trace, "$GPGGA")) {
|
|
||||||
GString *str;
|
|
||||||
GDateTime *now;
|
|
||||||
|
|
||||||
now = g_date_time_new_now_utc ();
|
|
||||||
str = g_string_new ("");
|
|
||||||
g_string_append_printf (str,
|
|
||||||
"$GPGGA,%02u%02u%02u,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
|
|
||||||
g_date_time_get_hour (now),
|
|
||||||
g_date_time_get_minute (now),
|
|
||||||
g_date_time_get_second (now));
|
|
||||||
mm_iface_modem_location_gps_update (self, str->str);
|
|
||||||
g_string_free (str, TRUE);
|
|
||||||
g_date_time_unref (now);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mm_iface_modem_location_gps_update (self, trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
mm_common_cinterion_setup_gps_port (MMBroadbandModem *self)
|
|
||||||
{
|
|
||||||
MMPortSerialGps *gps_data_port;
|
|
||||||
|
|
||||||
gps_data_port = mm_base_modem_peek_port_gps (MM_BASE_MODEM (self));
|
|
||||||
if (gps_data_port) {
|
|
||||||
/* It may happen that the modem was started with GPS already enabled, or
|
|
||||||
* maybe ModemManager got rebooted and it was left enabled before. We'll make
|
|
||||||
* sure that it is disabled when we initialize the modem */
|
|
||||||
mm_base_modem_at_command_full (MM_BASE_MODEM (self),
|
|
||||||
mm_base_modem_peek_best_at_port (MM_BASE_MODEM (self), NULL),
|
|
||||||
"AT^SGPSS=0",
|
|
||||||
3, FALSE, FALSE, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* Add handler for the NMEA traces */
|
|
||||||
mm_port_serial_gps_add_trace_handler (gps_data_port,
|
|
||||||
(MMPortSerialGpsTraceFn)trace_received,
|
|
||||||
self,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -44,8 +44,6 @@ gboolean mm_common_cinterion_disable_location_gathering_finish (MMI
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void mm_common_cinterion_setup_gps_port (MMBroadbandModem *self);
|
|
||||||
|
|
||||||
void mm_common_cinterion_peek_parent_location_interface (MMIfaceModemLocation *iface);
|
void mm_common_cinterion_peek_parent_location_interface (MMIfaceModemLocation *iface);
|
||||||
|
|
||||||
#endif /* MM_COMMON_CINTERION_H */
|
#endif /* MM_COMMON_CINTERION_H */
|
||||||
|
Reference in New Issue
Block a user