RF24Ethernet - TCP/IP over RF24Network  1.6b
TMRh20 - Pushing the practical limits of RF24 modules
uip-conf.h
1 /** @file uip-conf.h*/
2 /**
3  * \name User configuration options
4  * @{
5  *
6  * uIP has a number of configuration options that can be overridden
7  * for each project. These are kept in a project-specific uip-conf.h
8  * file and all configuration names have the prefix UIP_CONF.
9  * Some of these options are specific to RF24Ethernet.
10  */
11 
12 /*
13  * Copyright (c) 2006, Swedish Institute of Computer Science.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution.
24  * 3. Neither the name of the Institute nor the names of its contributors
25  * may be used to endorse or promote products derived from this software
26  * without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  *
40  * This file is part of the uIP TCP/IP stack
41  * Modified 2015: TMRh20
42  */
43 
44 #ifndef __UIP_CONF_H__
45 #define __UIP_CONF_H__
46 
47 #include <inttypes.h>
48 
49 #include "RF24Network_config.h"
50 /************* TMRh20: User Configuration *******************/
51 /**
52 @defgroup UipConfiguration
53 
54 User Configuration Options
55 /* @{ */
56 
57 /** Maximum number of TCP connections. */
58 #define UIP_CONF_MAX_CONNECTIONS 1
59 
60 /** Maximum number of listening TCP ports. */
61 #define UIP_CONF_MAX_LISTENPORTS 1
62 
63 /**
64  * uIP buffer size.
65  * @note For simplicity, this is automatically set to the MAX_PAYLOAD_SIZE configured in the RF24Network_conf.h file, but can be configured independently
66  * of RF24Network if desired.
67  *
68  * Notes:
69  * 1. Nodes can use different buffer sizes, direct TCP communication is limited to the smallest
70  * ie: A RPi can be configured to use 1500byte TCP windows, with Arduino nodes using only 120byte TCP windows.
71  * 2. Routing nodes handle traffic at the link-layer, so the MAX_PAYLOAD_SIZE is not important, unless they are
72  * running RF24Ethernet.
73  * 3. Nodes running RF24Ethernet generally do not need to support RF24Network user payloads. Edit RF24Network_config.h
74  * and uncomment #define DISABLE_USER_PAYLOADS. This will free memory not used with RF24Ethernet.
75  * 4. The user buffers are automatically configured to (Buffer Size - Link Layer Header Size - TCP Header Size) so
76  * using RF24Mesh will decrease payloads by 14 bytes.
77  * 5. Larger buffer sizes increase throughput for individual nodes, but can impact other network traffic.
78  * 6. Max usable value is 512
79  */
80 
81 #define UIP_CONF_BUFFER_SIZE MAX_PAYLOAD_SIZE
82 /**
83  * <b>Optional:</b> Uncomment to disable
84  *
85  * Adjust the length of time after which an open connection will be timed out.
86  *
87  * If uIP is polling the established connection, but an ack or data is not received for this duration in ms, kill the connection.
88  */
89 #define UIP_CONNECTION_TIMEOUT 30000
90 
91 /**
92  * SLIP/TUN - 14 for Ethernet/TAP & 0 for TUN/SLIP
93  *
94  * Ethernet headers add an additional 14 bytes to each payload.
95  *
96  * RF24Mesh generally needs to be used if setting this to 0 and using a TUN or SLIP interface
97  */
98 #define UIP_CONF_LLH_LEN 0
99 
100 /**
101  * UDP support on or off (required for DNS)
102  * @note DNS support typically requires larger payload sizes (250-300). It seems that DNS servers will typically respond
103  * with a single address if requesting an address of www.google.com vs google.com, and this will work with the default payload size
104  */
105 
106 #define UIP_CONF_UDP 0
107 //#define UIP_CONF_BROADCAST 0
108 //#define UIP_CONF_UDP_CONNS 1
109 
110  /***@}*/
111  /**
112  * @name Advanced Operation
113  *
114  * For advanced configuration of RF24Ethernet
115  */
116  /***@{*/
117 
118  /**
119  *
120  * Adjust the rate at which the IP stack performs periodic processing.
121  * The periodic timer will be called at a rate of 1 second divided by this value
122  *
123  * Increase this value to reduce response times and increase throughput during user interactions.
124  * @note: Increasing this value will increase throughput for individual nodes, but can impact other network traffic.
125  */
126 #define UIP_TIMER_DIVISOR 16
127 
128 /**
129  * If operating solely as a server, disable the ability to open TCP connections as a client by setting to 0
130  * Saves memory and program space.
131  */
132 
133 #define UIP_CONF_ACTIVE_OPEN 1
134 
135 /**
136  * UDP checksums on or off
137  */
138 #define UIP_CONF_UDP_CHECKSUMS 0
139 
140 /**
141 * uIP User Output buffer size
142 *
143 * The output buffer size determines the max
144 * length of strings that can be sent by the user, and depends on the uip buffer size
145 *
146 * Must be <= UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN
147 * @note Must be an odd number or the TCP/IP sequence gets out of order with payloads larger than 511 bytes
148 * I think this might be a bug or missing feature of the uip stack
149 */
150 #define UIP_CONF_EXTERNAL_BUFFER
151 
152 #if UIP_CONF_BUFFER_SIZE >= 512
153  #define OUTPUT_BUFFER_SIZE 511
154 #else
155  #define OUTPUT_BUFFER_SIZE UIP_CONF_BUFFER_SIZE - 1 - UIP_CONF_LLH_LEN - UIP_TCPIP_HLEN
156 #endif
157 
158  /**
159  * <b>Optional:</b> Used with UIP_CONNECTION_TIMEOUT
160  *
161  * If an open connection is not receiving data, the connection will be restarted.
162  *
163  * Adjust the initial delay period before restarting a connection that has already been restarted
164  *
165  * For small payloads (96-120 bytes) with a fast connection, this value can be as low as ~750ms or so.
166  * When increasing the uip buffer size, this value should be increased, or
167  * the window may be reopened while the requested data is still being received, hindering traffic flow.
168  */
169 #define UIP_WINDOW_REOPEN_DELAY 5150
170 
171 /* @} */
172 /** @} */
173 /******************** END USER CONFIG ***********************************/
174 
175 /********** TMRh20: This option is not yet valid **********/
176 /* for TCP */
177 #define UIP_SOCKET_NUMPACKETS 1
178 
179 /**
180  * The TCP receive window.
181  *
182  * This is should not be to set to more than
183  * UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
184  * @note Must be an odd number or the TCP/IP sequence gets out of order with payloads larger than 511 bytes
185  * I think this might be a bug or missing feature of the uip stack
186  */
187 
188 #if UIP_CONF_BUFFER_SIZE >= 512
189  #define UIP_CONF_RECEIVE_WINDOW 511
190 #else
191  //#define UIP_CONF_RECEIVE_WINDOW UIP_CONF_BUFFER_SIZE *2 - UIP_CONF_LLH_LEN - UIP_TCPIP_HLEN //This is set automatically to the max allowable size
192  #define UIP_CONF_RECEIVE_WINDOW UIP_CONF_BUFFER_SIZE * 2 - 1 - UIP_CONF_LLH_LEN - UIP_TCPIP_HLEN //This is set automatically to the max allowable size
193 #endif
194 
195 #define UIP_CONF_TCP_MSS UIP_CONF_RECEIVE_WINDOW
196 
197  /**
198  * CPU byte order.
199  *
200  * \hideinitializer
201  */
202 #define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
203 
204 /**
205  * Logging on or off
206  *
207  * \hideinitializer
208  */
209 //#define UIP_CONF_LOGGING 1
210 #define UIP_CONF_LOGGING 0
211 
212 /**
213  * uIP statistics on or off
214  *
215  * \hideinitializer
216  */
217 #define UIP_CONF_STATISTICS 0
218 
219 // Define config for TAP or TUN based on Link-layer header length
220 #if UIP_CONF_LLH_LEN > 0
221  #define RF24_TAP
222 #endif
223 
224 #if defined UIP_TIMER_DIVISOR
225  #if UIP_TIMER_DIVISOR > 5
226  #define UIP_CONF_RTO (UIP_TIMER_DIVISOR/2)
227  #else
228  #define UIP_CONF_RTO 3
229  #endif
230 #endif
231 
232 
233 /**
234  * 8 bit datatype
235  *
236  * This typedef defines the 8-bit type used throughout uIP.
237  *
238  * \hideinitializer
239  */
240 typedef uint8_t u8_t;
241 
242 /**
243  * 16 bit datatype
244  *
245  * This typedef defines the 16-bit type used throughout uIP.
246  *
247  * \hideinitializer
248  */
249 typedef uint16_t u16_t;
250 
251 /**
252  * Statistics datatype
253  *
254  * This typedef defines the dataype used for keeping statistics in
255  * uIP.
256  *
257  * \hideinitializer
258  */
259 typedef unsigned short uip_stats_t;
260 
261 /** \hideinitializer */
262 typedef void* uip_tcp_appstate_t;
263 
264 /** \hideinitializer */
265 void serialip_appcall(void);
266 /** \hideinitializer */
267 #define UIP_APPCALL serialip_appcall
268 
269 /** \hideinitializer */
270 typedef void* uip_udp_appstate_t;
271 
272 /** \hideinitializer */
273 void uipudp_appcall(void);
274 
275 /** \hideinitializer */
276 #define UIP_UDP_APPCALL uipudp_appcall
277 
278 #if UIP_CONF_LOGGING > 0
279 void uip_log(char* msg);
280 #endif
281 
282 #endif /* __UIP_CONF_H__ */
283 
284 
friend void uip_log(char *msg)
Definition: RF24Client.cpp:189
friend void serialip_appcall(void)
Definition: RF24Client.cpp:197