blob: 78662a9c22ecbc157b03e9e9eda06524d2bec30b [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"
12
13#define GNSS_ID_6228 "6228"
14#define GNSS_ID_5311 "5311"
b.liuf9fbfa12024-06-14 15:53:59 +080015#define GNSS_ID_8122 "8122"
b.liu8f231a12024-05-31 17:55:06 +080016
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
22typedef enum {
23 GNSS_ERR_OK,
24 GNSS_ERR_UNSUPPORT,
25 GNSS_ERR_TIMEOUT,
26 GNSS_ERR_ARG,
27 GNSS_ERR_CHECKSUM,
b.liu5f950c52024-06-15 20:13:12 +080028 GNSS_ERR_SET_BUSY,
b.liu8f231a12024-05-31 17:55:06 +080029
30 GNSS_ERR_UNKNOWN
31} gnss_err_enum;
32
33typedef int (*gnss_dev_open_func)();
34typedef int (*gnss_dev_close_func)();
35typedef int (*gnss_open_func)(const char *dev);
36typedef int (*gnss_close_func)(int fd);
37typedef int (*gnss_fw_dl_func)(int fd);
38typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len);
39typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len);
40typedef void (*gnss_set_cb_func)(const void *data, int data_len);
41
42typedef enum {
43 GNSS_TYPE_6228 = 0,
44 GNSS_TYPE_5311,
b.liuf9fbfa12024-06-14 15:53:59 +080045 GNSS_TYPE_8122
b.liu8f231a12024-05-31 17:55:06 +080046} gnss_id_enum;
47
48typedef 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
wangyouqiang9ee6eaa2024-06-17 13:43:45 +080056typedef enum {
57 GNSS_RESULT_STATE_OPEN_SUCCESS,
58 GNSS_RESULT_STATE_OPEN_FAIL,
59 GNSS_RESULT_STATE_CLOSE_SUCCESS,
60 GNSS_RESULT_STATE_CLOSE_FAIL,
61 GNSS_RESULT_STATE_SET_SUCCESS,
62 GNSS_RESULT_STATE_SET_FAIL,
63 GNSS_RESULT_STATE_UNSUPPORT,
64 GNSS_RESULT_STATE_UNKNOWN_ERROR,
65} gnss_result_enum;
66
b.liu8f231a12024-05-31 17:55:06 +080067typedef struct {
68 gnss_id_enum gnss_id;
69 char dev_name[32];
70 bool auto_open; // Should auto open gnss?
71 bool auto_dl_fw; // Should download firmware int the first?
72 int fd; // GNSS uart fd.
73 int exit_fd[2]; // Use to exit thread.
74 gnss_state_enum state;
75 uint32 print_port;
76 pthread_t read_pid; // Read NMEA thread.
77
78 // GNSS functions.
79 gnss_dev_open_func gnss_dev_open;
80 gnss_dev_close_func gnss_dev_close;
81 gnss_open_func gnss_open;
82 gnss_close_func gnss_close;
83 gnss_fw_dl_func gnss_fw_dl;
84 gnss_dl_read_cb_func gnss_dl_read_cb;
85 gnss_set_func gnss_set;
86 gnss_set_cb_func gnss_set_cb;
87} gnss_info_t;
88
b.liu5f950c52024-06-15 20:13:12 +080089int gnss_init(uint32 print_port);
90
91int gnss_deinit();
92
93int gnss_set(const void* buf, unsigned int buf_len, void *cmd_rsp, int cmd_rsp_len);
94
b.liu8f231a12024-05-31 17:55:06 +080095#endif /* _GNSS_INFO_H */