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>
33 #include "mapper-types.h"
36 #define GPS_READ_BUF_SIZE (1024)
39 * Types of GPS data sources
43 GPS_IO_RFCOMM=1, /* Bluetooth rfcomm socket */
44 GPS_IO_HILDON_DBUS, /* Request rfcomm using hildon bluetooth D-Bus */
45 GPS_IO_BLUEZ_DBUS, /* Request rfcomm using bluez bluetooth D-Bus*/
46 GPS_IO_FILE, /* File or (serial) device node */
48 GPS_IO_GPSD, /* TCP connection to gpsd (as TCP, but will send a request for NMEA mode */
49 GPS_IO_GYPSY, /* Gypsy events */
50 GPS_IO_SIMULATION, /* Random movement */
54 typedef struct _GpsTypes GpsTypes;
58 gboolean scan; /* Can scan for device */
59 gboolean address; /* Needs address */
60 gboolean port; /* Needs port */
61 guint port_def; /* Default port */
62 const gchar *address_def; /* Default mac/ip/device */
65 /** This enumerated type defines the possible connection states. */
77 typedef struct _GpsIO GpsIO;
80 gchar *address; /* BT MAC, File path or IP */
85 DBusConnection *dbus_conn;
86 DBusGProxy *rfcomm_req_proxy;
88 struct sockaddr_rc rcvr_addr_rc;
90 struct sockaddr_in rcvr_addr_in;
91 /* Channel callback IDs*/
96 guint errors; /* G_IO_STATUS_ERRROR counter */
97 guint again; /* G_IO_STATUS_AGAIN counter */
99 gchar buffer[GPS_READ_BUF_SIZE];
102 /* Latest NMEA line, ready for parsing */
110 typedef struct _Gps Gps;
112 gchar *name; /* Name of the connection */
115 /* Event callbacks */
118 gboolean(* connection_error) (Gps *gps, const gchar *error_str);
120 /* Connection retry */
121 gboolean(* connection_retry) (Gps *gps, const gchar *error_str);
123 /* Connection progress */
124 gboolean(* connection_progress)(Gps *gps, gdouble fix);
127 gboolean(* update_location)(Gps *gps);
128 gboolean(* update_satellite)(Gps *gps);
129 gboolean(* update_info)(Gps *gps);
135 const GpsTypes *gps_get_supported_types(void);
137 Gps *gps_new(GpsIOSourceType type);
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);