HomeAut
homeautmessage.h
1 /*******************************************************************************
2  * Purpose:
3  ******************************************************************************/
4 
5 #ifndef HOMEAUTMESSAGE_H_
6 #define HOMEAUTMESSAGE_H_
7 
8 
9 #include "include.h"
10 
11 
12 
13 /*------------------------------------------------------------------------------
14  * Macros & definitions
15  *----------------------------------------------------------------------------*/
16 
17 #define VALID ( 1 )
18 #define INVALID ( 0 )
19 
20 
21 
22 /*------------------------------------------------------------------------------
23  * Type definitions
24  *----------------------------------------------------------------------------*/
25 
27 typedef struct
28 {
29  char Header[9];
30  // |HomeAut|
31  char MyAddress[3];
32  // <MyAddress>
33  char Seperator1[1];
34  // |
35  char TargetAddress[3];
36  // <TargetAddress>
37  char Seperator2[1];
38  // |
39  char Function[7];
40  // <Function>
41  char Seperator3[1];
42  // |
43  char DataType[6];
44  // <DataType> : 6 byte ASCII char
45  char Data[8];
46  // <Data> : 8 byte - ASCII Hex
47  char Seperator4[1];
48  // |
50 
51 // For example message:
52 // |HomeAut|010|014|LOGIN__|NMEDIU00000000|
53 //type = Login_ImLoginImNodeMedium
54 
55 
56 
57 
58 
59 // uint8_t Function[7],
60 /*
61 const uint8_t HOMEAUTMESSAGE_DefaultFunctionLogin[] = "LOGIN__";
62 const uint8_t HOMEAUTMESSAGE_DefaultFunctionState[] = "STATE__";
63 const uint8_t HOMEAUTMESSAGE_DefaultFunctionAlarm[] = "ALARM__";
64 const uint8_t HOMEAUTMESSAGE_DefaultFunctionCommand[] = "COMMAND";
65 const uint8_t HOMEAUTMESSAGE_DefaultFunctionMode[] = "MODE___";
66 const uint8_t HOMEAUTMESSAGE_DefaultFunctionConfig[] = "CONFIG_";
67 */
68 
69 
70 typedef enum
71 {
72  Function_Invalid = 0,
73  Function_Login,
74  Function_State,
75  Function_Alarm,
76  Function_Command,
77  Function_Mode,
78  Function_Config,
79  Function_End
80 } HomeAut_FunctionType;
81 
82 
83 
85 typedef struct
86 {
87  char name[8];
88  HomeAut_FunctionType function;
90 
91 
93 typedef enum
94 {
95  DataType_Unknown = 0,
96 
97  // Login
98  Login_ImLoginImNodeSmall,
99  Login_ImLoginImNodeMedium,
100  Login_ImLoginImCenterPanel,
101  Login_Welcome,
102  Login_Sync,
103 
104 
105  // State
106  State_Temperature,
107  State_Brightness,
108  State_Sound,
109  State_Button,
110  State_Battery,
111  State_Vin,
112  State_Accelerometer,
113  State_Input,
114  State_Output,
115 
116  // Alarm
117  Alarm_TooHot,
118  Alarm_TooCold,
119  Alarm_InternalTemperature_TooHot,
120  Alarm_InternalTemperature_TooCold,
121  Alarm_TooBright,
122  Alarm_TooDark,
123  Alarm_PressedButton,
124  Alarm_OnCharge,
125  Alarm_OffCharge,
126  Alarm_LowBattery,
127  Alarm_Accelerometer,
128  Alarm_InputRise,
129  Alarm_InputFalling,
130  Alarm_InputAllState,
131  Alarm_Moving,
132  Alarm_SoundImpacted,
133  Alarm_DoorOpened,
134 
135  // Command: Master send command to Slave
136  Command_SetOutput,
137  Command_AllOutput,
138  Command_ResetOutput,
139  Command_SetLed,
140  Command_AllLed,
141  Command_ResetLed,
142 
143  // Mode: Master set Slave mode
144  Mode_RemoteControl,
145  Mode_Spectator,
146  Mode_Sleep,
147 
148  // Config: Master config the slave
149  Config_TODO,
150  Config_AnythingLimit,
151 
152  // Too add new DataType here
153 
154  DataType_End
155 } HomeAut_DataType;
156 
157 
158 
160 typedef struct
161 {
162  const char name[7];
163  HomeAut_DataType type;
165 
166 
167 
169 typedef struct
170 {
171  uint8_t MyAddress;
172  uint8_t TargetAddress;
173  HomeAut_FunctionType Function;
174  HomeAut_DataType DataType;
175  uint32_t Data;
176  uint8_t isValid;
178 
179 
180 
181 /*------------------------------------------------------------------------------
182  * Global variables
183  *----------------------------------------------------------------------------*/
184 
185 extern const FunctionTypeParity FunctionTypeParity_List[]; // Function enum - "FUNCTION" string
186 
187 
188 extern const DataTypeParity DataTypeParity_List[]; // DataType enum - "DATATYPE" string
189 
190 
191 extern HomeAut_InformationType HOMEAUTMESSAGE_MessageInformation;
192 
193 
194 
195 /*------------------------------------------------------------------------------
196  * Global function declarations
197  *----------------------------------------------------------------------------*/
198 
199 void HOMEAUTMESSAGE_Test(void);
200 ReturnType HOMEAUTMESSAGE_CompareMessage(char *messageString);
201 ReturnType HOMEAUTMESSAGE_CreateMessage(HomeAut_MessageType *createToMessage, HomeAut_InformationType *messageInformation);
202 
203 ReturnType HOMEAUTMESSAGE_CreateAndSendHomeAutMessage
204  ( uint8_t myIp, uint8_t destIp, HomeAut_FunctionType function,
205  HomeAut_DataType dataType, uint32_t data, uint8_t isValid);
206 
207 
208 
209 
210 
211 #endif /* HOMEAUTMESSAGE_H_*/
HomeAut_DataType DataType
Data type.
Definition: homeautmessage.h:174
uint32_t Data
Data.
Definition: homeautmessage.h:175
Function name - string parity table.
Definition: homeautmessage.h:85
HomeAut message information type.
Definition: homeautmessage.h:169
HomeAut_DataType type
Data type.
Definition: homeautmessage.h:163
uint8_t TargetAddress
Target (receiver) address.
Definition: homeautmessage.h:172
uint8_t MyAddress
My (sender) address.
Definition: homeautmessage.h:171
uint8_t isValid
It is valid information?
Definition: homeautmessage.h:176
HomeAut message structure for message separation.
Definition: homeautmessage.h:27
HomeAut_FunctionType Function
Function.
Definition: homeautmessage.h:173
Data type - string table.
Definition: homeautmessage.h:160