Ubuntu Platform API  1.1.0
A library helping with tight integration into the Ubuntu platform
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gps.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
17  * Authored by: Thomas Voß <thomas.voss@canonical.com>
18  */
19 #ifndef UBUNTU_HARDWARE_GPS_H_
20 #define UBUNTU_HARDWARE_GPS_H_
21 
22 #include <ubuntu/visibility.h>
23 
24 #include <stdint.h>
25 #include <stddef.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
37 #define U_HARDWARE_GPS_MAX_SVS 32
38 
43 enum
44 {
55 };
56 
64 #define U_HARDWARE_GPS_CAPABILITY_SCHEDULING 0x0000001
65 
66 #define U_HARDWARE_GPS_CAPABILITY_MSB 0x0000002
67 
68 #define U_HARDWARE_GPS_CAPABILITY_MSA 0x0000004
69 
70 #define U_HARDWARE_GPS_CAPABILITY_SINGLE_SHOT 0x0000008
71 
72 #define U_HARDWARE_GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010
73 
78 typedef uint32_t UHardwareGpsNiNotifyFlags;
80 #define U_HARDWARE_GPS_NI_NEED_NOTIFY 0x0001
81 
82 #define U_HARDWARE_GPS_NI_NEED_VERIFY 0x0002
83 
84 #define U_HARDWARE_GPS_NI_PRIVACY_OVERRIDE 0x0004
85 
92 
93 enum
94 {
98 };
99 
100 enum
101 {
105 };
106 
111 #define U_HARDWARE_GPS_NI_SHORT_STRING_MAXLEN 256
112 #define U_HARDWARE_GPS_NI_LONG_STRING_MAXLEN 2048
113 
119 
124 enum
125 {
131 };
132 
137 enum
138 {
141 };
142 
147 enum
148 {
155 };
156 
161 enum
162 {
167 };
168 
169 enum
170 {
181 };
182 
184 #define U_HARDWARE_GPS_LOCATION_HAS_LAT_LONG 0x0001
185 
186 #define U_HARDWARE_GPS_LOCATION_HAS_ALTITUDE 0x0002
187 
188 #define U_HARDWARE_GPS_LOCATION_HAS_SPEED 0x0004
189 
190 #define U_HARDWARE_GPS_LOCATION_HAS_BEARING 0x0008
191 
192 #define U_HARDWARE_GPS_LOCATION_HAS_ACCURACY 0x0010
193 
194 typedef struct UHardwareGps_* UHardwareGps;
195 
200 typedef struct
201 {
203  size_t size;
205  uint16_t flags;
207  double latitude;
209  double longitude;
212  double altitude;
214  float speed;
216  float bearing;
218  float accuracy;
220  int64_t timestamp;
222 
227 typedef struct {
229  size_t size;
231  int prn;
233  float snr;
235  float elevation;
237  float azimuth;
239 
244 typedef struct {
246  size_t size;
247 
249  int num_svs;
250 
253 
257  uint32_t ephemeris_mask;
258 
262  uint32_t almanac_mask;
263 
270 
275 typedef struct {
277  size_t size;
278 
279  uint16_t type;
280  uint16_t status;
281  uint32_t ipaddr;
283 
288 typedef struct {
290  size_t size;
291 
297 
302  uint32_t ni_type;
303 
307  UHardwareGpsNiNotifyFlags notify_flags;
308 
313  int timeout;
314 
318  UHardwareGpsUserResponseType default_response;
319 
324 
329 
333  UHardwareGpsNiEncodingType requestor_id_encoding;
334 
338  UHardwareGpsNiEncodingType text_encoding;
339 
346 
348 
349 typedef void (*UHardwareGpsLocationCallback)(UHardwareGpsLocation *location, void *context);
350 typedef void (*UHardwareGpsStatusCallback)(uint16_t status, void *context);
351 typedef void (*UHardwareGpsSvStatusCallback)(UHardwareGpsSvStatus *sv_info, void *context);
352 typedef void (*UHardwareGpsNmeaCallback)(int64_t timestamp, const char *nmea, int length, void *context);
353 typedef void (*UHardwareGpsSetCapabilities)(uint32_t capabilities, void *context);
354 typedef void (*UHardwareGpsRequestUtcTime)(void *context);
355 
359 typedef void (*UHardwareGpsXtraDownloadRequest)(void *context);
360 
363 typedef void (*UHardwareGpsAGpsStatusCallback)(UHardwareGpsAGpsStatus *status, void *context);
364 
367 typedef void (*UHardwareGpsNiNotifyCallback)(UHardwareGpsNiNotification *notification, void *context);
368 
369 /*
370  Callback for AGPS RIL (Radio Interface Library) set id
371 */
372 typedef void (*UHardwareGpsAGpsRilRequestSetId)(uint32_t flags, void *context);
373 typedef void (*UHardwareGpsAGpsRilRequestRefLoc)(uint32_t flags, void *context);
374 
375 typedef struct
376 {
377 
384 
386 
388 
390 
393 
394  void* context;
396 
397 /*
398  You must create only one instance per process/application.
399 */
400 UBUNTU_DLL_PUBLIC UHardwareGps
402 
404 u_hardware_gps_delete(UHardwareGps handle);
405 
407 u_hardware_gps_start(UHardwareGps self);
408 
410 u_hardware_gps_stop(UHardwareGps self);
411 
412 /*
413  \param time NTP time, in milliseconds since Jan 1st 1970.
414  \param time_reference time from the internal clock at the moment that NTP time was taken.
415  \param uncertainty possible deviation in the time supplied (uncertainty) in milliseconds.
416  */
419  UHardwareGps self,
420  int64_t time,
421  int64_t time_reference,
422  int uncertainty);
423 
426  UHardwareGps self,
427  double latitude,
428  double longitude,
429  float accuracy);
430 
433  UHardwareGps self,
434  uint16_t flags);
435 
436 /*
437  \param mode One of the U_HARDWARE_GPS_POSITION_MODE_* values
438  \param recurrence One of the U_HARDWARE_GPS_POSITION_RECURRENCE_* values
439  \param min_interval represents the time between fixes in milliseconds.
440  \param preferred_accuracy The requested fix accuracy in meters. Can be zero.
441  \param preferred_time The requested time to first fix in milliseconds. Can be zero.
442  */
445  UHardwareGps self,
446  uint32_t mode,
447  uint32_t recurrence,
448  uint32_t min_interval,
449  uint32_t preferred_accuracy,
450  uint32_t preferred_time);
451 
454  UHardwareGps self,
455  char* data,
456  int length);
457 
458 #ifdef __cplusplus
459 }
460 #endif
461 
462 #endif // UBUNTU_HARDWARE_GPS_H_
UHardwareGpsUserResponseType default_response
Definition: gps.h:318
void(* UHardwareGpsRequestUtcTime)(void *context)
Definition: gps.h:354
#define U_HARDWARE_GPS_MAX_SVS
Definition: gps.h:37
float elevation
Definition: gps.h:235
UBUNTU_DLL_PUBLIC bool u_hardware_gps_stop(UHardwareGps self)
UHardwareGpsSvStatusCallback sv_status_cb
Definition: gps.h:380
UHardwareGpsRequestUtcTime request_utc_time_cb
Definition: gps.h:383
uint32_t almanac_mask
Definition: gps.h:262
double longitude
Definition: gps.h:209
UBUNTU_DLL_PUBLIC bool u_hardware_gps_set_position_mode(UHardwareGps self, uint32_t mode, uint32_t recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time)
#define U_HARDWARE_GPS_NI_LONG_STRING_MAXLEN
Definition: gps.h:112
UHardwareGpsNiNotifyCallback gps_ni_notify_cb
Definition: gps.h:389
UHardwareGpsNmeaCallback nmea_cb
Definition: gps.h:381
void(* UHardwareGpsSetCapabilities)(uint32_t capabilities, void *context)
Definition: gps.h:353
uint16_t type
Definition: gps.h:279
void * context
Definition: gps.h:394
uint32_t ephemeris_mask
Definition: gps.h:257
#define U_HARDWARE_GPS_NI_SHORT_STRING_MAXLEN
Definition: gps.h:111
UHardwareGpsSetCapabilities set_capabilities_cb
Definition: gps.h:382
void(* UHardwareGpsAGpsRilRequestSetId)(uint32_t flags, void *context)
Definition: gps.h:372
UBUNTU_DLL_PUBLIC UHardwareGps u_hardware_gps_new(UHardwareGpsParams *params)
uint32_t UHardwareGpsNiNotifyFlags
Definition: gps.h:78
uint32_t ipaddr
Definition: gps.h:281
int UHardwareGpsNiEncodingType
Definition: gps.h:118
UBUNTU_DLL_PUBLIC void u_hardware_gps_inject_xtra_data(UHardwareGps self, char *data, int length)
UHardwareGpsNiEncodingType requestor_id_encoding
Definition: gps.h:333
size_t size
Definition: gps.h:229
UBUNTU_DLL_PUBLIC bool u_hardware_gps_start(UHardwareGps self)
UHardwareGpsAGpsRilRequestRefLoc request_refloc_cb
Definition: gps.h:392
int UHardwareGpsUserResponseType
Definition: gps.h:91
UBUNTU_DLL_PUBLIC void u_hardware_gps_inject_time(UHardwareGps self, int64_t time, int64_t time_reference, int uncertainty)
UHardwareGpsNiEncodingType text_encoding
Definition: gps.h:338
UHardwareGpsNiNotifyFlags notify_flags
Definition: gps.h:307
void(* UHardwareGpsLocationCallback)(UHardwareGpsLocation *location, void *context)
Definition: gps.h:349
UHardwareGpsLocationCallback location_cb
Definition: gps.h:378
uint32_t used_in_fix_mask
Definition: gps.h:268
UBUNTU_DLL_PUBLIC void u_hardware_gps_inject_location(UHardwareGps self, double latitude, double longitude, float accuracy)
UHardwareGpsAGpsStatusCallback agps_status_cb
Definition: gps.h:387
void(* UHardwareGpsStatusCallback)(uint16_t status, void *context)
Definition: gps.h:350
int64_t timestamp
Definition: gps.h:220
uint16_t status
Definition: gps.h:280
void(* UHardwareGpsNmeaCallback)(int64_t timestamp, const char *nmea, int length, void *context)
Definition: gps.h:352
#define UBUNTU_DLL_PUBLIC
Definition: visibility.h:25
UHardwareGpsStatusCallback status_cb
Definition: gps.h:379
UHardwareGpsXtraDownloadRequest xtra_download_request_cb
Definition: gps.h:385
void(* UHardwareGpsSvStatusCallback)(UHardwareGpsSvStatus *sv_info, void *context)
Definition: gps.h:351
void(* UHardwareGpsXtraDownloadRequest)(void *context)
Definition: gps.h:359
UBUNTU_DLL_PUBLIC void u_hardware_gps_delete(UHardwareGps handle)
uint16_t flags
Definition: gps.h:205
double altitude
Definition: gps.h:212
struct UHardwareGps_ * UHardwareGps
Definition: gps.h:194
float azimuth
Definition: gps.h:237
float accuracy
Definition: gps.h:218
double latitude
Definition: gps.h:207
void(* UHardwareGpsNiNotifyCallback)(UHardwareGpsNiNotification *notification, void *context)
Definition: gps.h:367
void(* UHardwareGpsAGpsRilRequestRefLoc)(uint32_t flags, void *context)
Definition: gps.h:373
void(* UHardwareGpsAGpsStatusCallback)(UHardwareGpsAGpsStatus *status, void *context)
Definition: gps.h:363
UBUNTU_DLL_PUBLIC void u_hardware_gps_delete_aiding_data(UHardwareGps self, uint16_t flags)
UHardwareGpsAGpsRilRequestSetId request_setid_cb
Definition: gps.h:391