-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeMsg.h
136 lines (113 loc) · 2.69 KB
/
NodeMsg.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
129
130
131
132
133
134
135
136
// Added Comment 2014-12-26
// NodeMsg.h
// Node message types
#ifndef NodeMsg_h
#define NodeMsg_h
#if (ARDUINO < 100)
#include "WProgram.h"
#else
#include <Arduino.h>
#endif
#define MAX_PKG_SIZE 32 // Package size in payload
#define WATCHDOG_DEFAULT 10000 // 10 seconds used by node
/*---------------------------------------------
| !! PKG Types !!
| Structure written to pkg[] array...
|
*/
typedef enum {
// Endpoint ping
pingMsg = 0, // System Ping
// Sprinkler Zone Control types
spklZone = 10, // Zone Control
spklProg = 11, // Program Control
spklSys = 12, // Sprinkler System Control
// Test Message
testMsg = 255 // Test messagte
} NodeMsgType;
typedef enum {
zone1 = 15, // Relay 0
zone2 = 16, // Relay 1
zone3 = 18, // Relay 2
zone4 = 3, // Relay 3
zone5 = 5, // Relay 4
zone6 = 14, // Relay 5
zone7 = 17, // Relay 6
zone8 = 19, // Relay 7
zone9 = 4, // Relay 8
zone10 = 6 // Relay 9
} SprinkleZoneIoMap;
// List of all zones
int zoneList[] = {
zone1, zone2, zone3, zone4, zone5,
zone6, zone7, zone8, zone9, zone10
};
// Message Wrapper
typedef enum {
GET,
SET,
STATUS,
READ,
WRITE,
POST,
DELETE,
RESPONSE,
REQUEST
} msgMethodList;
typedef enum {
// time in minutes
// Number of Seconds / WATCHDOG_DEFAULT
min1 = 6, // 1 Minute for test
min5 = 30,
min7 = 42,
min10 = 60,
} _zoneCycleTime;
// Wrapper structure
typedef struct {
byte pkgType;
byte msgMethod; // See Method List
unsigned long msgID;
byte pkg[MAX_PKG_SIZE]; // 32 bytes
} Payload;
Payload theData;
/*---------------------------------------------
|
| !! PKG Definitions !!
| Sensor specific message structures
|
*/
typedef struct {
byte a;
byte b;
byte c;
byte d;
} _testMsg;
_testMsg testMsgPkg;
typedef struct {
//Pkg for spklZoneCtrl = 10, // Zone Control
byte zoneNumber; // {1}
byte dataDirection; // {1} Send or receive
byte zoneState; // {1} {0=OFF, 1=ENABLE, 2=ON, 3=COMPLETE}
byte zoneCycleTime; // {2} total number of seconds to sprinkle
byte activeCycleTime; // {2} Actuve number of seconds for node
byte percentComplete; // {1} Active time
int pauseTime; // {2} Ammount of time paused... (If in Pause Mode, otherwise 0)
} _spklZone;
_spklZone spklZonePkg;
typedef struct {
// Sprinkler program control
} _spklProg;
_spklProg spklProgPkg;
typedef struct {
unsigned long lifetimeSprinkleSeconds;
} _spklSys;
_spklSys spklSysPkg;
typedef struct {
// Configure sprinkle system defaults
} _spklSysCfg;
_spklSysCfg spklSysCfgPkg;
/*---------------------------------------------------------------------------
| REFERENCE - Datatype Size
|
*/
#endif