MeshNet  1.0.0
meshConfig.h
Go to the documentation of this file.
1 
10 #ifndef INC_MESHCONFIG_H_
11 #define INC_MESHCONFIG_H_
12 
13 #ifndef SIMULATION
14  #include <wirish.h>
15  #include <Stream.h>
16  #define NO_ITOA_S
17  #define ITOA _itoa_s
18 #else
19  #include "Simulation.h"
20  #define ITOA _itoa_s
21 #endif
22 #include <HardwareCRC.h>
23 #include <ThreadLock.h>
24 
28 #define MESHNET_VERSION (MeshVersion(1,0,0))
29 
33 #define MESHNET_VERSION_txt "1.0.0"
34 
35 // Streams macros - BEGIN
36 #ifndef ISTREAM
37 #define ISTREAM Stream //Input debug stream
38 #endif
39 
40 #ifndef OSTREAM
41 #define OSTREAM Print //Output debug stream
42 #endif
43 // Streams macros - END
44 
45 // Addresses macros - BEGIN
50 #define BROADCAST_MESH_ADDRESS (255)
51 
56 #define INVALID_MESH_ADDRESS (254)
57 
62 #define UNKNOWN_MESH_ADDRESS (253)
63 
69 #define MESH_GATEWAY_MAX_ADDRESS (2)
70 
75 #define MAX_MESH_ADDRESS (250)
76 #define MAX_MESH_ADDRESS_txt "250" //Text form of MAX_MNODE_ADDRESS
77 
82 #define IS_VALID_MESH_ADDRESS(address) ((address) <= MAX_MESH_ADDRESS && (address) >= 0)
83 
88 #define IS_VALID_MESH_SRC_ADDRESS(address) (IS_VALID_MESH_ADDRESS(address) || (address) == UNKNOWN_MESH_ADDRESS)
89 
94 #define IS_VALID_MESH_DEST_ADDRESS(address) (IS_VALID_MESH_SRC_ADDRESS(address) || (address) == BROADCAST_MESH_ADDRESS)
95 
100 #define IS_VALID_MESH_FROM_ADDRESS(address) (IS_VALID_MESH_SRC_ADDRESS(address))
101 
106 #define IS_VALID_MESH_TO_ADDRESS(address) (IS_VALID_MESH_SRC_ADDRESS(address))
107 // Addresses macros - END
108 
109 
110 // Size macros - BEGIN
116 #define MESH_PACKET_PAYLOAD_SIZE_LIMIT (512)
117 #define MESH_PACKET_PAYLOAD_SIZE_LIMIT_txt "512"
118 
123 #define MESH_PING_PAYLOAD_SIZE_LIMIT (MESH_PACKET_PAYLOAD_SIZE_LIMIT-12)
124 #define MESH_PING_PAYLOAD_SIZE_LIMIT_txt "500"
125 
131 #define MESH_FRAME_SIZE_LIMIT (128)
132 
139 #define MESH_FRAME_SIZE_MIN_LIMIT (24)
140 // Size macros - END
141 
142 
143 // Buffers macros - BEGIN
144 #define DHCPTABLE_SIZE (MAX_MESH_ADDRESS+1) //Size of DHCP table has to be same as maximum address value + 1, because index of this table is node address
145 #define DHCPTABLE_SIZE_txt "251" //Size of DHCP table in text form. TODO this has to be evaluated each time DHCPTABLE_SIZE or MAX_MESH_ADDRESS is changed
146 #define DHCPTABLE_VALID_ROW_LIFETIME (86400000UL) //Time, until DHCPTable row is valid. After this time, it is invalid, but still reserved.
147 #define DHCPTABLE_ROW_RAW_LIFETIME_RESERVED (127) //If DHCP tables's row raw life time is under this value (raw lifetime can be from 0 to 255), record will be no longer valid.
148  //This settings helps to prevent assign address, which was unassigned a moment ago, to be assigned to another node,
149  //because some nodes in network may not know if this address was unassigned from node.
150 #define DHCPTABLE_ROW_LIFETIME (DHCPTABLE_VALID_ROW_LIFETIME + (DHCPTABLE_VALID_ROW_LIFETIME*(255ULL - DHCPTABLE_ROW_RAW_LIFETIME_RESERVED))/DHCPTABLE_ROW_RAW_LIFETIME_RESERVED) //MAX Lifetime of each row in RouteTable in milliseconds.
151 
152 #define ROUTETABLE_SIZE (64) //Maximum number of routes (including routes to neighbors and gateways)
153 #define ROUTETABLE_SIZE_txt "64" //Size of route table in text form.
154 #define ROUTETABLE_MAX_IND_txt "63" //Maximum index in route table
155 #define ROUTETABLE_ROW_LIFETIME (30UL * 60UL * 1000UL) //MAX Lifetime of each row in RouteTable in milliseconds.
156 
157 #define IDTABLE_SIZE (64) //Size of ID table.
158 #define IDTABLE_SIZE_txt "64" //Size of ID table in text form.
159 #define IDTABLE_MAX_IND_txt "63" //Maximum index in ID table
160 #define IDTABLE_ROW_LIFETIME (5UL * 60UL * 1000UL) //MAX Lifetime of each row in ID table in milliseconds.
161 
162 #define FIDTABLE_SIZE (8) //Size of FID table.
163 #define FIDTABLE_SIZE_txt "8" //Size of FID table in text form.
164 #define FIDTABLE_MAX_IND_txt "7" //Maximum index in FID table
165 #define FIDTABLE_ROW_LIFETIME (5UL * 60UL * 1000UL) //MAX Lifetime of each row in FID table in milliseconds.
166 
167 #define OIDTABLE_SIZE (64) //Size of output ID table.
168 #define OIDTABLE_SIZE_txt "64" //Size of output ID table in text form.
169 #define OIDTABLE_MAX_IND_txt "63" //Maximum index in OID table
170 #define OIDTABLE_ROW_LIFETIME (127500UL) //MAX Lifetime of each row in output ID table in milliseconds.
171 
172 #define MESH_OFIFO_HIGH_SIZE (3) //Size of output packet FIFO buffer with high priority.
173 #define MESH_OFIFO_LOW_SIZE (4) //Size of output packet FIFO buffer with low priority.
174 #define MESH_WFIFO_SIZE (8) //Size of waiting packet FIFO buffer.
175 
176 #ifdef SIMULATION
177 #define MESH_INST_ARRAY_SIZE instArrSize
178 #else
179 #define MESH_INST_ARRAY_SIZE (2) //Size of instance array. This array stores all created instances of current class. Number of created instances of MeshNet in this program cannot exceed this number.
180 #endif //SIMULATION
181 
182 // Buffers macros - END
183 
184 
185 // Timing macros - BEGIN
192 #define MESH_NEXT_FRAME_TIMEOUT (40)
193 
199 #define MESH_ROUTE_RETR_TIME (50)
200 
205 #define MESH_FRAME_SEND_DELAY (15)
206 
211 #define MESH_ACK_CTS_TIME (15000)
212 
217 #define MESH_FRAME_CTS_TIME (20000)
218 
225 #define MESH_RANDOM_ROUTED_CTS_TIME (5000)
226 
234 #define MESH_RANDOM_UNROUTED_CTS_TIME (10000)
235 
240 #define MESH_PATH_DISC_TIMEOUT (5000)
241 // Timing macros - END
242 
243 
244 
245 // Settings macros - BEGIN
250 #define MESH_HOP_RELAY_LIMIT (25)
251 
256 #define MESH_ROUTE_RETR_CNT (4)
257 
262 #define MESH_FLOOD_RETR_CNT (1)
263 
268 #define MESH_RSSI_THRESHOLD (-70)
269 
274 #define MESH_PROCESS_RECV_FRAMES_AT_ONCE_MAX_LIMIT (3)
275 
276 #if !defined(SIMULATION)
277 
281 #define MESH_IMPL_CONSOLE_ITEM (1)
282 #else
283 #define MESH_IMPL_CONSOLE_ITEM (0) //Disabled in simulation
284 #endif // !SIMULATION
285 
290 //#define MESH_NO_STATISTICS
291 
292 // Settings macros - END
293 
294 
295 // Connect settings macros - BEGIN
296 
301 #define MESH_SYS_NET_SCAN_TIMEOUT (1500)
302 
307 #define MESH_CONNECT_TIMEOUT (7500)
308 
313 #define MESH_DISCONNECT_TIMEOUT (5000)
314 
319 #define MESH_REQ_DISCONNECT_TIMEOUT (7500)
320 
325 #define MESH_CONNECT_REQ_TIMEOUT (MESH_CONNECT_TIMEOUT - MESH_SYS_NET_SCAN_TIMEOUT)
326 
327 // Connect setting macros - END
328 
329 #endif /* INC_MESHCONFIG_H_ */