This repository has been archived by the owner on Sep 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lunix-protocol.h
128 lines (109 loc) · 3.53 KB
/
lunix-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
/*
* lunix-protocol.h
*
* Definitions file for the implementation of the
* protocol used by the wireless sensor network to report
* back on the measurements of individual sensors.
*
* Ioannis Panagopoulos <[email protected]>
* Vangelis Koukis <[email protected]>
*
*/
#ifndef _LUNIX_PROTOCOL_H
#define _LUNIX_PROTOCOL_H
#ifdef __KERNEL__
/*
* Application/Protocol specific constants
*/
#define MAX_PACKET_LEN 300
#define PACKET_SIGNATURE_OFFSET 4
#define NODE_OFFSET 9
#define VREF_OFFSET 18
#define TEMPERATURE_OFFSET 20
#define LIGHT_OFFSET 22
/*
* States of the Lunix protocol state machine
*/
#define SEEKING_START_BYTE 1
#define SEEKING_PACKET_TYPE 2
#define SEEKING_DESTINATION_ADDRESS 3
#define SEEKING_AM_TYPE 4/*
* lunix-protocol.h
*
* Definitions file for the implementation of the
* protocol used by the wireless sensor network to report
* back on the measurements of individual sensors.
*
* Ioannis Panagopoulos <[email protected]>
* Vangelis Koukis <[email protected]>
*
*/
#ifndef _LUNIX_PROTOCOL_H
#define _LUNIX_PROTOCOL_H
#ifdef __KERNEL__
/*
* Application/Protocol specific constants
*/
#define MAX_PACKET_LEN 300
#define PACKET_SIGNATURE_OFFSET 4
#define NODE_OFFSET 9
#define VREF_OFFSET 18
#define TEMPERATURE_OFFSET 20
#define LIGHT_OFFSET 22
/*
* States of the Lunix protocol state machine
*/
#define SEEKING_START_BYTE 1
#define SEEKING_PACKET_TYPE 2
#define SEEKING_DESTINATION_ADDRESS 3
#define SEEKING_AM_TYPE 4
#define SEEKING_AM_GROUP 5
#define SEEKING_PAYLOAD_LENGTH 6
#define SEEKING_PAYLOAD 7
#define SEEKING_CRC 8
#define SEEKING_END_BYTE 9
/*
* Current state of the Lunix protocol state machine
*/
struct lunix_protocol_state_struct
{
int state; /* The current state of the protocol state machine */
int bytes_read;
int bytes_to_read;
int pos; /* Current pos in the XMesh Packet */
unsigned char next_is_special; /* The next character to be received is a special character */
unsigned char payload_length; /* The length of the payload of the received packet */
unsigned char packet[MAX_PACKET_LEN]; /* The XMesh packet being received */
};
/*
* Function prototypes
*/
void lunix_protocol_init(struct lunix_protocol_state_struct *);
int lunix_protocol_received_buf(struct lunix_protocol_state_struct *, const unsigned char *buf, int count);
#endif /* __KERNEL__ */
#endif /* _LUNIX_H */
#define SEEKING_AM_GROUP 5
#define SEEKING_PAYLOAD_LENGTH 6
#define SEEKING_PAYLOAD 7
#define SEEKING_CRC 8
#define SEEKING_END_BYTE 9
/*
* Current state of the Lunix protocol state machine
*/
struct lunix_protocol_state_struct
{
int state; /* The current state of the protocol state machine */
int bytes_read;
int bytes_to_read;
int pos; /* Current pos in the XMesh Packet */
unsigned char next_is_special; /* The next character to be received is a special character */
unsigned char payload_length; /* The length of the payload of the received packet */
unsigned char packet[MAX_PACKET_LEN]; /* The XMesh packet being received */
};
/*
* Function prototypes
*/
void lunix_protocol_init(struct lunix_protocol_state_struct *);
int lunix_protocol_received_buf(struct lunix_protocol_state_struct *, const unsigned char *buf, int count);
#endif /* __KERNEL__ */
#endif /* _LUNIX_H */