15 #include <glib/gstdio.h>
17 #include <dbus/dbus.h>
18 #include <dbus/dbus-glib.h>
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <netinet/in.h>
22 #include <netinet/ip.h>
25 #include <bluetooth/bluetooth.h>
26 #include <bluetooth/hci.h>
27 #include <bluetooth/hci_lib.h>
28 #include <bluetooth/rfcomm.h>
32 #include "mapper-types.h"
35 #define GPS_READ_BUF_SIZE (1024)
38 * Types of GPS data sources
42 GPS_IO_RFCOMM=1, /* Bluetooth rfcomm socket */
43 GPS_IO_HILDON_DBUS, /* Request rfcomm using hildon bluetooth D-Bus */
44 GPS_IO_BLUEZ_DBUS, /* Request rfcomm using bluez bluetooth D-Bus*/
45 GPS_IO_FILE, /* File or (serial) device node */
47 GPS_IO_GPSD, /* TCP connection to gpsd (as TCP, but will send a request for NMEA mode */
48 GPS_IO_GYPSY, /* Gypsy events */
49 GPS_IO_SIMULATION, /* Random movement */
53 typedef struct _GpsTypes GpsTypes;
57 gboolean scan; /* Can scan for device */
58 gboolean address; /* Needs address */
59 gboolean port; /* Needs port */
60 guint port_def; /* Default port */
61 const gchar *address_def; /* Default mac/ip/device */
64 /** This enumerated type defines the possible connection states. */
76 typedef struct _GpsIO GpsIO;
79 gchar *address; /* BT MAC, File path or IP */
84 DBusConnection *dbus_conn;
85 DBusGProxy *rfcomm_req_proxy;
87 struct sockaddr_rc rcvr_addr_rc;
89 struct sockaddr_in rcvr_addr_in;
90 /* Channel callback IDs*/
95 guint errors; /* G_IO_STATUS_ERRROR counter */
96 guint again; /* G_IO_STATUS_AGAIN counter */
98 gchar buffer[GPS_READ_BUF_SIZE];
101 /* Latest NMEA line, ready for parsing */
109 typedef struct _Gps Gps;
111 gchar *name; /* Name of the connection */
114 /* Event callbacks */
117 gboolean(* connection_error) (Gps *gps, const gchar *error_str);
119 /* Connection retry */
120 gboolean(* connection_retry) (Gps *gps, const gchar *error_str);
122 /* Connection progress */
123 gboolean(* connection_progress)(Gps *gps, gdouble fix);
126 gboolean(* update_location)(Gps *gps);
127 gboolean(* update_satellite)(Gps *gps);
128 gboolean(* update_info)(Gps *gps);
134 const GpsTypes *gps_get_supported_types(void);
136 Gps *gps_new(GpsIOSourceType type);
137 void gps_clear(Gps *gps);
138 void gps_set_address(Gps *gps, gchar *address, guint port);
139 void gps_set_type(Gps *gps, GpsIOSourceType type);
140 void gps_free(Gps *gps);
141 void gps_data_integerize(GpsData *gpsdata);
142 gboolean gps_connect(Gps *gps);
143 gboolean gps_connect_now(Gps *gps);
144 void gps_connect_later(Gps *gps);
145 void gps_disconnect(Gps *gps);