blob: fc4cd374251d5bafbcbff448be7ea7a763ed5709 [file] [log] [blame]
b.liu8f231a12024-05-31 17:55:06 +08001/*
2* gnss_info.h
3*
4* GNSS informations header.
5*
6* Author : lb
7* Date : 2024/5/20 15:22:46
8*/
9#ifndef _GNSS_INFO_H
10#define _GNSS_INFO_H
11#include "mbtk_type.h"
b.liue77ac3a2024-07-17 17:36:57 +080012#include "mbtk_gnss.h"
b.liu8f231a12024-05-31 17:55:06 +080013
14#define GNSS_ID_6228 "6228"
15#define GNSS_ID_5311 "5311"
b.liuf9fbfa12024-06-14 15:53:59 +080016#define GNSS_ID_8122 "8122"
b.liu42f558e2024-07-18 14:06:49 +080017#define GNSS_ID_N50DB "N50DB"
b.liu8f231a12024-05-31 17:55:06 +080018
b.liud0ba7152024-06-19 14:47:21 +080019#define GNSS_SET_SYSCFG_GPS (1)
20#define GNSS_SET_SYSCFG_BDS (1<<1)
21#define GNSS_SET_SYSCFG_GLO (1<<2)
22#define GNSS_SET_SYSCFG_GAL (1<<3)
23
yq.wang6a3437f2024-07-27 02:57:20 -070024#define GNSS_SET_FREQCFG_1 (1)
25#define GNSS_SET_FREQCFG_2 (2)
26#define GNSS_SET_FREQCFG_5 (5)
27#define GNSS_SET_FREQCFG_10 (10)
28
yq.wangd8ded5e2024-08-16 03:27:49 -070029#define GNSS_SET_EVEL_5 (5)
30#define GNSS_SET_EVEL_15 (15)
31
32#define GNSS_SET_NMEAVER_3_01 (0)
33#define GNSS_SET_NMEAVER_4_00 (1)
34#define GNSS_SET_NMEAVER_4_10 (2)
35
b.liud0ba7152024-06-19 14:47:21 +080036#define GNSS_SET_MSGCFG_RMC (1)
37#define GNSS_SET_MSGCFG_VTG (1<<1)
38#define GNSS_SET_MSGCFG_GGA (1<<2)
39#define GNSS_SET_MSGCFG_GSA (1<<3)
40#define GNSS_SET_MSGCFG_GSV (1<<4)
41#define GNSS_SET_MSGCFG_GLL (1<<5)
42#define GNSS_SET_MSGCFG_ZDA (1<<6)
43#define GNSS_SET_MSGCFG_GST (1<<7)
44#define GNSS_SET_MSGCFG_GRS (1<<8)
45#define GNSS_SET_MSGCFG_TXT (1<<9)
46#define GNSS_SET_MSGCFG_DHV (1<<10)
47#define GNSS_SET_MSGCFG_DTM (1<<11)
48#define GNSS_SET_MSGCFG_NAVPOS (1<<12)
49#define GNSS_SET_MSGCFG_NAVVEL (1<<13)
50#define GNSS_SET_MSGCFG_NAVTIME (1<<14)
51#define GNSS_SET_MSGCFG_NAVACC (1<<15)
52#define GNSS_SET_MSGCFG_LSF (1<<16)
53#define GNSS_SET_MSGCFG_ANTSTAT (1<<17)
54#define GNSS_SET_MSGCFG_ANTSTAT1 (1<<18)
55#define GNSS_SET_MSGCFG_NOTICE (1<<19)
56#define GNSS_SET_MSGCFG_ABNORMAL (1<<20)
57#define GNSS_SET_MSGCFG_EPHABNORMAL (1<<21)
58
b.liu8f231a12024-05-31 17:55:06 +080059typedef enum {
b.liud0ba7152024-06-19 14:47:21 +080060 GNSS_RESET_TYPE_HOT = 1,
61 GNSS_RESET_TYPE_WARM,
62 GNSS_RESET_TYPE_COLD
63} gnss_reset_type_enum;
64
65typedef enum {
66 GNSS_MEMAVER_TYPE_3_0 = 0,
67 GNSS_MEMAVER_TYPE_4_0,
68 GNSS_MEMAVER_TYPE_4_1
69} gnss_memaver_type_enum;
70
b.liu8f231a12024-05-31 17:55:06 +080071typedef int (*gnss_dev_open_func)();
b.liu978f5432024-07-01 18:04:18 +080072typedef int (*gnss_dev_close_func)(int fd);
b.liu8f231a12024-05-31 17:55:06 +080073typedef int (*gnss_open_func)(const char *dev);
74typedef int (*gnss_close_func)(int fd);
b.liudbc3f4b2024-06-25 18:22:24 +080075typedef int (*gnss_fw_dl_func)(int fd, const char *fw_name, const char *dev);
b.liu8f231a12024-05-31 17:55:06 +080076typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len);
77typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len);
78typedef void (*gnss_set_cb_func)(const void *data, int data_len);
79
80typedef enum {
81 GNSS_TYPE_6228 = 0,
82 GNSS_TYPE_5311,
b.liu42f558e2024-07-18 14:06:49 +080083 GNSS_TYPE_8122,
84 GNSS_TYPE_N50DB
b.liu8f231a12024-05-31 17:55:06 +080085} gnss_id_enum;
86
87typedef enum {
88 GNSS_STATE_CLOSE, // GNSS is closed.
89 GNSS_STATE_CLOSING, // GNSS is closing.
90 GNSS_STATE_OPEN, // GNSS is opened.
91 GNSS_STATE_DOWNLOAD, // GNSS is downloading.
92 GNSS_STATE_READY, // GNSS is ready.
93} gnss_state_enum;
94
yq.wang5c647e02024-08-10 00:01:11 -070095typedef enum {
96 LYNQ_TIME_TYPE_CELL = 0, //NITZ
97 LYNQ_TIME_TYPE_NTP,
98 LYNQ_TIME_TYPE_GNSS,
99 LYNQ_TIME_TYPE_USER,
100
101 LYNQ_TIME_TYPE_UNUSE
102} lynq_time_type_enum;
103
b.liu8f231a12024-05-31 17:55:06 +0800104typedef struct {
b.liue77ac3a2024-07-17 17:36:57 +0800105 int cli_fd;
106 uint32 ind_flag;
107} gnss_ind_info_t;
108
109typedef struct {
b.liu8f231a12024-05-31 17:55:06 +0800110 gnss_id_enum gnss_id;
111 char dev_name[32];
112 bool auto_open; // Should auto open gnss?
113 bool auto_dl_fw; // Should download firmware int the first?
b.liu99c645d2024-06-20 10:52:15 +0800114 bool dl_befor_open; // Should download firmware before open device?
b.liu8f231a12024-05-31 17:55:06 +0800115 int fd; // GNSS uart fd.
116 int exit_fd[2]; // Use to exit thread.
117 gnss_state_enum state;
118 uint32 print_port;
119 pthread_t read_pid; // Read NMEA thread.
120
121 // GNSS functions.
122 gnss_dev_open_func gnss_dev_open;
123 gnss_dev_close_func gnss_dev_close;
124 gnss_open_func gnss_open;
125 gnss_close_func gnss_close;
126 gnss_fw_dl_func gnss_fw_dl;
127 gnss_dl_read_cb_func gnss_dl_read_cb;
128 gnss_set_func gnss_set;
129 gnss_set_cb_func gnss_set_cb;
130} gnss_info_t;
131
b.liu5f950c52024-06-15 20:13:12 +0800132int gnss_init(uint32 print_port);
133
134int gnss_deinit();
135
136int gnss_set(const void* buf, unsigned int buf_len, void *cmd_rsp, int cmd_rsp_len);
137
b.liudbc3f4b2024-06-25 18:22:24 +0800138int gnss_dl_fw(const char* fw_name, void *rsp, int rsp_len);
139
b.liue77ac3a2024-07-17 17:36:57 +0800140int gnss_ind_set(int fd, int ind_type);
141
b.liu8f231a12024-05-31 17:55:06 +0800142#endif /* _GNSS_INFO_H */