-
Notifications
You must be signed in to change notification settings - Fork 1
/
protocol.h
157 lines (103 loc) · 2.48 KB
/
protocol.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
#ifndef PROTOCOL_H_
#define PROTOCOL_H_
#include "stdio.h"
#define BG96
//#define SARA_U2
#define QUECTEL_GPS
//#define UBLOX_GPS
#define PACKET_HEADER_SIZE 13
#define COLLECTION_CYCLE_TIMEOUT 300
#define GPS_UPDATE_TIME 90
#define CONFIG_FILE (0x8010)
#define CONFIG_REC_KEY (0x7010)
#define PACKET_TYPE_UPLINK_EVENT_HEADER_0 0x04
#define PACKET_TYPE_UPLINK_SENSOR_DATA_HEADER_0 0x06
#define PACKET_TYPE_DOWNLINK_ACK_HEADER_0 0x00
#define PACKET_TYPE_DOWNLINK_TIME_DATA_HEADER_0 0x02
#define PACKET_TYPE_DOWNLINK_SETUP_DATA_HEADER_0 0x03
#define CHIP_MANUFACTURER_NORDIC 0x01
#define CHIP_IDENTIFIER_NRF52832 0x01
#define COMMUNICATION_TYPE_BLE_CONNECTION_1M 0x01
#define EVENT_TYPE_POWER_OFF 0x00
#define EVENT_TYPE_POWER_ON 0x01
#define EVENT_TYPE_RUN_TIME_EVENT 0x02
#define PRODUCT_ID_AA_MB_01 0x01
#define NODE_EVENT_PACKET_SIZE 14
#define NODE_DATA_PACKET_SIZE 21
typedef union {
struct {
uint8_t DEVICE_ROLE :1;
uint8_t PACKET_TYPE :3;
uint8_t CHIP_MANUFACTURER :4;
} bits;
uint8_t value;
} packet_header_0_t;
typedef union {
struct {
uint8_t CHIP_IDENTIFIER :5;
uint8_t COMMUNICATION_TYPE :3;
} bits;
uint8_t value;
} packet_header_1_t;
typedef union {
struct {
uint8_t EVENT_TYPE :2;
uint8_t UNKNOWN_RESET :1;
uint8_t COMMUNICATION_TIMEOUT_RESET :1;
uint8_t SENSOR_ERROR_RESET :1;
uint8_t MAIN_LOOP_STUCK_RESET :1;
uint8_t WDT_RESET :1;
uint8_t SETUP_COMMAND_RESET :1;
} bits;
uint8_t value;
} packet_event_0_t;
typedef union {
struct {
uint8_t CELLUAR_ERROR :1;
uint8_t GPS_ERROR :1;
uint8_t SI7051_ERROR :1;
uint8_t BMA400_ERROR :1;
uint8_t RESERVED_1 :1;
uint8_t RESERVED_2 :1;
uint8_t RESERVED_3 :1;
uint8_t RESERVED_4 :1;
} bits;
uint8_t value;
} packet_event_1_t;
typedef union {
struct {
uint16_t PRODUCT_ID :14;
uint16_t DEVICE_TYPE :1;
uint16_t PRODUCT_TYPE :1;
} bits;
uint16_t value;
} product_id_t;
typedef union {
struct {
uint8_t header_0;
uint8_t header_1;
uint8_t mac_address[8];
uint8_t product_id[2];
uint8_t event_value_0;
uint8_t event_value_1;
} Event_Packet;
struct {
uint8_t header_0;
uint8_t header_1;
uint8_t mac_address[8];
uint8_t packet_info; //11Byte
uint8_t battery_value;
uint8_t temperature[2];
uint8_t intterupt;
uint8_t ax[2];
uint8_t ay[2];
uint8_t az[2];
uint8_t roll[2];
uint8_t pitch[2];
uint8_t HDOP;
uint8_t latitude[4];
uint8_t longitude[4];
} Data_Packet;
uint8_t buffer[22];
} node_packet_data_t;
#endif /* PROTOCOL_H_ */