| /** |
| * \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" |
| |
| #ifdef MBTK_GNSS_6228 |
| #include "mbtk_gnss_6228.h" |
| |
| static mbtk_gnss_client_handle _gnss_handle = 0; |
| |
| #else |
| |
| #endif |
| |
| |
| static lynq_gnss_rx_ind_msg_handler_t handler_ptr = NULL; |
| |
| #ifdef MBTK_GNSS_6228 |
| void lynq_gnss_handler_function |
| ( |
| mbtk_gnss_client_handle h_loc, |
| int e_msg_id, |
| void *pv_data, |
| void *context_ptr |
| ) |
| { |
| if(NULL == handler_ptr) |
| return; |
| |
| if(E_LYNQ_LOC_MSG_ID_NMEA_INFO == e_msg_id) { |
| handler_ptr(h_loc, e_msg_id, pv_data, context_ptr); |
| } else { |
| } |
| } |
| |
| //该函数用于进行GNSS初始化 |
| int lynq_gnss_init(void) |
| { |
| int ret=0; |
| |
| ret = mbtk_gnss_client_init(&_gnss_handle); |
| if(ret < 0) { |
| printf("mopen_gnss_client_init FAIL. ret:%d\n",ret); |
| return -1; |
| } |
| |
| return 0; |
| } |
| |
| //该函数用于取消GNSS初始化 |
| int lynq_gnss_deinit(void) |
| { |
| int ret; |
| if(0 == _gnss_handle) { |
| return -1; |
| } |
| |
| ret = mbtk_gnss_client_deinit(_gnss_handle); |
| if(ret < 0) { |
| printf("mopen_gnss_client_deinit FAIL. ret:%d\n",ret); |
| return -1; |
| } |
| |
| _gnss_handle = 0; |
| return 0; |
| } |
| |
| //该函数用于GNSS回调函数初始化 |
| |
| int lynq_gnss_callback_reg(lynq_gnss_rx_ind_msg_handler_t handlerPtr) |
| { |
| int ret; |
| |
| if(0 == _gnss_handle) { |
| return -1; |
| } |
| mbtk_gnss_print_version(_gnss_handle); |
| |
| ret = mbtk_gnss_add_rx_msg_handler(_gnss_handle, lynq_gnss_handler_function); |
| if(0 == ret && handlerPtr) |
| handler_ptr = handlerPtr; |
| else |
| return -1; |
| return 0; |
| } |
| |
| //该函数用于启动GNSS。 |
| int lynq_gnss_start(void) |
| { |
| if(0 == _gnss_handle) { |
| return -1; |
| } |
| |
| mbtk_gnss_set_mode(_gnss_handle, 0); |
| return mbtk_gnss_set_mode(_gnss_handle, 3); |
| } |
| |
| //该函数用于关闭GNSS。 |
| int lynq_gnss_stop(void) |
| { |
| if(0 == _gnss_handle) { |
| return -1; |
| } |
| |
| return mbtk_gnss_set_mode(_gnss_handle, 0); |
| } |
| |
| |
| int lynq_gnss_agps_dataconnopen(void) |
| { |
| int ret; |
| |
| ret = mbtk_gnss_download_tle(); |
| if(ret) |
| { |
| printf("%s: download injects failed!!\n", __FUNCTION__); |
| return -1; |
| } |
| return mbtk_gnss_injects_aidpos(_gnss_handle); |
| } |
| |
| int lynq_gnss_dev_reset(void) |
| { |
| int ret = 0; |
| if(_gnss_handle < 0) |
| { |
| return -1; |
| } |
| ret = mbtk_gnss_dev_reset(_gnss_handle, 0, 0); |
| return ret; |
| } |
| |
| int lynq_gnss_enable_glonass(void) |
| { |
| mbtk_gnss_firmware_update(); |
| return 0; |
| } |
| #else |
| //该函数用于进行GNSS初始化 |
| int lynq_gnss_init(void) |
| { |
| |
| return 0; |
| } |
| |
| //该函数用于取消GNSS初始化 |
| int lynq_gnss_deinit(void) |
| { |
| |
| return 0; |
| } |
| |
| //该函数用于GNSS回调函数初始化 |
| |
| int lynq_gnss_callback_reg(lynq_gnss_rx_ind_msg_handler_t handlerPtr) |
| { |
| UNUSED(handlerPtr); |
| |
| |
| return 0; |
| } |
| |
| //该函数用于启动GNSS。 |
| int lynq_gnss_start(void) |
| { |
| return 0; |
| } |
| |
| //该函数用于关闭GNSS。 |
| int lynq_gnss_stop(void) |
| { |
| return 0; |
| } |
| |
| |
| int lynq_gnss_agps_dataconnopen(void) |
| { |
| return 0; |
| } |
| |
| int lynq_gnss_dev_reset(void) |
| { |
| return 0; |
| } |
| |
| int lynq_gnss_enable_glonass(void) |
| { |
| return 0; |
| } |
| #endif |