diff options
author | Paul Wise <pabs3@bonedaddy.net> | 2012-01-03 17:09:25 +0800 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2012-01-17 08:11:07 +0100 |
commit | 9dd1f00e836044d9378350882e54c8c7442b3e60 (patch) | |
tree | c355ec185247dcc2bc5db192b13c74faf9bfac5c /src/host/layer23 | |
parent | 217d4f29882abd7c69c55eb60ffe68e7881ccee9 (diff) |
host: Add support for the new gpsd API
Written-by: Paul Wise <pabs3@bonedaddy.net>
Acked-by: Peter Stuge <peter@stuge.se>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host/layer23')
-rw-r--r-- | src/host/layer23/src/common/gps.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/host/layer23/src/common/gps.c b/src/host/layer23/src/common/gps.c index 38aae2ca..e9aaa97c 100644 --- a/src/host/layer23/src/common/gps.c +++ b/src/host/layer23/src/common/gps.c @@ -56,7 +56,12 @@ static struct osmo_fd gps_bfd; #ifdef _HAVE_GPSD -static struct gps_data_t* gdata; +static struct gps_data_t* gdata = NULL; + +#if GPSD_API_MAJOR_VERSION >= 5 +static struct gps_data_t _gdata; +#define gps_poll gps_read +#endif int osmo_gpsd_cb(struct osmo_fd *bfd, unsigned int what) { @@ -69,9 +74,15 @@ int osmo_gpsd_cb(struct osmo_fd *bfd, unsigned int what) if (gdata->online) goto gps_not_ready; +#if GPSD_API_MAJOR_VERSION >= 5 + /* gps has no data */ + if (gps_waiting(gdata, 500)) + goto gps_not_ready; +#else /* gps has no data */ if (gps_waiting(gdata)) goto gps_not_ready; +#endif /* polling returned an error */ if (gps_poll(gdata)) @@ -111,7 +122,14 @@ int osmo_gpsd_open(void) gps_bfd.when = BSC_FD_READ; gps_bfd.cb = osmo_gpsd_cb; +#if GPSD_API_MAJOR_VERSION >= 5 + if (gps_open(g.gpsd_host, g.gpsd_port, &_gdata) == -1) + gdata = NULL; + else + gdata = &_gdata; +#else gdata = gps_open(g.gpsd_host, g.gpsd_port); +#endif if (gdata == NULL) { LOGP(DGPS, LOGL_ERROR, "Can't connect to gpsd\n"); return -1; @@ -139,6 +157,9 @@ void osmo_gpsd_close(void) osmo_fd_unregister(&gps_bfd); +#if GPSD_API_MAJOR_VERSION >= 5 + gps_stream(gdata, WATCH_DISABLE, NULL); +#endif gps_close(gdata); gps_bfd.fd = -1; /* -1 or 0 indicates: 'close' */ } |