]> err.no Git - mapper/commitdiff
Add gps_clear helper to clear the gps data on disconnect.
authorKaj-Michael Lang <milang@onion.tal.org>
Mon, 17 Mar 2008 14:02:05 +0000 (16:02 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Mon, 17 Mar 2008 14:02:05 +0000 (16:02 +0200)
src/gps.c
src/gps.h

index 6e10184267e8a64d89741bf66388f2171acef8b5..8bc3defbd549c55def621197f0a4859cf55c2971 100644 (file)
--- a/src/gps.c
+++ b/src/gps.c
@@ -104,15 +104,26 @@ gps_new(GpsIOSourceType type)
 Gps *gps;
 
 gps=g_slice_new0(Gps);
-gps->data.fix=FIX_NOFIX;
+g_assert(gps);
+gps->io.type=type;
+gps_clear(gps);
+return gps;
+}
+
+void
+gps_clear(Gps *gps)
+{
+g_assert(gps);
 gps->io.fd=-1;
 gps->io.address=NULL;
-gps->io.type=type;
 gps->io.conn=RCVR_OFF;
 gps->io.nmea=NULL;
 gps->io.nmea_cnt=0;
+gps->data.fix=FIX_NOFIX;
 gps->data.lat=60.20;
 gps->data.lon=22.20;
+gps->data.satinview=0;
+gps->data.satinuse=0;
 gps->connection_error=NULL;
 gps->connection_retry=NULL;
 gps->connection_progress=NULL;
@@ -120,7 +131,6 @@ gps->update_location=NULL;
 gps->update_info=NULL;
 gps->update_satellite=NULL;
 gps_data_integerize(&gps->data);
-return gps;
 }
 
 void
@@ -392,15 +402,19 @@ if (gps->io.type==GPS_IO_BLUEZ_DBUS && gps->io.rfcomm_req_proxy) {
 }
 #endif
 
+gps_clear(gps);
 }
 
 static void
 gps_simulate_start(Gps *gps)
 {
+g_assert(gps);
 gps->data.lat=60.45;
 gps->data.lon=22.26;
 gps->io.conn=RCVR_FIXED;
 gps->data.fix=FIX_2D;
+gps->data.satinview=0;
+gps->data.satinuse=0;
 gps_data_integerize(&gps->data);
 }
 
@@ -410,6 +424,7 @@ gps_simulate_move(Gps *gps)
 static gdouble slat=0, slon=0;
 gdouble plat, plon;
 gfloat h;
+
 g_assert(gps);
 
 if (g_random_double()<0.2) {
index c60f8955cadb6427d5211b127c382b2b5b3b4216..388faed2793669495c821da190aa1b42b2ca5ddf 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
@@ -135,6 +135,7 @@ gint _gmtoffset;
 const GpsTypes *gps_get_supported_types(void);
 
 Gps *gps_new(GpsIOSourceType type);
+void gps_clear(Gps *gps);
 void gps_set_address(Gps *gps, gchar *address, guint port);
 void gps_set_type(Gps *gps, GpsIOSourceType type);
 void gps_free(Gps *gps);