blob: 9ba5185b753846961bcac58e9a08f79e4d619cea [file] [log] [blame]
/**
* \file gnss_test.c
* \brief A Documented file.
*
* Detailed description
* \Author: Sniper <e190@163.com>
* \Version: 1.0.0
* \Date: 2022-03-26
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <termios.h>
#include <sys/ioctl.h>
#include "mbtk_type.h"
#include "lynq/lynq_gnss.h"
//#include "mbtk_gnss.h"
void gnss_handler_cb
(
uint32 h_loc,
int e_msg_id,
void *pv_data,
void *context_ptr
) {
printf("e_msg_id=%d\n", e_msg_id);
switch(e_msg_id)
{
case E_LYNQ_LOC_MSG_ID_STATUS_INFO:
break;
case E_LYNQ_LOC_MSG_ID_LOCATION_INFO:
break;
case E_LYNQ_LOC_MSG_ID_SV_INFO:
break;
case E_LYNQ_LOC_MSG_ID_NMEA_INFO:
{
LYNQ_LOC_NMEA_INFO_T *pt_nmea = (LYNQ_LOC_NMEA_INFO_T *)pv_data;
printf("NMEA info: timestamp=%lld, length=%d, nmea=%s\n",
pt_nmea->timestamp, pt_nmea->length, pt_nmea->nmea);
break;
}
case E_LYNQ_LOC_MSG_ID_CAPABILITIES_INFO:
break;
case E_LYNQ_LOC_MSG_ID_AGPS_STATUS:
break;
case E_LYNQ_LOC_MSG_ID_NI_NOTIFICATION:
break;
case E_LYNQ_LOC_MSG_ID_XTRA_REPORT_SERVER:
break;
}
}
#if 1
int main(int argc, char *argv[])
{
int ret;
ret = lynq_gnss_enable_glonass();
if(ret < 0) {
printf("lynq_gnss_init FAIL. ret:%d\n",ret);
return -1;
}
ret = lynq_gnss_init();
if(ret < 0) {
printf("lynq_gnss_init FAIL. ret:%d\n",ret);
return -1;
}
lynq_gnss_callback_reg(gnss_handler_cb);
ret = lynq_gnss_agps_dataconnopen();
if(ret < 0) {
printf("lynq_gnss_agps_dataconnopen FAIL. ret:%d\n", ret);
return -1;
}
ret = lynq_gnss_start();
if(ret < 0) {
printf("lynq_gnss_start FAIL. ret:%d\n",ret);
return -1;
}
sleep(10);
ret = lynq_gnss_stop();
if(ret < 0) {
printf("lynq_gnss_stop FAIL. ret:%d\n",ret);
return -1;
}
ret = lynq_gnss_deinit();
if(ret < 0) {
printf("lynq_gnss_deinit FAIL. ret:%d\n",ret);
return -1;
}
return 0;
}
#else
int main(int argc, char *argv[])
{
int ret;
int opt;
char dev_file[12] = {0};
while(1)
{
printf("=========gnss main=========\n"
"\t0 exit\n"
"\t1 gnss init\n"
"\t2 gnss add callback function\n"
"\t3 gnss start\n"
"\t4 gnss stop\n"
"\t5 gnss deinit\n"
"\t6 agps down\n"
"please input operator: >> ");
scanf("%d", &opt);
switch (opt)
{
case 0:
printf("main exit\n");
return 0;
case 1:
ret = lynq_gnss_init();
if(ret < 0)
{
printf("lynq_gnss_init FAIL. ret:%d\n",ret);
return -1;
}
opt = 0;
break;
case 2:
{
lynq_gnss_callback_reg(gnss_handler_cb);
break;
}
case 3:
{
lynq_gnss_start();
break;
}
case 4:
{
lynq_gnss_stop();
break;
}
case 5:
{
lynq_gnss_deinit();
break;
}
case 6:
{
ret = lynq_gnss_agps_dataconnopen();
if(ret < 0)
{
printf("lynq_gnss_agps_dataconnopen FAIL. ret:%d\n", ret);
return -1;
}
break;
}
default:
break;
}
}
return 0;
}
#endif