-
Notifications
You must be signed in to change notification settings - Fork 4
/
packet.h
59 lines (45 loc) · 1.26 KB
/
packet.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
/*
* packet.h
*
* Created on: 26-Apr-2009
* Author: Neil MacMillan
*/
#ifndef PACKET_H_
#define PACKET_H_
#include <avr/io.h>
/***** Add labels for the packet types to the enumeration *****/
typedef enum _pt
{
MESSAGE,
ACK,
} PACKET_TYPE;
/***** Construct payload format structures *****/
// structures must be 29 bytes long or less.
typedef struct _msg
{
uint8_t messageid;
uint8_t address[5];
uint8_t messagecontent[23];
} pf_message_t;
typedef struct _ack
{
uint8_t messageid;
} pf_ack_t;
/***** Add format structures to the union *****/
/// The application-dependent packet format. Add structures to the union that correspond to the packet types defined
/// in the PACKET_TYPE enumeration. The format structures may not be more than 29 bytes long. The _filler array must
/// be included to ensure that the union is exactly 29 bytes long.
typedef union _pf
{
uint8_t _filler[29]; // make sure the packet is exactly 32 bytes long - this array should not be accessed directly.
pf_message_t message;
pf_ack_t ack;
} payloadformat_t;
/***** Leave the radiopacket_t structure alone. *****/
typedef struct _rp
{
PACKET_TYPE type;
uint16_t timestamp;
payloadformat_t payload;
} radiopacket_t;
#endif /* PACKET_H_ */