Ubuntu Platform API  2.0.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 
185 typedef uint16_t UHardwareGpsAidingData;
186 
187 #define U_HARDWARE_GPS_DELETE_EPHEMERIS 0x0001
188 #define U_HARDWARE_GPS_DELETE_ALMANAC 0x0002
189 #define U_HARDWARE_GPS_DELETE_POSITION 0x0004
190 #define U_HARDWARE_GPS_DELETE_TIME 0x0008
191 #define U_HARDWARE_GPS_DELETE_IONO 0x0010
192 #define U_HARDWARE_GPS_DELETE_UTC 0x0020
193 #define U_HARDWARE_GPS_DELETE_HEALTH 0x0040
194 #define U_HARDWARE_GPS_DELETE_SVDIR 0x0080
195 #define U_HARDWARE_GPS_DELETE_SVSTEER 0x0100
196 #define U_HARDWARE_GPS_DELETE_SADATA 0x0200
197 #define U_HARDWARE_GPS_DELETE_RTI 0x0400
198 #define U_HARDWARE_GPS_DELETE_CELLDB_INFO 0x8000
199 #define U_HARDWARE_GPS_DELETE_ALL 0xFFFF
200 
202 typedef uint16_t UHardwareGpsAGpsType;
203 #define U_HARDWARE_GPS_AGPS_TYPE_SUPL 1
204 #define U_HARDWARE_GPS_AGPS_TYPE_C2K 2
205 
208 #define U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_GSM_CELLID 1
209 
210 #define U_HARDWARE_GPS_AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2
211 
212 #define U_HARDWARE_GPS_AGPS_REG_LOCATION_TYPE_MAC 3
213 
215 #define U_HARDWARE_GPS_LOCATION_HAS_LAT_LONG 0x0001
216 
217 #define U_HARDWARE_GPS_LOCATION_HAS_ALTITUDE 0x0002
218 
219 #define U_HARDWARE_GPS_LOCATION_HAS_SPEED 0x0004
220 
221 #define U_HARDWARE_GPS_LOCATION_HAS_BEARING 0x0008
222 
223 #define U_HARDWARE_GPS_LOCATION_HAS_ACCURACY 0x0010
224 
225 typedef struct UHardwareGps_* UHardwareGps;
226 
231 typedef struct
232 {
234  size_t size;
236  uint16_t flags;
238  double latitude;
240  double longitude;
242  double altitude;
244  float speed;
246  float bearing;
248  float accuracy;
250  int64_t timestamp;
252 
257 typedef struct {
259  size_t size;
261  int prn;
263  float snr;
265  float elevation;
267  float azimuth;
269 
274 typedef struct {
276  size_t size;
277 
279  int num_svs;
280 
283 
287  uint32_t ephemeris_mask;
288 
292  uint32_t almanac_mask;
293 
300 
305 typedef struct {
307  size_t size;
308 
309  uint16_t type;
310  uint16_t status;
311  uint32_t ipaddr;
313 
315 typedef struct
316 {
321  uint16_t type;
323  uint16_t mcc;
325  uint16_t mnc;
327  uint16_t lac;
329  uint32_t cid;
331 
333 typedef struct
334 {
336  uint8_t mac[6];
338 
340 typedef struct
341 {
347  uint16_t type;
348  union {
351  } u;
353 
358 typedef struct {
360  size_t size;
361 
367 
372  uint32_t ni_type;
373 
377  UHardwareGpsNiNotifyFlags notify_flags;
378 
383  int timeout;
384 
388  UHardwareGpsUserResponseType default_response;
389 
394 
399 
403  UHardwareGpsNiEncodingType requestor_id_encoding;
404 
408  UHardwareGpsNiEncodingType text_encoding;
409 
416 
418 
419 typedef void (*UHardwareGpsLocationCallback)(UHardwareGpsLocation *location, void *context);
420 typedef void (*UHardwareGpsStatusCallback)(uint16_t status, void *context);
421 typedef void (*UHardwareGpsSvStatusCallback)(UHardwareGpsSvStatus *sv_info, void *context);
422 typedef void (*UHardwareGpsNmeaCallback)(int64_t timestamp, const char *nmea, int length, void *context);
423 typedef void (*UHardwareGpsSetCapabilities)(uint32_t capabilities, void *context);
424 typedef void (*UHardwareGpsRequestUtcTime)(void *context);
425 
427 typedef void (*UHardwareGpsXtraDownloadRequest)(void *context);
428 
430 typedef void (*UHardwareGpsAGpsStatusCallback)(UHardwareGpsAGpsStatus *status, void *context);
431 
433 typedef void (*UHardwareGpsNiNotifyCallback)(UHardwareGpsNiNotification *notification, void *context);
434 
436 typedef void (*UHardwareGpsAGpsRilRequestSetId)(uint32_t flags, void *context);
438 typedef void (*UHardwareGpsAGpsRilRequestRefLoc)(uint32_t flags, void *context);
439 
440 typedef struct
441 {
442 
449 
451 
453 
455 
458 
459  void* context;
461 
462 /*
463  You must create only one instance per process/application.
464 */
465 UBUNTU_DLL_PUBLIC UHardwareGps
467 
469 u_hardware_gps_delete(UHardwareGps handle);
470 
472 u_hardware_gps_start(UHardwareGps self);
473 
475 u_hardware_gps_stop(UHardwareGps self);
476 
484  UHardwareGps self,
485  int64_t time,
486  int64_t time_reference,
487  int uncertainty);
488 
499  UHardwareGps self,
500  UHardwareGpsLocation location);
501 
510  UHardwareGps self,
511  UHardwareGpsAGpsRefLocation *location,
512  size_t size_of_struct);
513 
521  UHardwareGps self,
522  const char *apn);
523 
530  UHardwareGps self);
531 
538  UHardwareGps self);
539 
549  UHardwareGps self,
550  UHardwareGpsAGpsType type,
551  const char* hostname,
552  uint16_t port);
553 
561  UHardwareGps self,
562  UHardwareGpsAidingData flags);
563 
574  UHardwareGps self,
575  uint32_t mode,
576  uint32_t recurrence,
577  uint32_t min_interval,
578  uint32_t preferred_accuracy,
579  uint32_t preferred_time);
580 
583  UHardwareGps self,
584  char* data,
585  int length);
586 
587 #ifdef __cplusplus
588 }
589 #endif
590 
591 #endif // UBUNTU_HARDWARE_GPS_H_
UHardwareGpsUserResponseType default_response
Definition: gps.h:388
void(* UHardwareGpsRequestUtcTime)(void *context)
Definition: gps.h:424
#define U_HARDWARE_GPS_MAX_SVS
Definition: gps.h:37
UBUNTU_DLL_PUBLIC void u_hardware_gps_agps_set_server_for_type(UHardwareGps self, UHardwareGpsAGpsType type, const char *hostname, uint16_t port)
Sets the hostname and port for the AGPS server.
float elevation
Definition: gps.h:265
UBUNTU_DLL_PUBLIC bool u_hardware_gps_stop(UHardwareGps self)
UHardwareGpsSvStatusCallback sv_status_cb
Definition: gps.h:445
UHardwareGpsRequestUtcTime request_utc_time_cb
Definition: gps.h:448
uint32_t almanac_mask
Definition: gps.h:292
double longitude
Definition: gps.h:240
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)
Sets the positioning mode of the chipset.
uint16_t UHardwareGpsAGpsType
Definition: gps.h:202
#define U_HARDWARE_GPS_NI_LONG_STRING_MAXLEN
Definition: gps.h:112
Describes a wifi ID as understood by the GPS chipset.
Definition: gps.h:333
UHardwareGpsNiNotifyCallback gps_ni_notify_cb
Definition: gps.h:454
UHardwareGpsNmeaCallback nmea_cb
Definition: gps.h:446
void(* UHardwareGpsSetCapabilities)(uint32_t capabilities, void *context)
Definition: gps.h:423
uint16_t type
Definition: gps.h:309
void * context
Definition: gps.h:459
uint32_t ephemeris_mask
Definition: gps.h:287
#define U_HARDWARE_GPS_NI_SHORT_STRING_MAXLEN
Definition: gps.h:111
Describes a reference location, either a radio cell or a wifi.
Definition: gps.h:340
UHardwareGpsSetCapabilities set_capabilities_cb
Definition: gps.h:447
void(* UHardwareGpsAGpsRilRequestSetId)(uint32_t flags, void *context)
Definition: gps.h:436
UBUNTU_DLL_PUBLIC UHardwareGps u_hardware_gps_new(UHardwareGpsParams *params)
uint32_t UHardwareGpsNiNotifyFlags
Definition: gps.h:78
uint32_t ipaddr
Definition: gps.h:311
int UHardwareGpsNiEncodingType
Definition: gps.h:118
UBUNTU_DLL_PUBLIC void u_hardware_gps_inject_xtra_data(UHardwareGps self, char *data, int length)
UBUNTU_DLL_PUBLIC void u_hardware_gps_agps_notify_connection_not_available(UHardwareGps self)
Notifies the chipset that an AGPS data connection is not available.
UHardwareGpsAGpsRefLocationCellID cellID
Definition: gps.h:349
UHardwareGpsNiEncodingType requestor_id_encoding
Definition: gps.h:403
UBUNTU_DLL_PUBLIC void u_hardware_gps_delete_aiding_data(UHardwareGps self, UHardwareGpsAidingData flags)
Requests the chipset to delete the aiding data specified in flags.
size_t size
Definition: gps.h:259
UBUNTU_DLL_PUBLIC bool u_hardware_gps_start(UHardwareGps self)
UHardwareGpsAGpsRilRequestRefLoc request_refloc_cb
Definition: gps.h:457
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)
Injects a new reference time into the GPS chipset.
UHardwareGpsNiEncodingType text_encoding
Definition: gps.h:408
uint16_t UHardwareGpsAidingData
Definition: gps.h:185
UBUNTU_DLL_PUBLIC void u_hardware_gps_inject_location(UHardwareGps self, UHardwareGpsLocation location)
Injects a new reference location into the GPS chipset.
UBUNTU_DLL_PUBLIC void u_hardware_gps_agps_notify_connection_is_closed(UHardwareGps self)
Notifies the chipset that an AGPS data connection has been closed.
#define U_HARDWARE_GPS_AGPS_TYPE_SUPL
Definition: gps.h:203
UHardwareGpsNiNotifyFlags notify_flags
Definition: gps.h:377
void(* UHardwareGpsLocationCallback)(UHardwareGpsLocation *location, void *context)
Definition: gps.h:419
UHardwareGpsLocationCallback location_cb
Definition: gps.h:443
uint32_t used_in_fix_mask
Definition: gps.h:298
UHardwareGpsAGpsStatusCallback agps_status_cb
Definition: gps.h:452
void(* UHardwareGpsStatusCallback)(uint16_t status, void *context)
Definition: gps.h:420
int64_t timestamp
Definition: gps.h:250
uint16_t status
Definition: gps.h:310
UBUNTU_DLL_PUBLIC void u_hardware_gps_agps_notify_connection_is_open(UHardwareGps self, const char *apn)
Notifies the chipset that a data connection is availble.
void(* UHardwareGpsNmeaCallback)(int64_t timestamp, const char *nmea, int length, void *context)
Definition: gps.h:422
#define UBUNTU_DLL_PUBLIC
Definition: visibility.h:25
UHardwareGpsStatusCallback status_cb
Definition: gps.h:444
UHardwareGpsXtraDownloadRequest xtra_download_request_cb
Definition: gps.h:450
UHardwareGpsAGpsRefLocationMac mac
Definition: gps.h:350
void(* UHardwareGpsSvStatusCallback)(UHardwareGpsSvStatus *sv_info, void *context)
Definition: gps.h:421
Describes a cell ID as understood by the GPS chipset.
Definition: gps.h:315
UBUNTU_DLL_PUBLIC void u_hardware_gps_agps_set_reference_location(UHardwareGps self, UHardwareGpsAGpsRefLocation *location, size_t size_of_struct)
Informs the GPS chipset about wifi ap's or radio cells to be used in AGPS calls.
void(* UHardwareGpsXtraDownloadRequest)(void *context)
Definition: gps.h:427
UBUNTU_DLL_PUBLIC void u_hardware_gps_delete(UHardwareGps handle)
uint16_t flags
Definition: gps.h:236
double altitude
Definition: gps.h:242
struct UHardwareGps_ * UHardwareGps
Definition: gps.h:225
float azimuth
Definition: gps.h:267
float accuracy
Definition: gps.h:248
double latitude
Definition: gps.h:238
void(* UHardwareGpsNiNotifyCallback)(UHardwareGpsNiNotification *notification, void *context)
Definition: gps.h:433
#define U_HARDWARE_GPS_AGPS_TYPE_C2K
Definition: gps.h:204
void(* UHardwareGpsAGpsRilRequestRefLoc)(uint32_t flags, void *context)
Definition: gps.h:438
void(* UHardwareGpsAGpsStatusCallback)(UHardwareGpsAGpsStatus *status, void *context)
Definition: gps.h:430
UHardwareGpsAGpsRilRequestSetId request_setid_cb
Definition: gps.h:456