-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkt_headers.h
60 lines (49 loc) · 1.46 KB
/
pkt_headers.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
#ifndef __PKT_HEADERS__
#define __PKT_HEADERS__
#define MAX_MSG_SIZE 60 // Data size between Fusion and UDP service, packet will have 200 bytes data + header
#define MSG_CODE_REG_DATA 0x0
#define MSG_CODE_REPLY_FRAG 0x1
#define MSG_CODE_REQUEST_FRAG 0x2
#define SEQ_MASK 0b1111
#define FRAG_MASK 0b11111
typedef struct __attribute__ ((packed)) Msg_Header {
uint16_t msgCode:2;
uint16_t frgmntIdx:5;
uint16_t frgmnts:5;
uint16_t seqNum:4; // Combined with frgmntIdx the pkt id is within 2^7
uint8_t size;
} Msg_Header_t;
/*
* Handshake
*/
typedef struct __attribute__ ((packed)) rUdp_Handshake {
uint8_t msgCode:2;
uint8_t pad:6;
uint16_t transmition_timeout_secs;
uint16_t retransmission_timeout_secs;
uint16_t iot_port;
} rUdp_Handshake_t;
typedef struct __attribute__ ((packed)) rUdpFragmntReq {
uint8_t msgCode:2;
uint8_t pad:6;
uint8_t fragmntLost;
uint8_t seqNum;
} rUdpFragmntReq_t;
typedef struct __attribute__ ((packed)) Msg_Buf
{
Msg_Header_t msgHeader;
uint8_t data[MAX_MSG_SIZE];
uint8_t opCode;
uint16_t termId;
uint8_t hiSkyId[6];
uint16_t msgLen;
uint8_t seqNum;
struct timeval time;
struct Msg_Buf *next;
}Msg_Buf_t;
typedef struct HUB_Message
{
uint16_t size;
uint8_t data[MAX_MSG_SIZE];
}HUB_Message_t;
#endif