iface-modem-location: common helper code to test raw gps
This commit is contained in:
@@ -108,31 +108,10 @@ get_private (MMSharedCinterion *self)
|
||||
/* GPS trace received */
|
||||
|
||||
static void
|
||||
trace_received (MMPortSerialGps *port,
|
||||
const gchar *trace,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -629,31 +629,10 @@ enable_location_gathering (MMIfaceModemLocation *self,
|
||||
/* Setup ports (Broadband modem class) */
|
||||
|
||||
static void
|
||||
trace_received (MMPortSerialGps *port,
|
||||
const gchar *trace,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,27 +114,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -950,47 +950,6 @@ nmea_received (MMPortSerialAt *port,
|
||||
gchar *trace;
|
||||
|
||||
trace = g_match_info_fetch (info, 1);
|
||||
|
||||
/* 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
|
||||
{
|
||||
const gchar *prefix = NULL;
|
||||
const gchar *lat = NULL;
|
||||
|
||||
/* lat N/S just to test which one is used */
|
||||
if (g_str_has_prefix (trace, "$GPGGA")) {
|
||||
prefix = "GPGGA";
|
||||
lat = "S";
|
||||
} else if (g_str_has_prefix (trace, "$GNGGA")) {
|
||||
prefix = "GNGGA";
|
||||
lat = "N";
|
||||
}
|
||||
|
||||
if (prefix && lat) {
|
||||
GString *str;
|
||||
GDateTime *now;
|
||||
|
||||
mm_dbg ("GGA trace detected: '%s'", trace);
|
||||
g_free (trace);
|
||||
|
||||
now = g_date_time_new_now_utc ();
|
||||
str = g_string_new ("");
|
||||
g_string_append_printf (str,
|
||||
"$%s,%02u%02u%02u,4807.038,%s,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
|
||||
prefix,
|
||||
g_date_time_get_hour (now),
|
||||
g_date_time_get_minute (now),
|
||||
g_date_time_get_second (now),
|
||||
lat);
|
||||
mm_iface_modem_location_gps_update (MM_IFACE_MODEM_LOCATION (self), str->str);
|
||||
g_string_free (str, TRUE);
|
||||
g_date_time_unref (now);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mm_iface_modem_location_gps_update (MM_IFACE_MODEM_LOCATION (self), trace);
|
||||
g_free (trace);
|
||||
}
|
||||
|
||||
@@ -253,14 +253,14 @@ notify_gps_location_update (MMIfaceModemLocation *self,
|
||||
NULL));
|
||||
}
|
||||
|
||||
void
|
||||
mm_iface_modem_location_gps_update (MMIfaceModemLocation *self,
|
||||
const gchar *nmea_trace)
|
||||
static void
|
||||
location_gps_update_nmea (MMIfaceModemLocation *self,
|
||||
const gchar *nmea_trace)
|
||||
{
|
||||
MmGdbusModemLocation *skeleton;
|
||||
LocationContext *ctx;
|
||||
gboolean update_nmea = FALSE;
|
||||
gboolean update_raw = FALSE;
|
||||
LocationContext *ctx;
|
||||
gboolean update_nmea = FALSE;
|
||||
gboolean update_raw = FALSE;
|
||||
|
||||
ctx = get_location_context (self);
|
||||
g_object_get (self,
|
||||
@@ -298,6 +298,50 @@ mm_iface_modem_location_gps_update (MMIfaceModemLocation *self,
|
||||
g_object_unref (skeleton);
|
||||
}
|
||||
|
||||
void
|
||||
mm_iface_modem_location_gps_update (MMIfaceModemLocation *self,
|
||||
const gchar *nmea_trace)
|
||||
{
|
||||
/* 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
|
||||
{
|
||||
const gchar *prefix = NULL;
|
||||
const gchar *lat = NULL;
|
||||
|
||||
/* lat N/S just to test which one is used */
|
||||
if (g_str_has_prefix (nmea_trace, "$GPGGA")) {
|
||||
prefix = "GPGGA";
|
||||
lat = "S";
|
||||
} else if (g_str_has_prefix (nmea_trace, "$GNGGA")) {
|
||||
prefix = "GNGGA";
|
||||
lat = "N";
|
||||
}
|
||||
|
||||
if (prefix && lat) {
|
||||
g_autoptr(GString) str = NULL;
|
||||
g_autoptr(GDateTime) now = NULL;
|
||||
|
||||
mm_dbg ("GGA trace detected: '%s'", nmea_trace);
|
||||
|
||||
now = g_date_time_new_now_utc ();
|
||||
str = g_string_new ("");
|
||||
g_string_append_printf (str,
|
||||
"$%s,%02u%02u%02u,4807.038,%s,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
|
||||
prefix,
|
||||
g_date_time_get_hour (now),
|
||||
g_date_time_get_minute (now),
|
||||
g_date_time_get_second (now),
|
||||
lat);
|
||||
location_gps_update_nmea (self, str->str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
location_gps_update_nmea (self, nmea_trace);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user