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