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 | |
yq.wang | d8ded5e | 2024-08-16 03:27:49 -0700 | [diff] [blame] | 29 | #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.liu | d0ba715 | 2024-06-19 14:47:21 +0800 | [diff] [blame] | 36 | #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 | |
yq.wang | 9dd771b | 2024-09-13 23:38:40 -0700 | [diff] [blame^] | 59 | #define GNSS_AGPS_LEN_MAX 128 |
| 60 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 61 | typedef enum { |
b.liu | d0ba715 | 2024-06-19 14:47:21 +0800 | [diff] [blame] | 62 | GNSS_RESET_TYPE_HOT = 1, |
| 63 | GNSS_RESET_TYPE_WARM, |
| 64 | GNSS_RESET_TYPE_COLD |
| 65 | } gnss_reset_type_enum; |
| 66 | |
| 67 | typedef enum { |
| 68 | GNSS_MEMAVER_TYPE_3_0 = 0, |
| 69 | GNSS_MEMAVER_TYPE_4_0, |
| 70 | GNSS_MEMAVER_TYPE_4_1 |
| 71 | } gnss_memaver_type_enum; |
| 72 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 73 | typedef int (*gnss_dev_open_func)(); |
b.liu | 978f543 | 2024-07-01 18:04:18 +0800 | [diff] [blame] | 74 | typedef int (*gnss_dev_close_func)(int fd); |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 75 | typedef int (*gnss_open_func)(const char *dev); |
| 76 | typedef int (*gnss_close_func)(int fd); |
b.liu | dbc3f4b | 2024-06-25 18:22:24 +0800 | [diff] [blame] | 77 | 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] | 78 | typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len); |
| 79 | typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len); |
| 80 | typedef void (*gnss_set_cb_func)(const void *data, int data_len); |
yq.wang | 99db6f5 | 2024-09-12 01:58:48 -0700 | [diff] [blame] | 81 | typedef gnss_err_enum (*gnss_agnss_get_eph_func)(const char *param); |
| 82 | typedef gnss_err_enum (*gnss_agnss_inject_func)(int fd); |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 83 | |
| 84 | typedef enum { |
| 85 | GNSS_TYPE_6228 = 0, |
| 86 | GNSS_TYPE_5311, |
b.liu | 42f558e | 2024-07-18 14:06:49 +0800 | [diff] [blame] | 87 | GNSS_TYPE_8122, |
| 88 | GNSS_TYPE_N50DB |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 89 | } gnss_id_enum; |
| 90 | |
| 91 | typedef enum { |
yq.wang | 99db6f5 | 2024-09-12 01:58:48 -0700 | [diff] [blame] | 92 | GNSS_EPH_GPS = 0, |
| 93 | GNSS_EPH_BDS, |
| 94 | GNSS_EPH_GLO, |
| 95 | GNSS_EPH_GPS_BDS, |
yq.wang | 9dd771b | 2024-09-13 23:38:40 -0700 | [diff] [blame^] | 96 | GNSS_EPH_GPS_GLO, |
| 97 | |
| 98 | GNSS_EPH_CFG = 10, //get eph data by cfg parameters |
yq.wang | 99db6f5 | 2024-09-12 01:58:48 -0700 | [diff] [blame] | 99 | } gnss_eph_data_enum; |
| 100 | |
| 101 | typedef enum { |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 102 | GNSS_STATE_CLOSE, // GNSS is closed. |
| 103 | GNSS_STATE_CLOSING, // GNSS is closing. |
| 104 | GNSS_STATE_OPEN, // GNSS is opened. |
| 105 | GNSS_STATE_DOWNLOAD, // GNSS is downloading. |
| 106 | GNSS_STATE_READY, // GNSS is ready. |
| 107 | } gnss_state_enum; |
| 108 | |
yq.wang | 9dd771b | 2024-09-13 23:38:40 -0700 | [diff] [blame^] | 109 | typedef struct |
| 110 | { |
| 111 | char host[GNSS_AGPS_LEN_MAX]; |
| 112 | char id[GNSS_AGPS_LEN_MAX]; |
| 113 | char passwd[GNSS_AGPS_LEN_MAX]; |
| 114 | }gnss_agps_info_t; |
| 115 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 116 | typedef struct { |
b.liu | e77ac3a | 2024-07-17 17:36:57 +0800 | [diff] [blame] | 117 | int cli_fd; |
| 118 | uint32 ind_flag; |
| 119 | } gnss_ind_info_t; |
| 120 | |
| 121 | typedef struct { |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 122 | gnss_id_enum gnss_id; |
| 123 | char dev_name[32]; |
| 124 | bool auto_open; // Should auto open gnss? |
| 125 | bool auto_dl_fw; // Should download firmware int the first? |
b.liu | 99c645d | 2024-06-20 10:52:15 +0800 | [diff] [blame] | 126 | bool dl_befor_open; // Should download firmware before open device? |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 127 | int fd; // GNSS uart fd. |
| 128 | int exit_fd[2]; // Use to exit thread. |
| 129 | gnss_state_enum state; |
| 130 | uint32 print_port; |
| 131 | pthread_t read_pid; // Read NMEA thread. |
| 132 | |
| 133 | // GNSS functions. |
| 134 | gnss_dev_open_func gnss_dev_open; |
| 135 | gnss_dev_close_func gnss_dev_close; |
| 136 | gnss_open_func gnss_open; |
| 137 | gnss_close_func gnss_close; |
| 138 | gnss_fw_dl_func gnss_fw_dl; |
| 139 | gnss_dl_read_cb_func gnss_dl_read_cb; |
| 140 | gnss_set_func gnss_set; |
| 141 | gnss_set_cb_func gnss_set_cb; |
yq.wang | 99db6f5 | 2024-09-12 01:58:48 -0700 | [diff] [blame] | 142 | gnss_agnss_get_eph_func gnss_agnss_get_eph; |
| 143 | gnss_agnss_inject_func gnss_agnss_inject; |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 144 | } gnss_info_t; |
| 145 | |
b.liu | 5f950c5 | 2024-06-15 20:13:12 +0800 | [diff] [blame] | 146 | int gnss_init(uint32 print_port); |
| 147 | |
| 148 | int gnss_deinit(); |
| 149 | |
| 150 | int gnss_set(const void* buf, unsigned int buf_len, void *cmd_rsp, int cmd_rsp_len); |
| 151 | |
b.liu | dbc3f4b | 2024-06-25 18:22:24 +0800 | [diff] [blame] | 152 | int gnss_dl_fw(const char* fw_name, void *rsp, int rsp_len); |
| 153 | |
yq.wang | 99db6f5 | 2024-09-12 01:58:48 -0700 | [diff] [blame] | 154 | int gnss_agnss_get_ept(const void* param); |
| 155 | |
| 156 | int gnss_agnss_inject(void); |
| 157 | |
b.liu | e77ac3a | 2024-07-17 17:36:57 +0800 | [diff] [blame] | 158 | int gnss_ind_set(int fd, int ind_type); |
| 159 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 160 | #endif /* _GNSS_INFO_H */ |