-
Notifications
You must be signed in to change notification settings - Fork 0
/
gprs.h
309 lines (222 loc) · 4.58 KB
/
gprs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
/*********************************************************************
* Filename: gprs.h
*
*
* Author: Bright Pan <[email protected]>
* Created at: 2013-05-06 11:12:03
*
*
*
* Change Log:
*
* Copyright (C) 2013 Yuettak Co.,Ltd
********************************************************************/
#ifndef _GPRS_H_
#define _GPRS_H_
#include <rthw.h>
#include <rtthread.h>
#include "stm32f10x.h"
#include "alarm.h"
#include "untils.h"
#define GPRS_MAIL_MAX_MSGS 20
typedef struct
{
time_t time;
ALARM_TYPEDEF alarm_type;
uint8_t order;
void* user;
}GPRS_MAIL_TYPEDEF;
extern rt_mq_t gprs_mq;
void gprs_mail_process_thread_entry(void *parameter);
void gprs_heart_process_thread_entry(void *parameters);
void send_gprs_mail(ALARM_TYPEDEF alarm_type, time_t time, uint8_t order,void *user);
typedef struct
{
uint8_t status;//batter status
uint8_t dump_energy;
uint8_t time[6];
}GPRS_POWER_ALARM;
typedef struct {
uint8_t key[4];
uint8_t time[6];
}GPRS_LOCK_OPEN;
typedef struct {
uint8_t power_status;
uint8_t power;
uint8_t time[6];
}GPRS_POWER_FAULT;
typedef struct {
uint16_t type;
uint8_t status;
uint8_t time[6];
}GPRS_WORK_ALARM;
typedef struct {
uint16_t type;
uint8_t time[6];
}GPRS_FAULT_ALARM;
typedef struct
{
uint8_t type;
uint8_t form;
uint8_t DPI;
uint8_t pic_size[2];
uint8_t page;
uint8_t time[6];
}GPRS_SEND_PIC_ASK;
typedef struct {
uint8_t type;
}GPRS_HEART;
typedef struct {
uint8_t device_id[6];
uint8_t enc_data[16];
}GPRS_AUTH;
typedef struct
{
uint8_t result;
uint8_t counts;
uint8_t telephone[TELEPHONE_NUMBERS][11];
}GPRS_SEND_LIST_TELEPHONE;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_TELEPHONE;
typedef struct
{
uint8_t result;
uint8_t counts;
uint8_t key[RFID_KEY_NUMBERS][4];
}GPRS_SEND_LIST_RFID_KEY;
typedef struct
{
uint8_t result;
uint8_t parameters;
}GPRS_SEND_LIST_USER_PARAMETERS;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_USER_PARAMETERS;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_RFID_KEY;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_TIME;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_KEY0;
typedef struct
{
uint8_t result;
}GPRS_SEND_SET_HTTP;
typedef struct
{
uint16_t length;
uint8_t cmd;
uint8_t order;
uint8_t cur_page;
uint8_t* data;
}GPRS_SEND_PIC;
typedef struct
{
uint8_t result;
}GPRS_RTU_ACK;
typedef union
{
GPRS_LOCK_OPEN lock_open;
GPRS_POWER_FAULT power_fault;
GPRS_WORK_ALARM work_alarm;
GPRS_FAULT_ALARM fault_alarm;
GPRS_HEART heart;
GPRS_AUTH auth;
GPRS_SEND_LIST_TELEPHONE list_telephone;
GPRS_SEND_SET_TELEPHONE set_telephone;
GPRS_SEND_LIST_RFID_KEY list_rfid_key;
GPRS_SEND_SET_RFID_KEY set_rfid_key;
GPRS_SEND_LIST_USER_PARAMETERS list_user_parameters;
GPRS_SEND_SET_USER_PARAMETERS set_user_parameters;
GPRS_SEND_SET_TIME set_time;
GPRS_SEND_SET_KEY0 set_key0;
GPRS_SEND_SET_HTTP set_http;
GPRS_POWER_ALARM battery;
GPRS_SEND_PIC_ASK picture;
GPRS_RTU_ACK sleep_ack;
GPRS_RTU_ACK wake_up_ack;
}GPRS_SEND_DATA;
typedef struct
{
uint16_t length;
uint8_t cmd;
uint8_t order;
GPRS_SEND_DATA data;
}GPRS_SEND_FRAME_TYPEDEF;
typedef struct
{
uint8_t type;
}GPRS_LIST_TELEPHONE;
typedef struct
{
uint8_t type;
}GPRS_LIST_RFID_KEY;
typedef struct
{
uint8_t type;
}GPRS_LIST_USER_PARAMETERS;
typedef struct
{
uint8_t parameters;
}GPRS_SET_USER_PARAMETERS;
typedef struct
{
uint8_t counts;
uint8_t telephone[TELEPHONE_NUMBERS][11];
}GPRS_SET_TELEPHONE;
typedef struct
{
uint8_t counts;
uint8_t key[RFID_KEY_NUMBERS][4];
}GPRS_SET_RFID_KEY;
typedef struct
{
uint8_t time[6];
}GPRS_SET_TIME;
typedef struct
{
uint8_t key0[8];
}GPRS_SET_KEY0;
typedef struct
{
uint8_t http_address[100];
}GPRS_SET_HTTP;
typedef struct
{
uint8_t result;
uint8_t resend_num;
uint8_t data[150];
}GPRS_PIC_RESULT;
typedef union
{
GPRS_LIST_TELEPHONE list_telephone;
GPRS_SET_TELEPHONE set_telephone;
GPRS_LIST_RFID_KEY list_rfid_key;
GPRS_SET_RFID_KEY set_rfid_key;
GPRS_LIST_USER_PARAMETERS list_user_parameters;
GPRS_SET_USER_PARAMETERS set_user_parameters;
GPRS_SET_TIME set_time;
GPRS_SET_KEY0 set_key0;
GPRS_SET_HTTP set_http;
GPRS_PIC_RESULT pic_send_result;
}GPRS_RECV_DATA;
typedef struct
{
uint16_t length;
uint8_t cmd;
uint8_t order;
GPRS_RECV_DATA data;
}GPRS_RECV_FRAME_TYPEDEF;
int8_t send_gprs_frame(ALARM_TYPEDEF alarm_type, time_t time, uint8_t order, void* user);
int8_t recv_gprs_frame(GPRS_RECV_FRAME_TYPEDEF *gprs_recv_frame, uint16_t recv_counts);
int8_t send_gprs_auth_frame(void);
#endif