00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _HARDWARE_GPS_H
00018 #define _HARDWARE_GPS_H
00019
00020 #include <stdint.h>
00021
00022 #if __cplusplus
00023 extern "C" {
00024 #endif
00025
00026
00027 typedef int64_t GpsUtcTime;
00028
00029
00030 #define GPS_MAX_SVS 32
00031
00032
00033 typedef uint16_t GpsPositionMode;
00034
00035
00036
00037 #define GPS_POSITION_MODE_STANDALONE 0
00038
00039 #define GPS_POSITION_MODE_MS_BASED 1
00040
00041 #define GPS_POSITION_MODE_MS_ASSISTED 2
00042
00043
00044 typedef uint16_t GpsStatusValue;
00045
00046
00047
00048 #define GPS_STATUS_NONE 0
00049
00050 #define GPS_STATUS_SESSION_BEGIN 1
00051
00052 #define GPS_STATUS_SESSION_END 2
00053
00054 #define GPS_STATUS_ENGINE_ON 3
00055
00056 #define GPS_STATUS_ENGINE_OFF 4
00057
00058
00059 typedef uint16_t GpsLocationFlags;
00060
00061
00062
00063 #define GPS_LOCATION_HAS_LAT_LONG 0x0001
00064
00065 #define GPS_LOCATION_HAS_ALTITUDE 0x0002
00066
00067 #define GPS_LOCATION_HAS_SPEED 0x0004
00068
00069 #define GPS_LOCATION_HAS_BEARING 0x0008
00070
00071 #define GPS_LOCATION_HAS_ACCURACY 0x0010
00072
00073
00074
00075 typedef uint16_t GpsAidingData;
00076
00077
00078 #define GPS_DELETE_EPHEMERIS 0x0001
00079 #define GPS_DELETE_ALMANAC 0x0002
00080 #define GPS_DELETE_POSITION 0x0004
00081 #define GPS_DELETE_TIME 0x0008
00082 #define GPS_DELETE_IONO 0x0010
00083 #define GPS_DELETE_UTC 0x0020
00084 #define GPS_DELETE_HEALTH 0x0040
00085 #define GPS_DELETE_SVDIR 0x0080
00086 #define GPS_DELETE_SVSTEER 0x0100
00087 #define GPS_DELETE_SADATA 0x0200
00088 #define GPS_DELETE_RTI 0x0400
00089 #define GPS_DELETE_CELLDB_INFO 0x8000
00090 #define GPS_DELETE_ALL 0xFFFF
00091
00092
00093
00094
00095 #define GPS_XTRA_INTERFACE "gps-xtra"
00096
00097
00098
00099
00100 #define GPS_SUPL_INTERFACE "gps-supl"
00101
00102
00103 typedef struct {
00104
00105 uint16_t flags;
00106
00107 double latitude;
00108
00109 double longitude;
00110
00111
00112 double altitude;
00113
00114 float speed;
00115
00116 float bearing;
00117
00118 float accuracy;
00119
00120 GpsUtcTime timestamp;
00121 } GpsLocation;
00122
00123
00124 typedef struct {
00125 GpsStatusValue status;
00126 } GpsStatus;
00127
00128
00129 typedef struct {
00130
00131 int prn;
00132
00133 float snr;
00134
00135 float elevation;
00136
00137 float azimuth;
00138 } GpsSvInfo;
00139
00140
00141 typedef struct {
00142
00143 int num_svs;
00144
00145
00146 GpsSvInfo sv_list[GPS_MAX_SVS];
00147
00148
00149
00150
00151 uint32_t ephemeris_mask;
00152
00153
00154
00155
00156 uint32_t almanac_mask;
00157
00158
00159
00160
00161
00162 uint32_t used_in_fix_mask;
00163 } GpsSvStatus;
00164
00165
00166 typedef void (* gps_location_callback)(GpsLocation* location);
00167
00168
00169 typedef void (* gps_status_callback)(GpsStatus* status);
00170
00171
00172 typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
00173
00174
00175 typedef struct {
00176 gps_location_callback location_cb;
00177 gps_status_callback status_cb;
00178 gps_sv_status_callback sv_status_cb;
00179 } GpsCallbacks;
00180
00181
00182
00183 typedef struct {
00184
00185
00186
00187
00188 int (*init)( GpsCallbacks* callbacks );
00189
00190
00191 int (*start)( void );
00192
00193
00194 int (*stop)( void );
00195
00196
00197 void (*set_fix_frequency)( int frequency );
00198
00199
00200 void (*cleanup)( void );
00201
00202
00203 int (*inject_time)(GpsUtcTime time, int64_t timeReference,
00204 int uncertainty);
00205
00206
00207
00208
00209
00210
00211 void (*delete_aiding_data)(GpsAidingData flags);
00212
00213
00214
00215
00216
00217 int (*set_position_mode)(GpsPositionMode mode, int fix_frequency);
00218
00219
00220 const void* (*get_extension)(const char* name);
00221 } GpsInterface;
00222
00223
00224
00225
00226 typedef void (* gps_xtra_download_request)();
00227
00228
00229 typedef struct {
00230 gps_xtra_download_request download_request_cb;
00231 } GpsXtraCallbacks;
00232
00233
00234 typedef struct {
00235
00236
00237
00238
00239 int (*init)( GpsXtraCallbacks* callbacks );
00240
00241 int (*inject_xtra_data)( char* data, int length );
00242 } GpsXtraInterface;
00243
00244
00245 typedef struct {
00246
00247
00248
00249 int (*set_apn)( const char* apn );
00250 } GpsSuplInterface;
00251
00252
00253 const GpsInterface* gps_get_hardware_interface();
00254
00255
00256
00257
00258 const GpsInterface* gps_get_qemu_interface();
00259
00260
00261
00262
00263 const GpsInterface* gps_get_interface();
00264
00265 #if __cplusplus
00266 }
00267 #endif
00268
00269 #endif // _HARDWARE_GPS_H