summaryrefslogtreecommitdiff
path: root/navit/vehicle/webos
diff options
context:
space:
mode:
authornorad <norad@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-26 14:24:27 +0000
committernorad <norad@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-26 14:24:27 +0000
commit5008ad0a69a5b37e054481404169c927bc7102b8 (patch)
treea34554d3ece324aaaa7ebbee287b7ba1d85415c9 /navit/vehicle/webos
parent3472fd4ee6218b08057f6d20cd43857ba28bc798 (diff)
downloadnavit-5008ad0a69a5b37e054481404169c927bc7102b8.tar.gz
Patch:vehicle/webos:Implement timeout to report lost gps fix.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4718 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/vehicle/webos')
-rw-r--r--navit/vehicle/webos/vehicle_webos.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/navit/vehicle/webos/vehicle_webos.c b/navit/vehicle/webos/vehicle_webos.c
index d8397768a..3aac8b657 100644
--- a/navit/vehicle/webos/vehicle_webos.c
+++ b/navit/vehicle/webos/vehicle_webos.c
@@ -46,6 +46,9 @@ struct vehicle_priv {
struct attr ** attrs;
char fixiso8601[128];
int pdk_version;
+ struct event_timeout *ev_timeout;
+ struct callback *timeout_cb;
+ char has_fix;
};
static void
@@ -89,9 +92,16 @@ vehicle_webos_gps_update(struct vehicle_priv *priv, PDL_Location *location)
{
struct timeval tv;
gettimeofday(&tv,NULL);
- priv->fix_time = tv.tv_sec;
+ event_remove_timeout(priv->ev_timeout);
+ priv->ev_timeout = NULL;
+
+ int new_timeout = (priv->fix_time == 0 ? 1 : (int)difftime(tv.tv_sec, priv->fix_time)) * 2000;
+
+ priv->fix_time = tv.tv_sec;
+ priv->has_fix = 1;
priv->geo.lat = location->latitude;
+ /* workaround for webOS GPS bug following */
priv->geo.lng = (priv->pdk_version == 200 && location->longitude >= -1 && location->longitude <= 1) ?
-location->longitude : location->longitude;
@@ -117,12 +127,29 @@ vehicle_webos_gps_update(struct vehicle_priv *priv, PDL_Location *location)
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- return;
+ dbg(1, "add timeout(%i)\n", new_timeout);
+ priv->ev_timeout = event_add_timeout(new_timeout, 0, priv->timeout_cb);
+}
+
+static void
+vehicle_webos_timeout_callback(struct vehicle_priv *priv)
+{
+ dbg(1, "GPS timeout triggered cb(%p)\n", priv->timeout_cb);
+
+ priv->fix_time = 0;
+ priv->has_fix = 0;
+
+ callback_list_call_attr_0(priv->cbl, attr_position_fix_type);
}
static void
vehicle_webos_close(struct vehicle_priv *priv)
{
+ event_remove_timeout(priv->ev_timeout);
+ priv->ev_timeout = NULL;
+
+ callback_destroy(priv->timeout_cb);
+
if (priv->pdk_version <= 100)
PDL_UnregisterServiceCallback((PDL_ServiceCallbackFunc)vehicle_webos_callback);
else
@@ -217,16 +244,18 @@ vehicle_webos_position_attr_get(struct vehicle_priv *priv,
break;
case attr_position_fix_type:
- if (priv->radius == 0.0)
- return 0; // strength = -1
- else if (priv->radius > 20.0)
+ if (!priv->has_fix || priv->radius == 0.0)
attr->u.num = 0; // strength = 1
+ else if (priv->radius > 20.0)
+ attr->u.num = 1; // strength >= 2
else
- attr->u.num = 1; // strength = 2
+ attr->u.num = 2; // strength >= 2
break;
case attr_position_sats_used:
- if (priv->radius <= 6.0 )
+ if (!priv->has_fix)
+ attr->u.num = 0;
+ else if (priv->radius <= 6.0 )
attr->u.num = 6; // strength = 5
else if (priv->radius <= 10.0 )
attr->u.num = 5; // strength = 4
@@ -291,10 +320,12 @@ vehicle_webos_new(struct vehicle_methods
{
struct vehicle_priv *priv;
-
priv = g_new0(struct vehicle_priv, 1);
priv->attrs = attrs;
priv->cbl = cbl;
+
+ priv->timeout_cb = callback_new_1(callback_cast(vehicle_webos_timeout_callback), priv);
+
*meth = vehicle_webos_methods;
while (*attrs) {
vehicle_webos_set_attr_do(priv, *attrs, 1);