blob: 046ede21e99acce0fd722c21bba2bca706f11c93 [file] [log] [blame]
zw.wang581aab12025-05-28 19:43:53 +08001/**
2* @file : gsw_gnss_interface.h
3* @brief : gnss function
4* @date : 2022-07-05
5* @author : gaofeng6122
6* @version : v1.0
7* @copyright Copyright(C) 2022,Gosuncnwelink
8*/
9#ifndef __GSW_GNSS_INTERFACE__H__
10#define __GSW_GNSS_INTERFACE__H__
11
12/*********************************************************************************************/
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16#include <unistd.h>
17#include <pthread.h>
18#include <stddef.h>
19#include "gsw_hal_errcode.h"
20
21typedef enum {
22 GNSS_FREQ_1HZ = 1, /**< 1Hz */
23 GNSS_FREQ_2HZ = 2, /**< 2Hz */
24 GNSS_FREQ_5HZ = 5, /**< 5Hz */
25 GNSS_FREQ_10HZ = 10, /**< 10Hz */
26} gnss_freq_type;
27
28#define GNSS_OK GSW_HAL_SUCCESS
29#define GNSS_ERROR GSW_HAL_NORMAL_FAIL
30
31
32typedef struct
33{
34 size_t size; /**< set to sizeof(GpsLocation) */
35
36 unsigned short int flags; /**< Contains GpsLocationFlags bits. */
37
38 double latitude; /**< Represents latitude in degrees. */
39
40 double longitude; /**< Represents longitude in degrees. */
41
42 double altitude; /**< Represents altitude in meters above the WGS 84 reference ellipsoid. */
43
44 float speed; /**< Represents speed in meters per second. */
45
46 float bearing; /**< Represents heading in degrees. */
47
48 float accuracy; /**< Represents expected accuracy in meters. */
49
50 long long int timestamp; /**< Timestamp for the location fix. */
51}GSW_GNSS_LOCATION_T;
52
53typedef struct {
54 GSW_GNSS_LOCATION_T legacyLocation;
55 float horizontalAccuracyMeters; /**< horizontal position accuracy in meters (68% confidence)*/
56 float verticalAccuracyMeters; /**< vertical position accuracy in meters (68% confidence)*/
57 float speedAccuracyMetersPerSecond;/**< speed accuracy in meter per seconds (68% confidence)*/
58 float bearingAccuracyDegrees; /**< bearing accuracy in degrees (68% confidence)*/
59}GSW_GNSS_LOCATION_EXT_T;
60
61typedef enum{
62 GSW_MODE_GPS_GLONASS = 0, /**< GPS+GLONASS */
63 GSW_MODE_GPS_BEIDOU, /**< GPS+BEIDOU */
64 GSW_MODE_GPS_GLONASS_BEIDOU, /**< GPS+GLONASS+BEIDOU */
65 GSW_MODE_GPS, /**< GPS only */
66 GSW_MODE_BEIDOU, /**< BEIDOU only*/ /* The high-tech platform does not support this type */
67 GSW_MODE_GLONASS, /**< GLONASS only */ /* The high-tech platform does not support this type */
68 GSW_MODE_GPS_GLONASS_BEIDOU_GALILEO, /**< GPS+GLONASS+BEIDOU+GALILEO */
69 GSW_MODE_GPS_GALILEO, /**< GPS+GALILEO */
70 GSW_MODE_GPS_GLONASS_GALILEO, /**< GPS+GLONASS+GALILEO */
71 GSW_MODE_GPS_GALILEO_ONLY, /**< GPS or GALILEO only */
72 GSW_MODE_GPS_GLONASS_BEIDOU_GALILEO_NAVIC, /**< GPS+GLONASS+BEIDOU+GALILEO+NAVIC */ /* The high-tech platform does not support this type */
73 GSW_MODE_GNSS_END /**< init value */
74}GSW_GNSS_MODE_CONFIGURATION;
75
76typedef enum{
77 GSW_SWITCH_DISABLE = 0, /**< configuration switch disable :0 */
78 GSW_SWITCH_ENABLE /**< configuration switch enable :1 */
79}GSW_CONF_SWITCH;
80
81typedef enum
82{
83 GSW_LOC_DELETE_EPHEMERIS = (1 << 0), /**< Delete ephemeris data. */
84 GSW_LOC_DELETE_ALMANAC = (1 << 1), /**< Delete almanac data. */
85 GSW_LOC_DELETE_POSITION = (1 << 2), /**< Delete position data. */
86 GSW_LOC_DELETE_TIME = (1 << 3), /**< Delete time data. */
87 GSW_LOC_DELETE_IONO = (1 << 4), /**< Delete IONO data. */
88 GSW_LOC_DELETE_UTC = (1 << 5), /**< Delete UTC data. */
89 GSW_LOC_DELETE_HEALTH = (1 << 6), /**< Delete health data. */
90 GSW_LOC_DELETE_SVDIR = (1 << 7), /**< Delete SVDIR data. */
91 GSW_LOC_DELETE_SVSTEER = (1 << 8), /**< Delete SVSTEER data. */
92 GSW_LOC_DELETE_SADATA = (1 << 9), /**< Delete SA data. */
93 GSW_LOC_DELETE_RTI = (1 << 10), /**< Delete RTI data. */
94 GSW_LOC_DELETE_CELLDB_INFO = (1 << 11), /**< Delete cell DB information. */
95 GSW_LOC_DELETE_ALL = 0xFFFFFFFF, /**< Delete all location data. */
96} GSW_AIDING_DATA_E;
97
98/* Callback function registered to gnss location
99 * Note:don`t use blocking function inside callback functions */
100typedef void (*gsw_gnss_location_callback_ext)(GSW_GNSS_LOCATION_EXT_T* location);
101
102/* Callback function registered to gnss nmea
103 * Note:don`t use blocking function inside callback functions */
104typedef void (* gsw_gnss_nmea_callback)(const char* nmea, int length);
105
106typedef struct
107{
108 gsw_gnss_location_callback_ext gsw_location_cb; /**< location callback */
109 gsw_gnss_nmea_callback gsw_nmea_cb; /**< nmea callback */
110}gsw_gnss_cb;
111
112typedef enum
113{
114 GSW_XTRA_STATE_MIN = 0,
115 GSW_XTRA_STATE_DISBALE = GSW_XTRA_STATE_MIN,
116 GSW_XTRA_STATE_ENABLE,
117 GSW_XTRA_STATE_MAX
118} gsw_xtra_state_e;
119
120
121/**
122 * @brief SDK interface to set gnss sampling frequency
123 * @details E02 and E06 unused
124 * @param [in] freq
125 * @retval 0: success
126 * @retval other: fail
127 */
128int gsw_gnss_set_freq(int freq);
129
130/**
131 * @brief SDK interface to initialization gnss
132 *
133 * @param
134 * @retval 0: success
135 * @retval other: fail
136 */
137int gsw_gnss_init(void);
138
139/**
140 * @brief SDK interface to start gnss
141 * @param
142 * @retval 0: success
143 * @retval other: fail
144 */
145int gsw_gnss_start(void);
146
147/**
148 * @brief SDK interface to stop gnss
149 * @param
150 * @retval 0: success
151 * @retval other: fail
152 */
153int gsw_gnss_stop(void);
154
155/**
156 * @brief SDK interface to de initialization gnss
157 * @param
158 * @retval 0: success
159 * @retval other: fail
160 */
161int gsw_gnss_deinit(void);
162
163/**
164 * @brief SDK interface to set gnss start mode,specific mode refreence GSW_GNSS_MODE_CONFIGURATION
165 * @details E02 and E06 unused
166 *
167 * @param [in] start_mode
168 * @retval 0: success
169 * @retval other: fail
170 */
171int gsw_gnss_set_start_mode(GSW_GNSS_MODE_CONFIGURATION start_mode);
172
173/**
174 * @brief SDK interface to set EPO switch if open or close
175 * @details E02 and E06 unused
176 *
177 * @param [in] switch_op
178 * @retval 0: success
179 * @retval other: fail
180 */
181int gsw_gnss_epo_switch(GSW_CONF_SWITCH switch_op);
182
183/**
184 * @brief SDK interface to delete aiding data,delete aiding data for cold start
185 * @details E02 and E06 unused
186 *
187 * @param [in] flags
188 * @retval 0: success
189 * @retval other: fail
190 */
191int gsw_gnss_delete_aiding_data(unsigned int flags);
192
193/**
194 * @brief load the dynamic link library.this interface must be called before other interface
195 * @details E02 and E06 unused
196 *
197 * @retval 0: success
198 * @retval other: fail
199 */
200int gsw_gnss_add_lib(void); /* The high-tech platform does not support this type */
201
202/**
203 * @brief SDK interface to registered callback function
204 * @details E02 and E06 unused
205 *
206 * @param [in] callback
207 * @retval 0: success
208 * @retval other: fail
209 */
210int gsw_gnss_reg_cb_group(gsw_gnss_cb callback);
211
212/**
213 * @brief check xtra support or not
214 * @details E02 and E06 unused
215 *
216 * @param [in] state
217 * @retval 0: success
218 * @retval other: fail
219 */
220int gsw_gnss_xtra_is_enable(gsw_xtra_state_e state);
221
222/**
223 * @brief to get current gps information function
224 * @details only for E02 and E06
225 *
226 * @param [out] GSW_GNSS_LOCATION_T
227 * @retval 0: success
228 * @retval other: fail
229 */
230int gsw_gnss_get_current_location(GSW_GNSS_LOCATION_T* location_info);
231
232/**
233 * @brief to get current modem nmea data tail type
234 * @details E02 and E06 unused
235 *
236 * @param [out] tail_type
237 * @param [in] len
238 * @retval 0: success
239 * @retval other: fail
240 */
241int gsw_gnss_get_tail_nmea_type(char *tail_type, int len);
242#endif //__GSW_GNSS_INTERFACE__H__