Skip to content

Commit 0db6ec4

Browse files
d-a-vdevyte
authored andcommitted
lwip2: 3 sntp servers, autoip (169.254), esp-ping, espconn (#5444)
* lwip2: better handling of ipv4_addr/t type + 3 sntp servers * bump lwip2 version * Only with FEATURES=1: 3 sntp servers and AutoIP enabled (169.254 when dhcp server fails) * Only with FEATURES=1: 3 sntp servers and AutoIP enabled (169.254 when dhcp server fails) * local CI runner: select build type * new ipv4_addr/t definition makes things easier for IPAddress * update local CI runner * lwip2 changes * lwip2: port esp-ping and espconn
1 parent 6d42a26 commit 0db6ec4

16 files changed

+115
-43
lines changed

cores/esp8266/IPAddress.h

-5
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ class IPAddress: public Printable {
152152
IPAddress(const ipv4_addr* fw_addr) { setV4(); v4() = fw_addr->addr; }
153153
IPAddress(const ip_addr_t& lwip_addr) { _ip = lwip_addr; }
154154

155-
#if LWIP_VERSION_MAJOR != 1
156-
IPAddress(ipv4_addr fw_addr) { setV4(); v4() = fw_addr.addr; }
157-
IPAddress(const ip_addr_t* lwip_addr) { _ip = *lwip_addr; }
158-
#endif
159-
160155
operator ip_addr_t () const { return _ip; }
161156
operator const ip_addr_t*() const { return &_ip; }
162157
operator ip_addr_t*() { return &_ip; }

tests/run_CI_locally.sh

+34-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,37 @@ if [ "$branch" != "$branch" ]; then
4747
exit 1
4848
fi
4949
rm -rf arduino_ide arduino-nightly Arduino/libraries/ArduinoJson
50-
HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=build tests/common.sh
50+
51+
while true; do
52+
53+
cat << EOF
54+
Which build?
55+
1. main
56+
2. debug even
57+
3. debug odd
58+
4. platformio
59+
5. package
60+
6. host
61+
7. style
62+
EOF
63+
64+
read ans
65+
66+
BUILD_TYPE=""
67+
case "$ans" in
68+
1) BUILD_TYPE=build;;
69+
2) BUILD_TYPE=debug_even;;
70+
3) BUILD_TYPE=debug_odd;;
71+
4) BUILD_TYPE=platformio;;
72+
5) BUILD_TYPE=package;;
73+
6) BUILD_TYPE=host;;
74+
7) BUILD_TYPE=style;;
75+
esac
76+
test -z "$BUILD_TYPE" || break
77+
done
78+
79+
# use pip2 for python2 with python3 is around, platformio doesn't like it
80+
cp tests/common.sh tests/common-custom.sh
81+
sed -i 's,pip ,pip2 ,g' tests/common-custom.sh
82+
83+
HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=$BUILD_TYPE tests/common-custom.sh

tools/sdk/include/ip_addr.h

+1-12
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,12 @@
2626
#define __IP_ADDR_H__
2727

2828
#include "c_types.h"
29+
#include "ipv4_addr.h"
2930

3031
#ifdef __cplusplus
3132
extern "C" {
3233
#endif
3334

34-
struct ipv4_addr {
35-
uint32 addr;
36-
};
37-
38-
typedef struct ipv4_addr ipv4_addr_t;
39-
40-
struct ip_info {
41-
struct ipv4_addr ip;
42-
struct ipv4_addr netmask;
43-
struct ipv4_addr gw;
44-
};
45-
4635
/**
4736
* Determine if two address are on the same network.
4837
*

tools/sdk/include/ipv4_addr.h

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* ESPRESSIF MIT License
3+
*
4+
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5+
*
6+
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
7+
* it is free of charge, to any person obtaining a copy of this software and associated
8+
* documentation files (the "Software"), to deal in the Software without restriction, including
9+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11+
* to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or
14+
* substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
25+
#ifndef __IPV4_ADDR_H__
26+
#define __IPV4_ADDR_H__
27+
28+
#include <stdint.h>
29+
#include <lwip/init.h>
30+
31+
// ipv4_addr is necessary for lwIP-v2 because
32+
// - espressif binary firmware is IPv4 only, under the name of ip_addr/_t
33+
// - ip_addr/_t is different when IPv6 is enabled with lwIP-v2
34+
// hence ipv4_addr/t is IPv4 version/copy of IPv4 ip_addr/_t
35+
// when IPv6 is enabled so we can deal with IPv4 use from firmware API.
36+
37+
// official lwIP's definitions (1.4 or 2)
38+
#include "lwip/ip_addr.h"
39+
40+
///////////////////////////////////////////////
41+
#if LWIP_VERSION_MAJOR == 1
42+
43+
#define ipv4_addr ip_addr
44+
45+
///////////////////////////////////////////////
46+
#else // lwIP-v2
47+
48+
#define ipv4_addr ip4_addr
49+
#define ipv4_addr_t ip4_addr_t
50+
51+
// defined in lwip-v1.4 sources only, used in fw
52+
struct ip_info {
53+
struct ipv4_addr ip;
54+
struct ipv4_addr netmask;
55+
struct ipv4_addr gw;
56+
};
57+
58+
///////////////////////////////////////////////
59+
#endif // lwIP-v2
60+
61+
#endif // __IPV4_ADDR_H__

tools/sdk/include/user_interface.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@
2828
#include "os_type.h"
2929
#ifdef LWIP_OPEN_SRC
3030

31-
#include "lwip/init.h"
32-
#if LWIP_VERSION_MAJOR == 1
33-
#define ipv4_addr ip_addr
34-
#endif
35-
#include "lwip/ip_addr.h"
36-
#if LWIP_VERSION_MAJOR != 1
37-
typedef struct ip4_addr ipv4_addr_t;
38-
#endif
31+
#include "ipv4_addr.h"
3932

4033
#else
4134
#error LWIP_OPEN_SRC must be defined

tools/sdk/lib/liblwip2-1460-feat.a

322 KB
Binary file not shown.

tools/sdk/lib/liblwip2-1460.a

291 KB
Binary file not shown.

tools/sdk/lib/liblwip2-536-feat.a

322 KB
Binary file not shown.

tools/sdk/lib/liblwip2-536.a

291 KB
Binary file not shown.

tools/sdk/lib/liblwip6-1460-feat.a

328 KB
Binary file not shown.

tools/sdk/lib/liblwip6-536-feat.a

328 KB
Binary file not shown.

tools/sdk/lwip2/include/arch/cc.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,7 @@ typedef uint32_t sys_prot_t; // not really used
9090
ip4_addr3_16(ipaddr), \
9191
ip4_addr4_16(ipaddr)
9292

93-
// ipv4_addr / ip_info: do not exist in lwip2 (only in lwip1.4)
94-
struct ipv4_addr {
95-
uint32_t addr;
96-
};
97-
struct ip_info {
98-
struct ipv4_addr ip;
99-
struct ipv4_addr netmask;
100-
struct ipv4_addr gw;
101-
};
93+
#include <ipv4_addr.h>
10294

10395
///////////////////////////////
10496
//// PROVIDED TO USER

tools/sdk/lwip2/include/gluedebug.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern "C"
3939
void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
4040

4141
/////////////////////////////////////////////////////////////////////////////
42+
#include <sys/pgmspace.h>
4243

4344
#if UDEBUG && UDEBUGSTORE
4445
#warning use 'doprint_allow=1' right after Serial is enabled
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// generated by makefiles/make-lwip2-hash
22
#ifndef LWIP_HASH_H
33
#define LWIP_HASH_H
4-
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.0"
4+
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.0-4-gc434c6f"
55
#endif // LWIP_HASH_H

tools/sdk/lwip2/include/lwipopts.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -987,20 +987,20 @@
987987
* LWIP_AUTOIP==1: Enable AUTOIP module.
988988
*/
989989
#if !defined LWIP_AUTOIP || defined __DOXYGEN__
990-
#define LWIP_AUTOIP 0
990+
#define LWIP_AUTOIP LWIP_FEATURES // 0
991991
#endif
992992
#if !LWIP_IPV4
993993
/* disable AUTOIP when IPv4 is disabled */
994994
#undef LWIP_AUTOIP
995-
#define LWIP_AUTOIP 0
995+
#define LWIP_AUTOIP 0
996996
#endif /* !LWIP_IPV4 */
997997

998998
/**
999999
* LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
10001000
* the same interface at the same time.
10011001
*/
10021002
#if !defined LWIP_DHCP_AUTOIP_COOP || defined __DOXYGEN__
1003-
#define LWIP_DHCP_AUTOIP_COOP 0
1003+
#define LWIP_DHCP_AUTOIP_COOP LWIP_FEATURES // 0
10041004
#endif
10051005

10061006
/**
@@ -3539,14 +3539,22 @@
35393539
------------------ SNTP options ------------------
35403540
--------------------------------------------------
35413541
*/
3542-
#define SNTP_SERVER_DNS 1 // SNTP support DNS names through sntp_setservername / sntp_getservername
3542+
35433543
// if SNTP_SERVER_ADDRESS is defined, it always overrides user's config
35443544
// so we do not define it. sntp server can come from dhcp server, or by
35453545
// user.
3546-
//#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default
3547-
#define SNTP_GET_SERVERS_FROM_DHCP 3
3546+
//#define SNTP_SERVER_ADDRESS "pool.ntp.org" // default
3547+
//#define SNTP_GET_SERVERS_FROM_DHCP // implicitely enabled by LWIP_DHCP_GET_NTP_SRV
3548+
3549+
#define SNTP_SERVER_DNS 1 // enable SNTP support DNS names through sntp_setservername / sntp_getservername
3550+
35483551
#define SNTP_SET_SYSTEM_TIME_US(t,us) do { struct timeval tv = { t, us }; settimeofday(&tv, NULL); } while (0)
35493552

3553+
#if LWIP_FEATURES
3554+
// lwip-1.4 had 3 possible SNTP servers (constant was harcoded)
3555+
#define SNTP_MAX_SERVERS 3
3556+
#endif
3557+
35503558
/*
35513559
--------------------------------------------------
35523560
------------------- LOCAL FIXES ------------------

0 commit comments

Comments
 (0)