From: Kaj-Michael Lang Date: Mon, 17 Mar 2008 14:02:05 +0000 (+0200) Subject: Add gps_clear helper to clear the gps data on disconnect. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f4088ead74df5e5c8e15f622a263077647640ae;p=mapper Add gps_clear helper to clear the gps data on disconnect. --- diff --git a/src/gps.c b/src/gps.c index 6e10184..8bc3def 100644 --- 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) { diff --git a/src/gps.h b/src/gps.h index c60f895..388faed 100644 --- 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);