navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
vehicle_android.c File Reference
#include <config.h>
#include <string.h>
#include <glib.h>
#include <math.h>
#include <time.h>
#include "debug.h"
#include "callback.h"
#include "plugin.h"
#include "coord.h"
#include "item.h"
#include "android.h"
#include "vehicle.h"

Data Structures

struct  vehicle_priv
 

Functions

static void vehicle_android_destroy (struct vehicle_priv *priv)
 Free the android_vehicle. More...
 
static int vehicle_android_position_attr_get (struct vehicle_priv *priv, enum attr_type type, struct attr *attr)
 Retrieves a vehicle attribute. More...
 
static void vehicle_android_position_callback (struct vehicle_priv *v, jobject location)
 Called when a new position has been reported. More...
 
static void vehicle_android_status_callback (struct vehicle_priv *v, int sats_in_view, int sats_used)
 Called when a new GPS status has been reported. More...
 
static void vehicle_android_fix_callback (struct vehicle_priv *v, int fix_type)
 Called when a change in GPS fix status has been reported. More...
 
static int vehicle_android_init (struct vehicle_priv *ret)
 Initializes an Android vehicle. More...
 
static struct vehicle_privvehicle_android_new_android (struct vehicle_methods *meth, struct callback_list *cbl, struct attr **attrs)
 Create android_vehicle. More...
 
void plugin_init (void)
 register vehicle_android More...
 

Variables

struct vehicle_methods vehicle_android_methods
 

Function Documentation

void plugin_init ( void  )

register vehicle_android

The plugin entry point.

Returns
nothing

References dbg, lvl_debug, and vehicle_android_new_android().

static void vehicle_android_destroy ( struct vehicle_priv priv)
static

Free the android_vehicle.

Parameters
privvehicle_priv structure for the vehicle
Returns
nothing

References dbg, and lvl_debug.

static void vehicle_android_fix_callback ( struct vehicle_priv v,
int  fix_type 
)
static

Called when a change in GPS fix status has been reported.

This function is called by

NavitLocationListener

upon receiving a new

android.location.GPS_FIX_CHANGE

broadcast.

Parameters
vThe
struct_vehicle_priv
for the vehicle
fix_typeThe fix type (1 = valid, 0 = invalid)

References attr_position_valid_extrapolated_time, attr_position_valid_valid, callback_list_call_attr_0, vehicle_priv::cbl, vehicle_priv::fix_type, and vehicle_priv::valid.

Referenced by vehicle_android_new_android().

static int vehicle_android_position_attr_get ( struct vehicle_priv priv,
enum attr_type  type,
struct attr attr 
)
static

Retrieves a vehicle attribute.

Parameters
privvehicle_priv structure for the vehicle
typeThe attribute type to retrieve
attrPoints to an attr structure that will receive the attribute data
Returns
True for success, false for failure

References attr_position_valid_invalid, attr_to_name(), attr::coord_geo, dbg, vehicle_priv::direction, vehicle_priv::fix_type, vehicle_priv::fixiso8601, vehicle_priv::geo, vehicle_priv::height, lvl_debug, attr::num, attr::numd, vehicle_priv::radius, vehicle_priv::sats, vehicle_priv::sats_used, vehicle_priv::speed, attr::str, type, attr::type, attr::u, and vehicle_priv::valid.

static void vehicle_android_position_callback ( struct vehicle_priv v,
jobject  location 
)
static
static void vehicle_android_status_callback ( struct vehicle_priv v,
int  sats_in_view,
int  sats_used 
)
static

Called when a new GPS status has been reported.

This function is called by

NavitLocationListener

upon receiving a new

GpsStatus

.

Note that

sats_used

should not be used to determine whether the vehicle's position is valid: some devices report non-zero numbers even when they do not have a fix. Position validity should be determined in

(an invalid fix type means we have lost the fix) and

(receiving a position means we have a fix).

Parameters
vThe
struct_vehicle_priv
for the vehicle
sats_in_viewThe number of satellites in view
sats_usedThe number of satellites currently used to determine the position

References callback_list_call_attr_0, vehicle_priv::cbl, vehicle_priv::sats, and vehicle_priv::sats_used.

Referenced by vehicle_android_new_android().

Variable Documentation

struct vehicle_methods vehicle_android_methods
Initial value:
= {
}
static void vehicle_android_destroy(struct vehicle_priv *priv)
Free the android_vehicle.
Definition: vehicle_android.c:73
static int vehicle_android_position_attr_get(struct vehicle_priv *priv, enum attr_type type, struct attr *attr)
Retrieves a vehicle attribute.
Definition: vehicle_android.c:88

Referenced by vehicle_android_new_android().