blob: f4c5d0918ed40e3826d6d0896717adcf663b4aad [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001#ifndef __GEOFENCE_H__
2#define __GEOFENCE_H__
3
4#pragma pack(push)
5#pragma pack(4)
6
7typedef struct {
8 bool geofence_support;
9}mtk_geofence_client_capability;
10
11typedef struct {
12 bool geofence_support;
13}mtk_geofence_server_capability;
14
15typedef enum {
16 GEOFENCE_CLIENT_CAP,//geofence client capability
17 INIT_GEOFENCE,//Reserved
18 ADD_GEOFENCE_AREA,
19 PAUSE_GEOFENCE,//Reserved
20 RESUME_GEOFENCE,//Reserved
21 REMOVE_GEOFENCE,
22 RECOVER_GEOFENCE,//Reserved
23 CLEAR_GEOFENCE,
24 QUERY_GEOFENCE_NUM
25} mtk_geofence_command;
26
27typedef enum {
28 GEOFENCE_UNKNOWN = 0,
29 GEOFENCE_ENTERED = 1,
30 GEOFENCE_EXITED = 2,
31} mtk_geofence_status;
32
33typedef int mtk_monitor_transition;
34#define MTK_GEOFENCE_ENTER 0x01
35#define MTK_GEOFENCE_EXIT 0x02
36#define MTK_GEOFENCE_UNCERTAIN 0x04//Reserved
37
38typedef struct mtk_geofence_area {
39 double latitude;
40 double longitude;
41 double radius;
42 int latest_state; /*current state(mtk_geofence_status), most cases is GEOFENCE_UNKNOWN*/
43 mtk_monitor_transition monitor_transition; /*bitwise , MTK_GEOFENCE_EXIT/MTK_GEOFENCE_ENTER/MTK_GEOFENCE_UNCERTAIN*/
44 int unknown_timer;/*The time limit after which the UNCERTAIN transition should be triggered. This paramter is defined in milliseconds.*/
45} mtk_geofence_property;
46
47typedef struct mtk_geofence_alert {
48 int id;
49 int alert_state;//mtk_geofence_status
50 double latitude;
51 double longitude;
52 double altitude;
53 double speed;
54 double heading;
55 int h_acc;
56 int h_err_majoraxis;
57 int h_err_minoraxis;
58 int h_err_angle;
59 int hor_conf;
60 double pdop;
61 double hdop;
62 double vdop;
63}mtk_geofence_alert;
64
65typedef struct mtk_gnss_tracking_status {
66 int status; //GNSS service tracking OK = 0,GNSS service tracking failure = -1
67 int year;
68 int month;
69 int day;
70 int hour;
71 int minute;
72 int second;
73}mtk_gnss_tracking_status;
74
75typedef struct {
76 void (*geofence_connection_broken)();
77 void (*geofence_fence_alert_callback)(mtk_geofence_alert *ptr);
78 void (*geofence_tracking_status_callback)(mtk_gnss_tracking_status *ptr);
79 void (*geofence_capability_update)(mtk_geofence_server_capability *cap);
80}mtk_geofence_callback;
81
82#define MTK_GFC_SUCCESS (0)
83#define MTK_GFC_ERROR (-1)
84
85#pragma pack(pop)
86
87/*****************************************************************************
88 * FUNCTION
89 * geofenceinf_add_geofence
90 * DESCRIPTION
91 * add one geofence
92 * PARAMETERS
93 * fence: fence detail information
94 * RETURNS
95 * Success: geofence id, >=1
96 * Fail: -1, create fence fail. -2, insufficient_memory. -3,too many fences
97 *****************************************************************************/
98int geofenceinf_add_geofence(mtk_geofence_property *fence);
99
100/*****************************************************************************
101 * FUNCTION
102 * geofenceinf_remove_geofence
103 * DESCRIPTION
104 * romve one geofence
105 * PARAMETERS
106 * geofence_id: geofence id
107 * RETURNS
108 * MTK_GFC_ERROR
109 * MTK_GFC_SUCCESS
110 *****************************************************************************/
111int geofenceinf_remove_geofence(const int geofence_id) ;
112
113/*****************************************************************************
114 * FUNCTION
115 * geofenceinf_clear_geofences
116 * DESCRIPTION
117 * clear all geofences
118 * PARAMETERS
119 * RETURNS
120 * MTK_GFC_ERROR
121 * MTK_GFC_SUCCESS
122 *****************************************************************************/
123int geofenceinf_clear_geofences(void) ;
124
125/*****************************************************************************
126 * FUNCTION
127 * geofenceinf_query_geofences_num
128 * DESCRIPTION
129 * query geofence numbers that geofence feature support
130 * PARAMETERS
131 * RETURNS
132 * MTK_GFC_ERROR(-1)
133 * number: geofence numbers, >= 1
134 *****************************************************************************/
135int geofenceinf_query_geofences_num(void);
136
137/*****************************************************************************
138 * FUNCTION
139 * geofenceinf_client_register
140 * DESCRIPTION
141 * register geofence client
142 * PARAMETERS
143 * name: client name
144 * mtk_geofence_callback *callback: data messsage callback function
145 * RETURNS
146 * MTK_GFC_ERROR(-1), means error
147 * fd:file descriptor
148 *****************************************************************************/
149int geofenceinf_client_register(const char* name, mtk_geofence_callback *callback);
150
151/*****************************************************************************
152 * FUNCTION
153 * geofenceinf_client_capability_config
154 * DESCRIPTION
155 * config client capability, and send to geofence server
156 * PARAMETERS
157 * cap: client capability
158 * RETURNS
159 * MTK_GFC_ERROR
160 * MTK_GFC_SUCCESS
161 *****************************************************************************/
162int geofenceinf_client_capability_config(mtk_geofence_client_capability *cap);
163
164/*****************************************************************************
165 * FUNCTION
166 * mnl2geofence_hdlr
167 * DESCRIPTION
168 * mnl to geofence adaptor handle function
169 * PARAMETERS
170 * fd:file descriptor
171 * mtk_geofence_callback *callback: data messsage callback function
172 * RETURNS
173 * MTK_GFC_ERROR
174 * MTK_GFC_SUCCESS
175 *****************************************************************************/
176int mnl2geofence_hdlr (int fd, mtk_geofence_callback *callback);
177
178#endif