Skip to content

Commit 3ebfc7b

Browse files
committed
Allow to add extra options to the default one
by adding a 'lwipopts_extra.h' Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 568478e commit 3ebfc7b

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The LwIP has several user defined options, which is specified from within the `l
2222

2323
This library provides a default user defined options file named `lwipopts_default.h`.
2424

25-
User can provide his own defined options at sketch level by adding his configuration in a file named `STM32lwipopts.h`.
25+
User can provide his own defined options at sketch level by adding his configuration in a file named `STM32lwipopts.h` or
26+
extend the default one by adding some extra configuration in a file named `lwipopts_extra.h`.
27+
2628

2729

2830
## New alternative init procedure **!!!**

src/lwipopts.h

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#if __has_include("STM32lwipopts.h")
1212
#include "STM32lwipopts.h"
1313
#else
14+
#if __has_include("lwipopts_extra.h")
15+
#include "lwipopts_extra.h"
16+
#endif
1417
#include "lwipopts_default.h"
1518
#endif
1619

src/lwipopts_default.h

+27-35
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,10 @@
99
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
1010
* All rights reserved.</center></h2>
1111
*
12-
* Redistribution and use in source and binary forms, with or without
13-
* modification, are permitted, provided that the following conditions are met:
14-
*
15-
* 1. Redistribution of source code must retain the above copyright notice,
16-
* this list of conditions and the following disclaimer.
17-
* 2. Redistributions in binary form must reproduce the above copyright notice,
18-
* this list of conditions and the following disclaimer in the documentation
19-
* and/or other materials provided with the distribution.
20-
* 3. Neither the name of STMicroelectronics nor the names of other
21-
* contributors to this software may be used to endorse or promote products
22-
* derived from this software without specific written permission.
23-
* 4. This software, including modifications and/or derivative works of this
24-
* software, must execute solely and exclusively on microcontroller or
25-
* microprocessor devices manufactured by or for STMicroelectronics.
26-
* 5. Redistribution and use of this software other than as permitted under
27-
* this license is void and will automatically terminate your rights under
28-
* this license.
29-
*
30-
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
31-
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
32-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
33-
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
34-
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
35-
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
38-
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41-
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12+
* This software component is licensed by ST under Ultimate Liberty license
13+
* SLA0044, the "License"; You may not use this file except in compliance with
14+
* the License. You may obtain a copy of the License at:
15+
* www.st.com/SLA0044
4216
*
4317
******************************************************************************
4418
*/
@@ -58,6 +32,8 @@
5832
*/
5933
#define SYS_LIGHTWEIGHT_PROT 0
6034

35+
#define LWIP_NOASSERT
36+
6137
/* ---------- Memory options ---------- */
6238
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
6339
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
@@ -100,9 +76,13 @@ a lot of data that needs to be copied, this should be set high. */
10076
/* ---------- TCP options ---------- */
10177
#define LWIP_TCP 1
10278
#define TCP_TTL 255
79+
#define LWIP_SO_RCVTIMEO 1
80+
#define LWIP_SO_RCVRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */
81+
#define LWIP_SO_SNDTIMEO 1
82+
#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 1 /* Pass an integer number of ms instead of a timeval struct. */
10383

10484
/* Controls if TCP should queue segments that arrive out of
105-
order. Define to 0 if your device is low on memory. */
85+
order. Define to 0 if your device is low on memory and you are not scared by TCP congestion and latencies. */
10686
#define TCP_QUEUE_OOSEQ 0
10787

10888
/* TCP Maximum segment size. */
@@ -117,19 +97,25 @@ a lot of data that needs to be copied, this should be set high. */
11797
#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS)
11898

11999
/* TCP receive window. */
120-
#define TCP_WND (2*TCP_MSS)
100+
#define TCP_WND (3*TCP_MSS)
101+
102+
#define LWIP_TCP_KEEPALIVE 1 /* Keep the TCP link active. Important for MQTT/TLS */
103+
#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 1 /* Prevent the same port to be used after reset.
104+
Otherwise, the remote host may be confused if the port was not explicitly closed before the reset. */
121105

122106

123107
/* ---------- ICMP options ---------- */
124108
#define LWIP_ICMP 1
109+
#define LWIP_RAW 1 /* PING changed to 1 */
110+
#define DEFAULT_RAW_RECVMBOX_SIZE 3 /* for ICMP PING */
125111

126112

127113
/* ---------- DHCP options ---------- */
114+
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
115+
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
116+
turning this on does currently not work. */
128117
#define LWIP_DHCP 1
129118

130-
/* ---------- DNS options ---------- */
131-
#define LWIP_DNS 1
132-
133119

134120
/* ---------- UDP options ---------- */
135121
#define LWIP_UDP 1
@@ -138,12 +124,17 @@ a lot of data that needs to be copied, this should be set high. */
138124

139125
/* ---------- Statistics options ---------- */
140126
#define LWIP_STATS 0
127+
#define LWIP_PROVIDE_ERRNO
141128

142129
/* ---------- link callback options ---------- */
143130
/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
144131
* whenever the link changes (i.e., link down)
145132
*/
133+
// need for building net_ip.c
134+
#define LWIP_NETIF_HOSTNAME 1
135+
#define LWIP_NETIF_STATUS_CALLBACK 1
146136
#define LWIP_NETIF_LINK_CALLBACK 1
137+
#define LWIP_DHCP_CHECK_LINK_UP 1
147138

148139
/*
149140
--------------------------------------
@@ -211,6 +202,7 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
211202
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
212203
*/
213204
#define LWIP_SOCKET 0
205+
#define LWIP_DNS 1
214206

215207
/*
216208
------------------------------------

0 commit comments

Comments
 (0)