-
Notifications
You must be signed in to change notification settings - Fork 0
/
lunix-protocol.h
65 lines (55 loc) · 1.77 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
/*
* 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 */