]> git.itanic.dy.fi Git - maemo-mapper/blob - src/gpsbt.h
Administrative changes in preparation for release of Maemo Mapper v2.6.2.
[maemo-mapper] / src / gpsbt.h
1 /*
2  * Copyright (C) 2006, 2007 John Costigan.
3  *
4  * POI and GPS-Info code originally written by Cezary Jackiewicz.
5  *
6  * Default map data provided by http://www.openstreetmap.org/
7  *
8  * This file is part of Maemo Mapper.
9  *
10  * Maemo Mapper is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * Maemo Mapper is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Maemo Mapper.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef LEGACY
25 #  include "/usr/include/gpsbt.h"
26 #else
27
28 /*
29 GPS BT management API. The API is used by those applications that
30 wish to use services provided by gps daemon i.e., they wish to receive
31 GPS data from the daemon. See README file for more details.
32
33 Copyright (C) 2006 Nokia Corporation. All rights reserved.
34
35 Author: Jukka Rissanen <jukka.rissanen@nokia.com>
36
37 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
38
39 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
40 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
41 The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
42
43 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
45 */
46
47 /* $Id:$ */
48
49 #include <stdlib.h>
50 #include <stdio.h>
51 #include <sys/types.h>
52 #include <signal.h>
53
54 #include <gpsmgr.h>
55
56 #ifndef gpsbt_included
57 #define gpsbt_included
58
59 /* Internal context information */
60 typedef struct {
61   gpsmgr_t mgr;
62   char **rfcomms; /* what devices where found (null terminated array),
63                    * not used if compiled with USE_AUTOMATIC_DISCONNECT
64                    * (see gpsbt.c for details)
65                    */
66   int timeout; /* timeout for dbus messages */
67 } gpsbt_t;
68
69
70 /* Start function finds out the available GPS BT devices and starts
71  * the gpsd if it is not running. If no GPS BT devices are found, then
72  * an error is returned.
73  *
74  * Parameters:
75  *    bda 
76  *       BT address of the GPS device, normally this is left
77  *       to null but if this API cannot find a suitable GPS
78  *       BT device, the application can ask the BT device
79  *       from the user and supply the address here.
80  *
81  *    debug_level
82  *       debug level (set to 0 to use the default)
83  *
84  *    gpsd_debug_level
85  *       gpsd debug level (set to 0 to use the default)
86  *
87  *    port
88  *       gpsd port (set to 0 to use the default (2947))
89  *
90  *    error_buf
91  *       user supplied error buffer (optional), if there is an error
92  *       the API puts error message to this buffer
93  *
94  *    error_buf_max_len
95  *       max length of the error buffer, set to 0 if error
96  *       message is not needed in caller program
97  *
98  *    timeout_ms
99  *       timeout (in ms) when waiting dbus replies, set to 0 to use
100  *       the library default (5 seconds), if set to <0 then use
101  *       the dbus default (whatever that is).
102  *
103  *    ctx
104  *       caller must allocate and clear this struct before call
105  *
106  * Returns:
107  *    <0 : error, check errno for more details
108  *     0 : ok
109  *
110  * Example:
111  *    The default call would be
112  *         gpsbt_start(NULL, 0, 0, 0, &ctx);
113  *
114  * If the GPSD_PROG environment variable is defined, then it is used
115  * when starting the program, otherwise "gpsd" will be used as a program
116  * name. This way you can override the program name and/or path if necessary.
117  *
118  * If the GPSD_CTRL_SOCK environment variable is defined, then it is used
119  * as a location to gpsd control socket, otherwise the default control socket
120  * is /tmp/.gpsd_ctrl_sock
121  */
122
123 extern int gpsbt_start(char *bda,
124                        int debug_level,
125                        int gpsd_debug_level,
126                        short port,
127                        char *error_buf,
128                        int error_buf_max_len,
129                        int timeout_ms,
130                        gpsbt_t *ctx);
131
132
133 /* Stop function stops the gpsd if it was running and nobody
134  * was using it.
135  *
136  * Parameters:
137  *    ctx : context returned by gpsbt_start()
138  *
139  * Returns:
140  *    <0 : error, check errno for more details
141  *     0 : ok
142  *
143  */
144
145 extern int gpsbt_stop(gpsbt_t *ctx);
146
147 #endif /* gpsbt_included */
148
149 #endif