b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 1 | /* |
| 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.liu | e77ac3a | 2024-07-17 17:36:57 +0800 | [diff] [blame] | 12 | #include "mbtk_gnss.h" |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 13 | |
| 14 | #define GNSS_ID_6228 "6228" |
| 15 | #define GNSS_ID_5311 "5311" |
b.liu | f9fbfa1 | 2024-06-14 15:53:59 +0800 | [diff] [blame] | 16 | #define GNSS_ID_8122 "8122" |
b.liu | 42f558e | 2024-07-18 14:06:49 +0800 | [diff] [blame] | 17 | #define GNSS_ID_N50DB "N50DB" |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 18 | |
b.liu | d0ba715 | 2024-06-19 14:47:21 +0800 | [diff] [blame] | 19 | #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.wang | 6a3437f | 2024-07-27 02:57:20 -0700 | [diff] [blame] | 24 | #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 | |
b.liu | d0ba715 | 2024-06-19 14:47:21 +0800 | [diff] [blame] | 29 | #define GNSS_SET_MSGCFG_RMC (1) |
| 30 | #define GNSS_SET_MSGCFG_VTG (1<<1) |
| 31 | #define GNSS_SET_MSGCFG_GGA (1<<2) |
| 32 | #define GNSS_SET_MSGCFG_GSA (1<<3) |
| 33 | #define GNSS_SET_MSGCFG_GSV (1<<4) |
| 34 | #define GNSS_SET_MSGCFG_GLL (1<<5) |
| 35 | #define GNSS_SET_MSGCFG_ZDA (1<<6) |
| 36 | #define GNSS_SET_MSGCFG_GST (1<<7) |
| 37 | #define GNSS_SET_MSGCFG_GRS (1<<8) |
| 38 | #define GNSS_SET_MSGCFG_TXT (1<<9) |
| 39 | #define GNSS_SET_MSGCFG_DHV (1<<10) |
| 40 | #define GNSS_SET_MSGCFG_DTM (1<<11) |
| 41 | #define GNSS_SET_MSGCFG_NAVPOS (1<<12) |
| 42 | #define GNSS_SET_MSGCFG_NAVVEL (1<<13) |
| 43 | #define GNSS_SET_MSGCFG_NAVTIME (1<<14) |
| 44 | #define GNSS_SET_MSGCFG_NAVACC (1<<15) |
| 45 | #define GNSS_SET_MSGCFG_LSF (1<<16) |
| 46 | #define GNSS_SET_MSGCFG_ANTSTAT (1<<17) |
| 47 | #define GNSS_SET_MSGCFG_ANTSTAT1 (1<<18) |
| 48 | #define GNSS_SET_MSGCFG_NOTICE (1<<19) |
| 49 | #define GNSS_SET_MSGCFG_ABNORMAL (1<<20) |
| 50 | #define GNSS_SET_MSGCFG_EPHABNORMAL (1<<21) |
| 51 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 52 | typedef enum { |
b.liu | d0ba715 | 2024-06-19 14:47:21 +0800 | [diff] [blame] | 53 | GNSS_RESET_TYPE_HOT = 1, |
| 54 | GNSS_RESET_TYPE_WARM, |
| 55 | GNSS_RESET_TYPE_COLD |
| 56 | } gnss_reset_type_enum; |
| 57 | |
| 58 | typedef enum { |
| 59 | GNSS_MEMAVER_TYPE_3_0 = 0, |
| 60 | GNSS_MEMAVER_TYPE_4_0, |
| 61 | GNSS_MEMAVER_TYPE_4_1 |
| 62 | } gnss_memaver_type_enum; |
| 63 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 64 | typedef int (*gnss_dev_open_func)(); |
b.liu | 978f543 | 2024-07-01 18:04:18 +0800 | [diff] [blame] | 65 | typedef int (*gnss_dev_close_func)(int fd); |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 66 | typedef int (*gnss_open_func)(const char *dev); |
| 67 | typedef int (*gnss_close_func)(int fd); |
b.liu | dbc3f4b | 2024-06-25 18:22:24 +0800 | [diff] [blame] | 68 | typedef int (*gnss_fw_dl_func)(int fd, const char *fw_name, const char *dev); |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 69 | typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len); |
| 70 | typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len); |
| 71 | typedef void (*gnss_set_cb_func)(const void *data, int data_len); |
| 72 | |
| 73 | typedef enum { |
| 74 | GNSS_TYPE_6228 = 0, |
| 75 | GNSS_TYPE_5311, |
b.liu | 42f558e | 2024-07-18 14:06:49 +0800 | [diff] [blame] | 76 | GNSS_TYPE_8122, |
| 77 | GNSS_TYPE_N50DB |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 78 | } gnss_id_enum; |
| 79 | |
| 80 | typedef enum { |
| 81 | GNSS_STATE_CLOSE, // GNSS is closed. |
| 82 | GNSS_STATE_CLOSING, // GNSS is closing. |
| 83 | GNSS_STATE_OPEN, // GNSS is opened. |
| 84 | GNSS_STATE_DOWNLOAD, // GNSS is downloading. |
| 85 | GNSS_STATE_READY, // GNSS is ready. |
| 86 | } gnss_state_enum; |
| 87 | |
yq.wang | 5c647e0 | 2024-08-10 00:01:11 -0700 | [diff] [blame] | 88 | typedef enum { |
| 89 | LYNQ_TIME_TYPE_CELL = 0, //NITZ |
| 90 | LYNQ_TIME_TYPE_NTP, |
| 91 | LYNQ_TIME_TYPE_GNSS, |
| 92 | LYNQ_TIME_TYPE_USER, |
| 93 | |
| 94 | LYNQ_TIME_TYPE_UNUSE |
| 95 | } lynq_time_type_enum; |
| 96 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 97 | typedef struct { |
b.liu | e77ac3a | 2024-07-17 17:36:57 +0800 | [diff] [blame] | 98 | int cli_fd; |
| 99 | uint32 ind_flag; |
| 100 | } gnss_ind_info_t; |
| 101 | |
| 102 | typedef struct { |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 103 | gnss_id_enum gnss_id; |
| 104 | char dev_name[32]; |
| 105 | bool auto_open; // Should auto open gnss? |
| 106 | bool auto_dl_fw; // Should download firmware int the first? |
b.liu | 99c645d | 2024-06-20 10:52:15 +0800 | [diff] [blame] | 107 | bool dl_befor_open; // Should download firmware before open device? |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 108 | int fd; // GNSS uart fd. |
| 109 | int exit_fd[2]; // Use to exit thread. |
| 110 | gnss_state_enum state; |
| 111 | uint32 print_port; |
| 112 | pthread_t read_pid; // Read NMEA thread. |
| 113 | |
| 114 | // GNSS functions. |
| 115 | gnss_dev_open_func gnss_dev_open; |
| 116 | gnss_dev_close_func gnss_dev_close; |
| 117 | gnss_open_func gnss_open; |
| 118 | gnss_close_func gnss_close; |
| 119 | gnss_fw_dl_func gnss_fw_dl; |
| 120 | gnss_dl_read_cb_func gnss_dl_read_cb; |
| 121 | gnss_set_func gnss_set; |
| 122 | gnss_set_cb_func gnss_set_cb; |
| 123 | } gnss_info_t; |
| 124 | |
b.liu | 5f950c5 | 2024-06-15 20:13:12 +0800 | [diff] [blame] | 125 | int gnss_init(uint32 print_port); |
| 126 | |
| 127 | int gnss_deinit(); |
| 128 | |
| 129 | int gnss_set(const void* buf, unsigned int buf_len, void *cmd_rsp, int cmd_rsp_len); |
| 130 | |
b.liu | dbc3f4b | 2024-06-25 18:22:24 +0800 | [diff] [blame] | 131 | int gnss_dl_fw(const char* fw_name, void *rsp, int rsp_len); |
| 132 | |
b.liu | e77ac3a | 2024-07-17 17:36:57 +0800 | [diff] [blame] | 133 | int gnss_ind_set(int fd, int ind_type); |
| 134 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 135 | #endif /* _GNSS_INFO_H */ |