Add:core: Add iso fix time, hdop and fix type to gpsd
authorzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 9 Nov 2008 18:39:14 +0000 (18:39 +0000)
committerzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 9 Nov 2008 18:39:14 +0000 (18:39 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1714 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/vehicle/gpsd/vehicle_gpsd.c

index 2cb661f..8f54961 100644 (file)
@@ -41,13 +41,17 @@ static struct vehicle_priv {
        double speed;
        double direction;
        double height;
+       double hdop;
        int status;
+       int fix_type;
+       time_t fix_time;
        int sats;
        int sats_used;
        char *nmea_data;
-        char *nmea_data_buf;
+       char *nmea_data_buf;
        guint retry_timer;
        struct attr ** attrs;
+       char fixiso8601[128];
 } *vehicle_last;
 
 #define DEFAULT_RETRY_INTERVAL 10 // seconds
@@ -107,8 +111,17 @@ vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
                priv->status = data->status;
                data->set &= ~STATUS_SET;
        }
+       if (data->set & MODE_SET) {
+               priv->fix_type = data->fix.mode - 1;
+               data->set &= ~MODE_SET;
+       }
+       if (data->set & TIME_SET) {
+               priv->fix_time = data->fix.time;
+               data->set &= ~TIME_SET;
+       }
        if (data->set & PDOP_SET) {
-               dbg(0, "pdop : %g\n", data->pdop);
+               dbg(1, "pdop : %g\n", data->pdop);
+               priv->hdop = data->hdop;
                data->set &= ~PDOP_SET;
        }
        if (data->set & LATLON_SET) {
@@ -227,6 +240,9 @@ vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
 {
        struct attr * active=NULL;
        switch (type) {
+       case attr_position_fix_type:
+               attr->u.num = priv->fix_type;
+               break;
        case attr_position_height:
                attr->u.numd = &priv->height;
                break;
@@ -236,6 +252,9 @@ vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
        case attr_position_direction:
                attr->u.numd = &priv->direction;
                break;
+       case attr_position_hdop:
+               attr->u.numd = &priv->hdop;
+               break;
        case attr_position_qual:
                attr->u.num = priv->sats;
                break;
@@ -250,6 +269,19 @@ vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
                if (! attr->u.str)
                        return 0;
                break;
+       case attr_position_time_iso8601:
+               {
+               struct tm tm;
+               if (!priv->fix_time)
+                       return 0;
+               if (gmtime_r(&priv->fix_time, &tm)) {
+                       strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+                               "%Y-%m-%dT%TZ", &tm);
+                       attr->u.str=priv->fixiso8601;
+               } else
+                       return 0;
+               }
+               break;
        case attr_active:
          active = attr_search(priv->attrs,NULL,attr_active);
          if(active != NULL && active->u.num == 1)