Contents of /trunk/src/gps.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 124 - (show annotations)
Tue Mar 17 12:04:48 2009 UTC (15 years, 2 months ago) by harbaum
File MIME type: text/plain
File size: 2718 byte(s)
Maemo version detection
1 /*
2 * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3 *
4 * This file is based upon parts of gpsd/libgps
5 *
6 * This file is part of OSM2Go.
7 *
8 * OSM2Go is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * OSM2Go is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23 #ifndef GPS_H
24 #define GPS_H
25
26 #ifndef NAN
27 #define NAN (0.0/0.0)
28 #endif /* !NAN */
29
30 #define MAXTAGLEN 8 /* maximum length of sentence tag name */
31 #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */
32
33 struct gps_fix_t {
34 int mode; /* Mode of fix */
35 #define MODE_NOT_SEEN 0 /* mode update not seen yet */
36 #define MODE_NO_FIX 1 /* none */
37 #define MODE_2D 2 /* good for latitude/longitude */
38 #define MODE_3D 3 /* good for altitude/climb too */
39 pos_t pos; /* Latitude/Longitude in degrees (valid if mode >= 2) */
40 double eph; /* Horizontal position uncertainty, meters */
41 };
42
43 typedef unsigned int gps_mask_t;
44
45 struct gps_data_t {
46 gps_mask_t set; /* has field been set since this was last cleared? */
47 #define LATLON_SET 0x00000008u
48 #define STATUS_SET 0x00000100u
49 #define MODE_SET 0x00000200u
50 #define SATELLITE_SET 0x00040000u
51
52 struct gps_fix_t fix; /* accumulated PVT data */
53
54 /* GPS status -- always valid */
55 int status; /* Do we have a fix? */
56 #define STATUS_NO_FIX 0 /* no */
57 #define STATUS_FIX 1 /* yes, without DGPS */
58 #define STATUS_DGPS_FIX 2 /* yes, with DGPS */
59
60 };
61
62 #ifdef ENABLE_LIBLOCATION
63 #include <location/location-gps-device.h>
64 #include <location/location-gpsd-control.h>
65 #endif
66
67 #ifdef ENABLE_GPSBT
68 #include <gpsbt.h>
69 #include <gpsmgr.h>
70 #endif
71
72 typedef struct gps_state_s {
73 #ifdef ENABLE_LIBLOCATION
74 LocationGPSDevice *device;
75 #if MAEMO_VERSION_MAJOR < 5
76 LocationGPSDControl *control;
77 #endif
78 guint idd_changed;
79
80 gboolean fix;
81 double latitude, longitude;
82
83 #else
84 /* setup for direct gpsd based communication */
85
86 #ifdef ENABLE_GPSBT
87 gpsbt_t context;
88 #endif
89
90 GThread* thread_p;
91 GMutex *mutex;
92 GnomeVFSInetConnection *iconn;
93 GnomeVFSSocket *socket;
94
95 struct gps_data_t gpsdata;
96 #endif
97 } gps_state_t;
98
99 void gps_init(appdata_t *appdata);
100 void gps_release(appdata_t *appdata);
101 pos_t *gps_get_pos(appdata_t *appdata);
102
103 #endif // GPS_H