blob: c8fcda2792b7c6409c82d17592a3f4d8ec2e3b97 [file] [log] [blame]
b.liu8583dce2024-04-03 13:30:08 +08001#include <stdio.h>
2#include <string.h>
3#include <strings.h>
4#include <stdlib.h>
5#include <errno.h>
6#include <termios.h>
7#include <unistd.h>
8#include <fcntl.h>
9#include <signal.h>
10#include <sys/types.h>
11#include <unistd.h>
12#include <pthread.h>
13#include <termios.h>
14#include <time.h>
15#include <sys/ioctl.h>
16#include <dlfcn.h>
17#include <stdint.h>
18#include "lynq-qser-gnss-demo.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24
25int (*qser_Gnss_Init)(uint32_t *h_gnss);
26int (*qser_Gnss_Deinit)(uint32_t);
27int (*qser_AddRxIndMsgHandler)(gnss_handler_func_t handler_ptr,uint32_t);
28int (*qser_Set_Indications)(uint32_t h_gnss,e_msg_id_t);
29int (*qser_Gnss_Start)(uint32_t h_gnss);
30int (*qser_Gnss_Stop)(uint32_t h_gnss);
31int (*qser_Gnss_Delete_Aiding_Data)(uint32_t,DELETE_AIDING_DATA_TYPE_T);
32int (*qser_Gnss_InjectTime)(uint32_t,LYNQ_INJECT_TIME_INTO_T *time_info);
33int (*qser_Gnss_Server_Configuration)(char *host, char *id, char *password);
34int (*qser_Gnss_download_tle)();
35int (*qser_Gnss_injectEphemeris)(uint32_t);
36int (*qser_Gnss_Set_Frequency)(uint32_t, int);
37void *dlHandle_gnss;
38
39int main(int argc, char *argv[])
40{
41 int ret;
42 int opt = 0;
43 char *lynqLib_gnss = "/lib/liblynq-qser-gnss.so";
44 char dev_file[12] = {0};
45 uint32_t ph_gnss;
46 dlHandle_gnss = dlopen(lynqLib_gnss, RTLD_NOW);
47 while(1)
48 {
49 printf("=========gnss main=========\n");
50 user_help();
51 scanf("%d", &opt);
52 while(getchar()!='\n');
53 switch (opt)
54 {
55 case -1:
56 {
57 printf("main exit\n");
58 return 0;
59 }
60
61 case 1:
62 {
63 qser_Gnss_Init=(int(*)(uint32_t *h_gnss))dlsym(dlHandle_gnss, "qser_Gnss_Init");
64 ret = qser_Gnss_Init(&ph_gnss);
65 if(ret < 0)
66 {
67 printf("mopen_gnss_client_init FAIL.\n");
68 return -1;
69 }
70 printf("mopen_gnss_client_init success , with address=%d\n", ph_gnss);
71 break;
72 }
73 case 2:
74 {
75 qser_Gnss_Deinit=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Deinit");
76 ret =qser_Gnss_Deinit(ph_gnss);
77 if(ret < 0)
78 {
79 printf("mopen_gnss_client_Deinit FAIL.\n");
80 return -1;
81 }
82 printf("mopen_gnss_client_Deinit success \n");
83 break;
84 }
85 case 3:
86 {
87 qser_AddRxIndMsgHandler=(int(*)(gnss_handler_func_t,uint32_t))dlsym(dlHandle_gnss, "qser_AddRxIndMsgHandler");
88 ret = qser_AddRxIndMsgHandler((gnss_handler_func_t)&cb,ph_gnss);
89 if(ret < 0)
90 {
91 printf("lynq_AddRxIndMsgHandler fail\n");
92 qser_Gnss_Deinit(ph_gnss);
93 return -1;
94 }
95 printf("add success\n");
96 break;
97 }
98 case 4:
99 {
100 e_msg_id_t ptr2=E_MT_LOC_MSG_ID_LOCATION_INFO;
101 qser_Set_Indications=(int(*)(uint32_t h_gnss,e_msg_id_t))dlsym(dlHandle_gnss, "qser_Set_Indications");
102 ret = qser_Set_Indications(ph_gnss,ptr2);
103 if(ret < 0)
104 {
105 printf("lynq_Set_LOCATION_INFO fail\n");
106 qser_Gnss_Deinit(ph_gnss);
107 return -1;
108 }
109 printf("set location mode success\n");
110 break;
111 }
112 case 5:
113 {
114 e_msg_id_t ptr4=E_MT_LOC_MSG_ID_NMEA_INFO;
115 qser_Set_Indications=(int(*)(uint32_t h_gnss,e_msg_id_t))dlsym(dlHandle_gnss, "qser_Set_Indications");
116 ret = qser_Set_Indications(ph_gnss,ptr4);
117 if(ret < 0)
118 {
119 printf("lynq_Set_NMEA_INFO fail\n");
120 qser_Gnss_Deinit(ph_gnss);
121 return -1;
122 }
123 printf("set nmea mode success\n");
124 break;
125
126 }
127 case 6:
128 {
129 qser_Gnss_Start=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Start");
130 ret = qser_Gnss_Start(ph_gnss);
131 if(ret < 0)
132 {
133 printf("lynq_Gnss_Start fail\n");
134 return -1;
135 }
136 printf("start success\n");
137 break;
138 }
139 case 7:
140 {
141 qser_Gnss_Stop=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_Stop");
142 ret = qser_Gnss_Stop(ph_gnss);
143 if(ret < 0)
144 {
145 printf("lynq_Gnss_Stop fail\n");
146 qser_Gnss_Deinit(ph_gnss);
147 return -1;
148 }
149 printf("stop success\n");
150 break;
151 }
152
153 case 8:
154 {
155 int opt_1;
156 DELETE_AIDING_DATA_TYPE_T ptr;
157 qser_Gnss_Delete_Aiding_Data=(int(*)(uint32_t,DELETE_AIDING_DATA_TYPE_T))dlsym(dlHandle_gnss, "qser_Gnss_Delete_Aiding_Data");
158 printf("=========delete aiding data type=========\n");
159 delete_type();
160 scanf("%d", &opt_1);
161 while(getchar()!='\n');
162 switch(opt_1)
163 {
164 case 0:
165 {
166 ptr = DELETE_NOTHING;//hot
167 break;
168 }
169 case 1:
170 {
171 ptr = DELETE_EPHEMERIS;//warm
172 break;
173 }
174 case 2:
175 {
176 ptr = DELETE_ALMANAC;
177 break;
178 }
179 case 3:
180 {
181 ptr = DELETE_POSITION_TIME;
182 break;
183 }
184 case 4:
185 {
186 ptr = DELETE_UTC;
187 break;
188 }
189 case 5:
190 {
191 ptr = DELETE_ALL;//cold
192 break;
193 }
194 default:
195 {
196 printf("input error\n");
197 return -1;
198 }
199 }
200 ret = qser_Gnss_Delete_Aiding_Data(ph_gnss,ptr);
201 if(ret < 0)
202 {
203 printf("lynq_Gnss_Delete_Aiding_Data %d fail\n",opt_1);
204 qser_Gnss_Deinit(ph_gnss);
205 return -1;
206 }
207 printf("lynq_Gnss_Delete_Aiding_Data %d success\n",opt_1);
208 break;
209 }
210 case 9:
211 {
212 LYNQ_INJECT_TIME_INTO_T time_test;
213 qser_Gnss_InjectTime=(int(*)(uint32_t,LYNQ_INJECT_TIME_INTO_T *time_info))dlsym(dlHandle_gnss, "qser_Gnss_InjectTime");
214 ret = qser_Gnss_InjectTime(ph_gnss,&time_test);
215 if(ret < 0)
216 {
217 printf("qser_Gnss_InjectTime fail\n");
218 qser_Gnss_Deinit(ph_gnss);
219 return -1;
220 }
221 printf("qser_Gnss_InjectTime success\n");
222 break;
223 }
224 case 10:
225 {
226 qser_Gnss_download_tle=(int(*)())dlsym(dlHandle_gnss, "qser_Gnss_download_tle");
227 ret = qser_Gnss_download_tle();
228 if(ret < 0)
229 {
230 printf("qser_Gnss_download_tle fail\n");
231 return -1;
232 }
233 printf("qser_Gnss_download_tle success\n");
234 break;
235 }
236 case 11:
237 {
238 int frequency;
239 qser_Gnss_Set_Frequency=(int(*)(uint32_t, int))dlsym(dlHandle_gnss, "qser_Gnss_Set_Frequency");
240 printf("=========delete aiding data type=========\n");
241 scanf("%d", &frequency);
242 ret = qser_Gnss_Set_Frequency(ph_gnss,frequency);
243 if(ret < 0)
244 {
245 printf("qser_Gnss_Set_Frequency fail\n");
246 return -1;
247 }
248 printf("frequency is %d\n",frequency);
249 printf("qser_Gnss_Set_Frequency success\n");
250 break;
251 }
252 case 12:
253 {
254 int (*qser_Gnss_injectEphemeris)(uint32_t);
255 qser_Gnss_injectEphemeris=(int(*)(uint32_t))dlsym(dlHandle_gnss, "qser_Gnss_injectEphemeris");
256 ret = qser_Gnss_injectEphemeris(ph_gnss);
257 if(ret < 0)
258 {
259 printf("qser_Gnss_injectEphemeris fail\n");
260 return -1;
261 }
262 printf("qser_Gnss_injectEphemeri ssuccess\n");
263 break;
264 }
265 case 13:
266 {
267 qser_Gnss_Server_Configuration=(int(*)(char *host, char *id, char *password))dlsym(dlHandle_gnss, "qser_Gnss_Server_Configuration");
268 ret = qser_Gnss_Server_Configuration(NULL,"lcz","123456");
269 if(ret < 0)
270 {
271 printf("qser_Gnss_Server_Configuration fail\n");
272 return -1;
273 }
274 printf("qser_Gnss_Server_Configuration ssuccess\n");
275 break;
276 }
277 default:
278 {
279 printf("input error,please re-enter\n");
280 break;
281 }
282 }
283 }
284 return 0;
285}
286#ifdef __cplusplus
287}
288#endif