forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

wujiazhi
2024-06-11 65062d0d5b21f838aa0043a15ce54cfab8d72c43
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
#ifndef _GPRS_PROTOCOL_IDEACREATED_GASMETER_API_H_
#define _GPRS_PROTOCOL_IDEACREATED_GASMETER_API_H_
 
#include "define_all.h" 
#include "gprs_sundry_api.h"
#include "administrator.h"
#include "system_parameter.h"
 
/*ЭÒéÖ¡¹Ì¶¨µÄ³¤¶È*/
#define PROTOCOL_HEAD_LENGTH sizeof(GPRS_PROTOCOL_HEAD_T) // Ð­ÒéÍ·¹Ì¶¨³¤¶È
#define PROTOCOL_TAIL_LENGTH sizeof(GPRS_PROTOCOL_TAIL_T) // Ð­Òéβ¹Ì¶¨³¤¶È
 
/*ÆÕͨ·¢ËÍÊý¾ÝÄÚÈݹ̶¨³¤¶È*/
#define PROTOCOL_NORMAL_DATA_HEAD_LENGTH sizeof(GPRS_PROTOCOL_NORMAL_DATA_HEAD_T) // ÆÕͨ·¢ËÍÊý¾ÝÍ·¹Ì¶¨³¤¶È
#define PROTOCOL_NORMAL_DATA_PACK_LENGTH sizeof(GPRS_PROTOCOL_NORMAL_DATA_PACK_T) // ÆÕͨ·¢ËÍÊý¾Ý°ü¹Ì¶¨³¤¶È
#define PROTOCOL_NORMAL_DATA_PACK_1_LENGTH sizeof(GPRS_PROTOCOL_NORMAL_DATA_PACK_1_T) // Êý¾Ý°ü1 ¹Ì¶¨³¤¶È
#define PROTOCOL_NORMAL_DATA_PACK_2_LENGTH sizeof(GPRS_PROTOCOL_NORMAL_DATA_PACK_2_T) // Êý¾Ý°ü2 ¹Ì¶¨³¤¶È
 
/*ÉèÖÃÃüÁîÓ¦´ðÊý¾ÝÄÚÈݹ̶¨³¤¶È*/
#define PROTOCOL_SET_CMD_DATA_BACK_LENGTH 1 // ËùÓÐÆ½Ì¨Ï·¢µÄÉèÖÃÃüÁîµÄ·µ»ØÊý¾Ý³¤¶È
 
#define PROTOCOL_FUNC_PARA_LENGTH sizeof(struct func_para)
#define PROTOCOL_SEND_CFG_LENGTH sizeof(struct send_cfg)
#define PROTOCOL_IP_PARA_LENGTH sizeof(struct ip_para)
#define PROTOCOL_DEVICE_INFO_LENGTH sizeof(struct device_info)
#define PROTOCOL_BALANCE_ALARM_LENGTH sizeof(struct balance_alarm_para)    
#define PROTOCOL_FLOW_CLOSE_LENGTH sizeof(struct cumulate_flow_close_para)    
 
#define PROTOCOL_START_CODE 0x68 // Ð­ÒéÆðʼ·û
#define PROTOCOL_END_CODE 0x16   // Ð­Òé½áÊø·û
#define PROTOCOL_VERSION 0x40    // Ð­Òé°æ±¾
#define DATA_START_CODE 0x55     // Êý¾ÝÆðʼ·û
 
#define PROTOCOL_NORMAL_SEND_CMD_U16 0x0101          // ÆÕͨÉϱ¨ÃüÁî±êʶ
#define PROTOCOL_END_CMD_U16 0x0102                  // ½áÊøÖ¡ÃüÁî±êʶ
#define PROTOCOL_OPERATION_KEY_U16 0x0103            // Ï·¢ÔËÓªÃÜÔ¿
#define PROTOCOL_BACKSETTLE_INFO_U16 0x0104          // ÍÆËͺǫ́½áËãÐÅÏ¢
#define PROTOCOL_STARTEND_COUNT_U16 0x0201           // Æô¡¢Í£ÓÃ
#define PROTOCOL_SET_FUN_PARA_U16 0x0202             // ÉèÖù¦ÄܲÎÊý
#define PROTOCOL_READ_FUN_PARA_U16 0x0203            // ¶ÁÈ¡¹¦ÄܲÎÊý
#define PROTOCOL_SET_ALARM_COUNT_U16 0x0204          // ÉèÖñ¨¾¯¿ØÖÆ×Ö
#define PROTOCOL_READ_ALARM_COUNT_U16 0x0205         // ¶ÁÈ¡±¨¾¯¿ØÖÆ×Ö
#define PROTOCOL_SET_SEND_CYCLE_U16 0x0206           // Éϱ¨ÖÜÆÚÉèÖÃ
#define PROTOCOL_READ_SEND_CYCLE_U16 0x0207          // ¶ÁÈ¡Éϱ¨ÖÜÆÚ
#define PROTOCOL_SET_METER_PARA_U16 0x0208           // ÉèÖöԽÓÒDZí²ÎÊý
#define PROTOCOL_READ_METER_PARA_U16 0x0209          // ¶ÁÈ¡¶Ô½ÓÒDZí²ÎÊý
#define PROTOCOL_READ_EQUIP_PARA_U16 0x0220          // ¶ÁÈ¡É豸ÐÅÏ¢
#define PROTOCOL_SET_TIME_CMD_U16 0x0221             // ÉèÖÃʱ¼äÃüÁî±êʶ
#define PROTOCOL_SET_IP_U16 0x0222                   // IPµØÖ·ÉèÖÃ
#define PROTOCOL_READ_IP_U16 0x0223                  // ¶ÁÈ¡IPµØÖ·
#define PROTOCOL_CLEAR_EXCEPTION_U16 0x0224          // Çå³ýÒì³£
#define PROTOCOL_CLEAR_COUNT_U16 0x0225              // ×ÜÁ¿ÇåÁã
#define PROTOCOL_SAVE_TIME_POINT_U16 0x0230          // ÈÕԼǼ±£´æÊ±¼äµãÉèÖÃ
#define PROTOCOL_READ_TIME_POINT_U16 0x0231          // ¶ÁÈ¡ÈÕԼǼ±£´æÊ±¼äµã
#define PROTOCOL_READ_HISTORY_U16 0x0232             // ¶ÁÈ¡ÀúÊ·¼Ç¼
#define PROTOCOL_READ_VALVE_RECORD_U16 0x0233        // ¶ÁÈ¡·§ÃŲÙ×÷¼Ç¼
#define PROTOCOL_READ_MODIFY_ACC_RECORD 0x0234       // È¥¶ÁÀÛ»ýÁ¿Ð޸ļǼ
#define PROTOCOL_CONT_VALVE 0x0301                   // ·§ÃÅ¿ØÖÆ
#define PROTOCOL_SET_BALANCE_CLOSE_VALVE 0x0302      // ÉèÖÃÓà¶î¹Ø·§
#define PROTOCOL_READ_BALANCE_CLOSE_VALVE 0x0303     // ¶ÁÈ¡Óà¶î¹Ø·§
#define PROTOCOL_SET_CLOSE_VALVE 0x0304              // ÉèÖùط§¿ØÖƹ¦ÄÜ
#define PROTOCOL_READ_CLOSE_VALVE 0x0305             // ¶ÁÈ¡¹Ø·§¿ØÖƹ¦ÄÜ
#define PROTOCOL_SET_DONT_REPORT_CLOSE_VALVE 0x0306  // ÉèÖÃÎÞÉϱ¨¹Ø·§ÌìÊý
#define PROTOCOL_READ_DONT_REPORT_CLOSE_VALVE 0x0307 // ¶ÁÎÞÉϱ¨¹Ø·§ÌìÊý
#define PROTOCOL_SET_DONT_USE_GAS_DAY 0x0308         // ÉèÖÃÎÞÓÃÆø¹Ø·§ÌìÊý
#define PROTOCOL_READ_DONT_USE_GAS_DAY 0x0309        // ¶ÁÎÞÓÃÆø¹Ø·§ÌìÊý
#define PROTOCOL_SET_COUNT_CLOSE_VALVE 0x0310        // ÉèÖÃÀÛ»ýÁ¿¹Ø·§
#define PROTOCOL_READ_NO_COUNT_CLOSE_VALVE 0x0311    // ¶ÁÎÞÀÛ»ýÁ¿¹Ø·§
 
#define PROTOCOL_PAY_MONEYS_U16 0x0401   // ½ð¶î³äÖµ
#define PROTOCOL_ADJUST_PRICE_U16 0x0402 // µ÷¼Û
#define PROTOCOL_READ_PRICE_U16 0x0403   // ¶Á¼Û
 
#define GPRS_PROTOCOL_SEND_FUNC_TABLE_NUM sizeof(gprs_protocol_send_tab_func) / sizeof(GPRS_PROTOCOL_SEND_FUNC_TABLE_DRV_T)
#define GPRS_PROTOCOL_RECV_FUNC_TABLE_NUM sizeof(gprs_protocol_recv_tab_func) / sizeof(GPRS_PROTOCOL_RECV_FUNC_TABLE_DRV_T)
 
typedef enum
{
  PROTOCOL_UNKOWN_STATUS = 0U,
  PROTOCOL_END_STATUS,
 
  PROTOCOL_NORMAL_SEND_CMD,
  PROTOCOL_ALARM_SEND_CMD,
 
  PROTOCOL_READ_FUNC_BACK,                    // 0x0203
  PROTOCOL_READ_ALARM_CONTROL_BACK,           // 0x0205
  PROTOCOL_READ_SEND_CYCLE_BACK,              // 0x0207
  PROTOCOL_READ_METER_PARA_BACK,              // 0x0209
  PROTOCOL_READ_EQUIP_PARA_BACK,              // 0x0220
  PROTOCOL_SET_IP_BACK,                       // 0x0222
  PROTOCOL_READ_IP_BACK,                      // 0x0223
  PROTOCOL_CLEAR_COUNT_BACK,                  // 0x0225
  PROTOCOL_READ_TIME_POINT_BACK,              // 0x0231
  PROTOCOL_READ_HISTORY_BACK,                 // 0x0232
  PROTOCOL_READ_VALVE_RECORD_BACK,            // 0x0233
  PROTOCOL_READ_MODIFY_ACC_RECORD_BACK,       // 0x0234
  PROTOCOL_READ_BALANCE_CLOSE_VALVE_BACK,     // 0x0303
  PROTOCOL_READ_CLOSE_VALVE_BACK,             // 0x0305
  PROTOCOL_READ_DONT_REPORT_CLOSE_VALVE_BACK, // 0x0307
  PROTOCOL_READ_DONT_USE_GAS_DAY_BACK,        // 0x0309
  PROTOCOL_READ_NO_COUNT_CLOSE_VALVE_BACK,    // 0x0311
 
  PROTOCOL_PAY_MONEYS_BACK,
    PROTOCOL_READ_PRICE_NOW_INF_BACK,           //  0x0403
 
  PROTOCOL_SET_RECV_SUCCORFAIL, // ÉèÖýÓÊÕͨÓ÷µ»Ø
} GPRS_PROTOCOL_STATUS;
 
 
#pragma pack(1)
 
/*¿ª±ÙÈáÐÔÊý×é*/
typedef struct
{
  uint8_t send_len;
  uint8_t send_buffer[];
} GPRS_PROTOCOL_SEND_BUFFER_T;
 
typedef union
{
  uint8_t union_buff[150];
  uint8_t secret_keys[8][16];
  struct recv_settle_data
  {
    uint8_t settle_time_bcd[6];         // ½áËãµÄʱ¼ä
    int64_t settle_cumulate_sc;          // ½áËãµÄ×ÜÁ¿
    int64_t settle_balance;              // ½áËãµÄÓà¶î
    uint32_t settle_price;              // ½áËãµÄµ¥¼Û
    uint8_t settle_ladder;              // ½áËãµÄ½×ÌÝ
    uint8_t settle_balance_small_state; // ½áËãµÄÓà¶îÉÙ¶î״̬
    uint8_t last_pay_time[6];           // ÉÏÒ»´Î³äֵʱ¼ä
    int64_t last_pay_money;              // ÉÏÒ»´Î³äÖµµÄÇ®
    uint8_t reserve[19];
  } settle_data_s;
  uint8_t account_state; // ÕË»§×´Ì¬£¨ÆôÍ£Óã©
  struct func_para
  {
    uint8_t lcd_display_mode;
    uint8_t virtual_billing_state;
    uint8_t display_balance;
    uint8_t display_price;
    uint8_t gprs_usually_on_line; // ³£ÔÚÏß
    uint8_t reserve[25];
  } func_para_s; // gprsЭÒ鹦ÄܲÎÊý¸ñʽ
  struct send_cfg
  {
    uint8_t gprs_interval_type;
    uint16_t gprs_send_period_min_time;           // gprs·¢Ë͵ļä¸ô·ÖÖÓʱ¼ä
    uint16_t extern_pwr_send_period_reserve;      // Íâµç·¢Ëͼä¸ôʱ¼ä(Ô¤Áô)
    uint8_t gprs_reference_time_bcd[2];           // »ù׼ʱ¼ä BCD£¨[0] = Ð¡Ê± [1] = ·ÖÖÓ£©
    uint8_t gprs_timed_number;                    // ¶¨Ê±´ÎÊý
    uint8_t gprs_timing_time_bcd[12][2];          // ¶¨Ê±Ê±¼ä
    uint16_t gprs_timeout;                        // ³¬Ê±Ê±¼ä
    uint16_t gprs_restart_send_interval_min_time; // gprsÖØÐ·¢Ë͵ļä¸ô·ÖÖÓʱ¼ä
    uint8_t gprs_restart_number;                  // gprsÖØÐ·¢Éú´ÎÊý
    uint8_t pack_or_independent_data;             // ´ò°üÉÏ·¢or¶ÀÁ¢ÉÏ·¢
    uint16_t save_data_period_min_time;           // ²É¼¯Êý¾ÝµÄ¼ä¸ô·ÖÖÓʱ¼ä
    uint16_t extern_pwr_save_period_reserve;      // Íâµç²É¼¯Êý¾Ý¼ä¸ôʱ¼ä£¨Ô¤Áô£©
    uint8_t save_reference_time_bcd[2];           // »ù׼ʱ¼ä BCD£¨[0] = Ð¡Ê± [1] = ·ÖÖÓ£©
    uint8_t reserve[13];
  } send_cfg_s; // gprsЭÒé·¢ËÍÅäÖøñʽ
  struct ip_para
  {
    uint8_t status_ip_1;
    uint8_t gprs_ip_1[4];
    uint16_t gprs_port_1;
    uint8_t gprs_link_type_1;
    uint8_t status_ip_2;
    uint8_t gprs_ip_2[4];
    uint16_t gprs_port_2;
    uint8_t gprs_link_type_2;
  } ip_para_s; // gprsЭÒéip²ÎÊý¸ñʽ
  struct balance_alarm_para
  {
    int32_t balance_small_value_1;
    uint8_t valve_cfg_flag_1;
    int32_t balance_small_value_2;
    uint8_t valve_cfg_flag_2;
    int32_t balance_small_value_3;
    uint8_t valve_cfg_flag_3;
    int32_t balance_small_value_4;
    uint8_t valve_cfg_flag_4;
    int32_t balance_small_value_5;
    uint8_t valve_cfg_flag_5;
  } balance_alarm_para_s;
  struct pay_moneys_para
  {
    uint8_t pay_moneys_flag;        //½ð¶î³äÖµ±êʶ
    uint16_t pay_moneys_cnt;        //³äÖµÐòºÅ
    long long pay_value;                //³äÖµ½ð¶î
  } pay_moneys_para_s;
  struct cumulate_flow_close_para
  {
    uint32_t set_cumulate_flow_value;
    uint8_t valve_control_type;
  } cumulate_flow_close_para_s;
    struct price_cfg
    {
        uint16_t price_ver;
        uint8_t set_price_type_mode;
        uint32_t normal_price_now;
        uint8_t period_state;
    }price_cfg_s;
    struct device_info
    {
        uint8_t device_iccid[20];
        uint8_t device_imei[15];
        uint8_t device_net_info;
        uint8_t device_hardware_ver_bcd[4];
        uint8_t device_software_ver_bcd[4];
        uint8_t reserve[32];
    }device_info_s;
} GPRS_PTL_CMD_UNION_T;
 
typedef struct
{
  uint8_t frame_start_code;     // Ö¡Æðʼ·û
  uint8_t device_num[8];        // ±í¾ß±àºÅ
  uint8_t data_start_code;      // Êý¾ÝÆðʼ·û
  uint8_t device_time[6];       // ÏµÍ³Ê±¼ä
  uint8_t protocol_ver;         // Ð­Òé°æ±¾
  uint16_t cmd_code_u16;        // ÃüÁî±êʶ
  uint16_t frame_num;           // Ö¡ÐòÁкÅ
  uint16_t frame_sum;           // ×ÜÖ¡Êý
  uint8_t key_ver;              // ÃÜÔ¿°æ±¾ºÅ
  uint16_t data_content_length; // 221101Êý¾ÝÄÚÈݳ¤¶È
} GPRS_PROTOCOL_HEAD_T;         // ¹Ì¶¨µÄÖ¡Í·Êý¾Ý
 
typedef struct
{
  uint16_t check_crc;     // crcУÑé
  uint8_t frame_end_code; // Ö¡½áÊø·û
} GPRS_PROTOCOL_TAIL_T;   // ¹Ì¶¨µÄ֡βÊý¾Ý
 
typedef struct
{
  DEVICE_TYPE equipment_type;                            // É豸ÀàÐÍ
  DEVICE_MODEL equipment_model;                          // É豸ÐͺÅ
  uint8_t sys_send_type;                                 // Éϸ淽ʽ
  int8_t iccid[20];                                     // iccid
  uint8_t signal_intensity;                              // ÐźÅÇ¿¶È
  uint8_t signal_intensity_level;                        // ÐźÅÇ¿¶ÈµÈ¼¶
  uint8_t net_info;                                      // ÍøÂçÐÅÏ¢
  uint8_t software_version[4];                           // Èí¼þ°æ±¾ºÅ
  uint8_t account_state;                                 // ¿ª»§×´Ì¬
  uint16_t alarm_word[SYS_ALARM_BYTES_TYPE_LENGTH >> 1]; // ±¨¾¯×Ö
  uint16_t valve_close_reason;                           // ¹Ø·§Ô­Òò×Ö
  uint8_t reserve[8];                                    // ±£Áô
  uint8_t data_package_format;                           // Êý¾Ý°ü¸ñʽ
  uint8_t data_pack_num;                                 // Êý¾Ý°üÌõÊý
} GPRS_PROTOCOL_NORMAL_DATA_HEAD_T;                      // ÆÕͨÊý¾ÝµÄ¹Ì¶¨¸ñʽͷ
 
typedef struct
{
  GPRS_PROTOCOL_HEAD_T gprs_protocol_head;
  GPRS_PROTOCOL_TAIL_T gprs_protocol_tail;
  GPRS_PROTOCOL_NORMAL_DATA_HEAD_T gprs_protocol_normal_data_head;
} GPRS_PROTOCOL_HEAD_TAIL_T;
 
typedef struct
{
  uint8_t sample_time[6]; // ¶³½áʱ¼ä
  uint64_t sc_cumulate;   // ÕýÏò±ê¿ö×ÜÁ¿£¬ÎÞ·ûºÅ
  uint64_t wc_cumulate;   // ÕýÏò¹¤¿ö×ÜÁ¿£¬ÎÞ·ûºÅ
  int32_t sc_instant;     // ±ê¿ö˲ʱÁ¿£¬ÓзûºÅ
  int32_t wc_instant;     // ¹¤¿ö˲ʱÁ¿£¬ÓзûºÅ
  float pressure;
  float temperature;
  int64_t balance;                                    // Ê£Óà½ð¶î£¬ÓзûºÅ
  uint32_t uint_price;                                // µ¥¼Û
  uint8_t lith_vcc;                                   // ï®µç³Øµçѹ
  int8_t lith_vcc_per;                               // ï®µç³Øµçѹ°Ù·Ö±È
  uint8_t alka_vcc;                                   // ¼îµç³Øµçѹ
  int8_t alka_vcc_per;                               // ¼îµç³Øµçѹ°Ù·Ö±È
  uint16_t status[SYS_STATUS_BYTES_TYPE_LENGTH >> 1]; // ×´Ì¬×Ö
//uint8_t reserved[40];
} GPRS_PROTOCOL_NORMAL_DATA_PACK_T;
 
typedef struct
{
  uint8_t sample_time[6];        // ¶³½áʱ¼ä
  uint64_t sc_cumulate;          // ÕýÏò±ê¿ö×ÜÁ¿
  uint64_t wc_cumulate;          // ÕýÏò¹¤¿ö×ÜÁ¿
  int32_t sc_instant;            // ±ê¿ö˲ʱÁ¿
  int32_t wc_instant;            // ¹¤¿ö˲ʱÁ¿
  float pressure;                // Ñ¹Á¦
  float temperature;             // Î¶È
  int64_t balance;               // Ê£Óà½ð¶î
  uint32_t uint_price;           // µ¥¼Û
  uint8_t lith_vcc;              // ï®µç³Øµçѹ
  int8_t lith_vcc_per;          // ï®µç³Øµçѹ°Ù·Ö±È
  uint8_t alka_vcc;              // ¼îµç³Øµçѹ
  int8_t alka_vcc_per;          // ¼îµç³Øµçѹ°Ù·Ö±È
  uint8_t signal_noise_ratio_a1; // ÐÅÔë±ÈA1
  uint8_t signal_noise_ratio_b1; // ÐÅÔë±ÈB1
  uint8_t gain_a1;               // ÔöÒæA1
  uint8_t gain_b1;               // ÔöÒæB1
  uint8_t signal_intensity_a1;   // ÐźÅÇ¿¶È
  uint8_t signal_intensity_b1;
  float channel_time_a1; // Í¨µÀʱ¼ä
  float channel_time_b1;
  float Channel_sound_v;   // Í¨µÀÉùËÙ
  float Channel_flow_rate; // Í¨µÀÁ÷ËÙ
  uint16_t status[SYS_STATUS_BYTES_TYPE_LENGTH >> 1];
} GPRS_PROTOCOL_NORMAL_DATA_PACK_1_T;
 
typedef struct
{
  uint8_t sample_time[6];        // ¶³½áʱ¼ä
  uint64_t sc_cumulate;          // ÕýÏò±ê¿ö×ÜÁ¿£¬ÎÞ·ûºÅ
  uint64_t wc_cumulate;          // ÕýÏò¹¤¿ö×ÜÁ¿£¬ÎÞ·ûºÅ
  uint64_t re_sc_cumulate;       // ·´Ïò±ê¿ö×ÜÁ¿
  uint64_t re_wc_cumulate;       // ·´Ïò¹¤¿ö×ÜÁ¿
  int32_t sc_instant;            // ±ê¿ö˲ʱÁ¿£¬ÓзûºÅ
  int32_t wc_instant;            // ¹¤¿ö˲ʱÁ¿£¬ÓзûºÅ
  float pressure;                // Ñ¹Á¦
  float temperature;             // Î¶È
  float temp_environment;        // »·¾³Î¶È
  int64_t balance;               // Ê£Óà½ð¶î£¬ÓзûºÅ
  uint32_t uint_price;           // µ¥¼Û
  uint8_t lith_vcc;              // ï®µç³Øµçѹ
  int8_t lith_vcc_per;          // ï®µç³Øµçѹ°Ù·Ö±È
  uint8_t alka_vcc;              // ¼îµç³Øµçѹ
  int8_t alka_vcc_per;          // ¼îµç³Øµçѹ°Ù·Ö±È
  uint8_t signal_noise_ratio_a1; // ÐÅÔë±ÈA1
  uint8_t signal_noise_ratio_b1; // ÐÅÔë±ÈB1
  uint8_t signal_noise_ratio_a2; // ÐÅÔë±ÈA2
  uint8_t signal_noise_ratio_b2; // ÐÅÔë±ÈB2
  uint8_t signal_noise_ratio_a3; // ÐÅÔë±ÈA3
  uint8_t signal_noise_ratio_b3; // ÐÅÔë±ÈB3
  uint8_t gain_a1;               // ÔöÒæ
  uint8_t gain_b1;
  uint8_t gain_a2;
  uint8_t gain_b2;
  uint8_t gain_a3;
  uint8_t gain_b3;
  uint8_t signal_intensity_a1; // ÐźÅÇ¿¶È
  uint8_t signal_intensity_b1;
  uint8_t signal_intensity_a2;
  uint8_t signal_intensity_b2;
  uint8_t signal_intensity_a3;
  uint8_t signal_intensity_b3;
  float channel_time_a1; // Í¨µÀʱ¼ä
  float channel_time_b1;
  float channel_time_a2;
  float channel_time_b2;
  float channel_time_a3;
  float channel_time_b3;
  float Channel_sound_v1; // Í¨µÀÉùËÙ
  float Channel_sound_v2;
  float Channel_sound_v3;
  float Channel_flow_rate1; // Í¨µÀÁ÷ËÙ
  float Channel_flow_rate2;
  float Channel_flow_rate3;
  uint16_t status[SYS_STATUS_BYTES_TYPE_LENGTH >> 1];
} GPRS_PROTOCOL_NORMAL_DATA_PACK_2_T;
 
typedef struct
{
  __IO GPRS_PROTOCOL_STATUS gprs_protocol_type;
} GPRS_PROTOCOL_PARA_T;
 
typedef void (*pGprs_Protocol_Send_FuncHandler)(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail);
typedef struct
{
  const GPRS_PROTOCOL_STATUS gprs_protocol_cmd_table;
  pGprs_Protocol_Send_FuncHandler GprsProtocolSendFuncHandler;
} GPRS_PROTOCOL_SEND_FUNC_TABLE_DRV_T; /*·¢ËÍЭÒé±íÇý¶¯*/
 
typedef GPRS_PROTOCOL_STATUS (*pGprs_Protocol_Recv_FuncHandler)(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
typedef struct
{
  const uint16_t gprs_protocol_cmd_table_u16;
  pGprs_Protocol_Recv_FuncHandler GprsProtocolRecvFuncHandler;
} GPRS_PROTOCOL_RECV_FUNC_TABLE_DRV_T; /*½ÓÊÕЭÒé±íÇý¶¯*/
 
#pragma pack()
 
extern GPRS_PROTOCOL_HEAD_TAIL_T gprs_protocol_head_tail_g;
extern GPRS_PROTOCOL_PARA_T gprs_protocol_para_g;
 
uint16_t Gprs_Protocol_DataLength(uint8_t send_type, GPRS_PROTOCOL_ENCRYPT_PARA *gprs_protocol_encrypt_para_p);
 
 
/************************************** Send Data **************************************************************/
void Gprs_Protocol_SendSetTimeResultHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);
void Gprs_Protocol_SendNormalDataHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);
void Gprs_Protocol_SendDataConfig(uint8_t send_type, uint8_t *pSendData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);
void Gprs_Protocol_SendReadFunHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);                  // ¶Á±í¾ß¹¦ÄܲÎÊý0x0203
void Gprs_Protocol_SendReadAlarmContHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ¶ÁÈ¡±¨¾¯¿ØÖÆ×Ö0x0205
void Gprs_Protocol_SendReadSendCycleHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ¶ÁÈ¡Éϱ¨ÖÜÆÚ0x0207
void Gprs_Protocol_SendReadMeterParaHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ¶ÁÈ¡¶Ô½ÓÒDZí²ÎÊý0x0209
void Gprs_Protocol_SendReadEquipParaHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ¶ÁÈ¡É豸ÐÅÏ¢0x0220
void Gprs_Protocol_SendSetIpaddrHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);                // IPµØÖ·ÉèÖÃ0x0222
void Gprs_Protocol_SendReadIpaddrHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);               // ¶ÁÈ¡IPµØÖ·ÉèÖÃ0x0223
void Gprs_Protocol_SendClearCountHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);               // ×ÜÁ¿ÇåÁã0x0225
void Gprs_Protocol_SendSaveTimePointHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ÈÕԼǼ±£´æÊ±¼äµãÉèÖÃ0x0230
void Gprs_Protocol_SendReadTimePointHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);            // ¶ÁÈ¡ÈÕԼǼ±£´æÊ±¼äµã0x0231
void Gprs_Protocol_SendReadHistoryHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);              // ¶ÁÀúÊ·¼Ç¼0x0232
void Gprs_Protocol_SendReadValveRecordHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);          // ¶ÁÈ¡·§ÃŲÙ×÷¼Ç¼0x0233
void Gprs_Protocol_SendReadModifyAccRecordHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);      // ¶ÁÀÛ»ýÁ¿Ð޸ļǼ0x0234
void Gprs_Protocol_SendReadBalanceCloseValveHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);    // ¶ÁÈ¡Óà¶î¹Ø·§0x0303
void Gprs_Protocol_SendSetCloseValveKeyHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);         // ¶ÁÈ¡¹Ø·§¿ØÖÆ×Ö0x0305
void Gprs_Protocol_SendReadDontReportCloseValveHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p); // ¶ÁÎÞÉϱ¨¹Ø·§ÌìÊý0x0307
void Gprs_Protocol_SendReadDontUseGasDayHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);        // ¶ÁÎÞÓÃÆø¹Ø·§ÌìÊý0x0309
void Gprs_Protocol_SendSetCountCloseValveHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);       // ÉèÖÃÀÛ»ýÁ¿¹Ø·§0x0310
void Gprs_Protocol_SendReadNoCountCloseValveHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);    // ¶ÁÎÞÀÛ»ýÁ¿¹Ø·§0x0311
 
void Gprs_Protocol_SendPayMoneysBackHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p); // ³äǮӦ´ð·µ»Ø
void Gprs_Protocol_SendPriceNowInfHandler(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p);//¶ÁÈ¡µ±Ç°¼Û¸ñÐÅÏ¢0x0403
 
void Gprs_Protocol_SetRecvSuccOrFail(uint8_t *pData, GPRS_PROTOCOL_HEAD_TAIL_T *gprs_protocol_head_tail_p); // ÉèÖýÓÊճɹ¦/ʧ°Ü
/************************************** Recv Data **************************************************************/
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvDataConfig(uint8_t *pRecvData, uint16_t recv_data_length);
 
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvNormalDataHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvEndHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvOperaKeyHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvBackSettleInfoHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvStartEndCountHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetFunParaHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetAlarmContHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetSendCycleHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetMeterParaHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetTimeHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetIpaddrHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvClearExceptionHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvClearCountHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSaveTimePointHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvReadHistoryHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvReadValveRecordHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvReadModifyAccRecordHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvContValveHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetBalanceCloseValveHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetCloseValveHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetDontReportCloseValveHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetDontUseGasDayHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvSetCountCloseValveHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
 
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvPayMoneysHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
GPRS_PROTOCOL_STATUS Gprs_Protocol_RecvAdjustPriceHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
 
GPRS_PROTOCOL_STATUS Gprs_Protocol_Recv_ReadCmdGeneralHandler(GPRS_PTL_CMD_UNION_T *pGprs_ptl_cmd_union);
 
#endif