blob: a292db7179c15f4f4d8d5b9299b691366444552a [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,
28
29 GNSS_ERR_UNKNOWN
30} gnss_err_enum;
31
32typedef int (*gnss_dev_open_func)();
33typedef int (*gnss_dev_close_func)();
34typedef int (*gnss_open_func)(const char *dev);
35typedef int (*gnss_close_func)(int fd);
36typedef int (*gnss_fw_dl_func)(int fd);
37typedef void (*gnss_dl_read_cb_func)(const void *data, int data_len);
38typedef gnss_err_enum (*gnss_set_func)(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len);
39typedef void (*gnss_set_cb_func)(const void *data, int data_len);
40
41typedef enum {
42 GNSS_TYPE_6228 = 0,
43 GNSS_TYPE_5311,
b.liuf9fbfa12024-06-14 15:53:59 +080044 GNSS_TYPE_8122
b.liu8f231a12024-05-31 17:55:06 +080045} gnss_id_enum;
46
47typedef enum {
48 GNSS_STATE_CLOSE, // GNSS is closed.
49 GNSS_STATE_CLOSING, // GNSS is closing.
50 GNSS_STATE_OPEN, // GNSS is opened.
51 GNSS_STATE_DOWNLOAD, // GNSS is downloading.
52 GNSS_STATE_READY, // GNSS is ready.
53} gnss_state_enum;
54
55typedef struct {
56 gnss_id_enum gnss_id;
57 char dev_name[32];
58 bool auto_open; // Should auto open gnss?
59 bool auto_dl_fw; // Should download firmware int the first?
60 int fd; // GNSS uart fd.
61 int exit_fd[2]; // Use to exit thread.
62 gnss_state_enum state;
63 uint32 print_port;
64 pthread_t read_pid; // Read NMEA thread.
65
66 // GNSS functions.
67 gnss_dev_open_func gnss_dev_open;
68 gnss_dev_close_func gnss_dev_close;
69 gnss_open_func gnss_open;
70 gnss_close_func gnss_close;
71 gnss_fw_dl_func gnss_fw_dl;
72 gnss_dl_read_cb_func gnss_dl_read_cb;
73 gnss_set_func gnss_set;
74 gnss_set_cb_func gnss_set_cb;
75} gnss_info_t;
76
77#endif /* _GNSS_INFO_H */