-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeGwMsg.h
77 lines (64 loc) · 2 KB
/
NodeGwMsg.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
/*********** GATEWAY MESSAGE STRUCTURE *******************
Gateways structure is a simplified, abstracted, message
type used to relay messages between host computer and
wireless sensor network.
Gateway message format
HEADER
- MESSAGE PAYLOAD
Function:
Gateway relays messages by inspecting only the message
header. Payload forwarded to target node intact...
MOTEINO MESSAGE FORMAT
----------------------------------
MAX_MESSAGE_SIZE = 66
MESSAGE FRAME SIZES
------------------------
PAYLOAD = 1
ADDRESS_BYTE = 1
FROM_ADDRESS = 1
CONTROL_BYTE = 1
NETWORK_ID = 1
MAX_PAYLOAD = 66 - 5 = 61 BYTES!!!
_____________________________________
Moteino References
https://github.com/LowPowerLab/RFM69
http://lowpowerlab.com/blog/2013/06/20/rfm69-library/#more-917
Developer Notes
1. Payload is not inspected by the gateway.
2. Header inspected by Gateway, used to route message
3. Target node is responsible for processing payload.
4. ASSUMPTION = AVR(Big Endian) RPI(Little Endian)
5. NodeID + MsgID used together to create unique index for xmit.
*/
#ifndef NodeMsg_h
#define NodeMsg_h
#if (ARDUINO < 100)
#include "WProgram.h"
#else
#include <Arduino.h>
#endif
#define FRAME_BUFFER_SIZE 5
#define MAX_SERIAL_SIZE 70
#define MAX_NETWORK_SIZE 61
//#define MAX_PAYLOAD_SIZE 59 // Package size in payload
#define WATCHDOG_DEFAULT 10000 // 10 seconds used by node
/*---------------------------------------------
| !! PKG Types !!
| Structure written to pkg[] array...
|
*/
// Gateway Message Structure
typedef struct {
byte SerialDelimiter;
byte NodeID; // Address of target sensor (00 for echo to gateway)
byte SerialPayloadSize; // Length structure to read
byte SerialPayload[MAX_NETWORK_SIZE];
} SerialMsg;
SerialMsg sMsg;
typedef struct {
byte MsgID; // Coordination ID to ack/nak (unknown if needed for applications)
byte MsgType; // Message type - Struct Decode (10)
byte msg[59]; // Allocate remaining msg space for possible payload. Payload is node specific
} Payload;
Payload payload;
#endif