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" |
| 12 | |
| 13 | #define GNSS_ID_6228 "6228" |
| 14 | #define GNSS_ID_5311 "5311" |
b.liu | f9fbfa1 | 2024-06-14 15:53:59 +0800 | [diff] [blame] | 15 | #define GNSS_ID_8122 "8122" |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 16 | |
| 17 | #define GNSS_PRINT_PORT_UART1 1 // 1 |
| 18 | #define GNSS_PRINT_PORT_USB_NMEA (1<<1) // 2 |
| 19 | #define GNSS_PRINT_PORT_USB_AT (1<<2) // 4 |
| 20 | #define GNSS_PRINT_PORT_TTY_AT (1<<3) // 8 |
| 21 | |
| 22 | typedef enum { |
| 23 | GNSS_ERR_OK, |
| 24 | GNSS_ERR_UNSUPPORT, |
| 25 | GNSS_ERR_TIMEOUT, |
| 26 | GNSS_ERR_ARG, |
| 27 | GNSS_ERR_CHECKSUM, |
b.liu | 5f950c5 | 2024-06-15 20:13:12 +0800 | [diff] [blame^] | 28 | GNSS_ERR_SET_BUSY, |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 29 | |
| 30 | GNSS_ERR_UNKNOWN |
| 31 | } gnss_err_enum; |
| 32 | |
| 33 | typedef int (*gnss_dev_open_func)(); |
| 34 | typedef int (*gnss_dev_close_func)(); |
| 35 | typedef int (*gnss_open_func)(const char *dev); |
| 36 | typedef int (*gnss_close_func)(int fd); |
| 37 | typedef int (*gnss_fw_dl_func)(int fd); |
| 38 | typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len); |
| 39 | typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len); |
| 40 | typedef void (*gnss_set_cb_func)(const void *data, int data_len); |
| 41 | |
| 42 | typedef enum { |
| 43 | GNSS_TYPE_6228 = 0, |
| 44 | GNSS_TYPE_5311, |
b.liu | f9fbfa1 | 2024-06-14 15:53:59 +0800 | [diff] [blame] | 45 | GNSS_TYPE_8122 |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 46 | } gnss_id_enum; |
| 47 | |
| 48 | typedef enum { |
| 49 | GNSS_STATE_CLOSE, // GNSS is closed. |
| 50 | GNSS_STATE_CLOSING, // GNSS is closing. |
| 51 | GNSS_STATE_OPEN, // GNSS is opened. |
| 52 | GNSS_STATE_DOWNLOAD, // GNSS is downloading. |
| 53 | GNSS_STATE_READY, // GNSS is ready. |
| 54 | } gnss_state_enum; |
| 55 | |
| 56 | typedef struct { |
| 57 | gnss_id_enum gnss_id; |
| 58 | char dev_name[32]; |
| 59 | bool auto_open; // Should auto open gnss? |
| 60 | bool auto_dl_fw; // Should download firmware int the first? |
| 61 | int fd; // GNSS uart fd. |
| 62 | int exit_fd[2]; // Use to exit thread. |
| 63 | gnss_state_enum state; |
| 64 | uint32 print_port; |
| 65 | pthread_t read_pid; // Read NMEA thread. |
| 66 | |
| 67 | // GNSS functions. |
| 68 | gnss_dev_open_func gnss_dev_open; |
| 69 | gnss_dev_close_func gnss_dev_close; |
| 70 | gnss_open_func gnss_open; |
| 71 | gnss_close_func gnss_close; |
| 72 | gnss_fw_dl_func gnss_fw_dl; |
| 73 | gnss_dl_read_cb_func gnss_dl_read_cb; |
| 74 | gnss_set_func gnss_set; |
| 75 | gnss_set_cb_func gnss_set_cb; |
| 76 | } gnss_info_t; |
| 77 | |
b.liu | 5f950c5 | 2024-06-15 20:13:12 +0800 | [diff] [blame^] | 78 | int gnss_init(uint32 print_port); |
| 79 | |
| 80 | int gnss_deinit(); |
| 81 | |
| 82 | int gnss_set(const void* buf, unsigned int buf_len, void *cmd_rsp, int cmd_rsp_len); |
| 83 | |
b.liu | 8f231a1 | 2024-05-31 17:55:06 +0800 | [diff] [blame] | 84 | #endif /* _GNSS_INFO_H */ |