Skip to content

Commit d215b66

Browse files
Merge branch 'master' into SDFS
2 parents c8acb84 + 3f8cd46 commit d215b66

24 files changed

+146
-44
lines changed

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ jobs:
6565
env:
6666
- BUILD_PARITY=odd
6767

68+
- name: "Build lwIP-v1.4 (1)"
69+
stage: build
70+
script: $TRAVIS_BUILD_DIR/tests/build1.sh
71+
env:
72+
- BUILD_PARITY=even
73+
- name: "Build lwIP-v1.4 (2)"
74+
stage: build
75+
script: $TRAVIS_BUILD_DIR/tests/build1.sh
76+
env:
77+
- BUILD_PARITY=odd
78+
6879
- name: "Host tests"
6980
stage: build
7081
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh

cores/esp8266/IPAddress.h

+20-5
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@
3535
#define IP_IS_V4_VAL(x) (1)
3636
#define IP_SET_TYPE_VAL(x,y) do { (void)0; } while (0)
3737
#define IP_ANY_TYPE (&ip_addr_any)
38+
#define IP4_ADDR_ANY IPADDR_ANY
3839
#define IP4_ADDR_ANY4 IPADDR_ANY
3940
#define IPADDR4_INIT(x) { x }
4041
#define CONST /* nothing: lwIP-v1 does not use const */
42+
#define ip4_addr_netcmp ip_addr_netcmp
43+
#define netif_dhcp_data(netif) ((netif)->dhcp)
4144
#else // lwIP-v2+
4245
#define CONST const
4346
#if !LWIP_IPV6
@@ -84,13 +87,15 @@ class IPAddress: public Printable {
8487

8588
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
8689
// to a four-byte uint8_t array is expected
87-
operator uint32_t() const {
88-
return isV4()? v4(): (uint32_t)0;
89-
}
90+
operator uint32_t() const { return isV4()? v4(): (uint32_t)0; }
91+
operator uint32_t() { return isV4()? v4(): (uint32_t)0; }
92+
operator u32_t() const { return isV4()? v4(): (u32_t)0; }
93+
operator u32_t() { return isV4()? v4(): (u32_t)0; }
9094

91-
// the above uint32_t() cast can be ambiguous
92-
// if gcc complains, use instead isSet() or v4() according to what's relevant
9395
bool isSet () const;
96+
operator bool () const { return isSet(); } // <-
97+
operator bool () { return isSet(); } // <- both are needed
98+
9499
// generic IPv4 wrapper to uint32-view like arduino loves to see it
95100
const u32_t& v4() const { return ip_2_ip4(&_ip)->addr; } // for raw_address(const)
96101
u32_t& v4() { return ip_2_ip4(&_ip)->addr; }
@@ -115,6 +120,10 @@ class IPAddress: public Printable {
115120
}
116121
bool operator==(const uint8_t* addr) const;
117122

123+
int operator>>(int n) const {
124+
return isV4()? v4() >> n: 0;
125+
}
126+
118127
// Overloaded index operator to allow getting and setting individual octets of the address
119128
uint8_t operator[](int index) const {
120129
return isV4()? *(raw_address() + index): 0;
@@ -152,6 +161,9 @@ class IPAddress: public Printable {
152161
IPAddress(const ipv4_addr& fw_addr) { setV4(); v4() = fw_addr.addr; }
153162
IPAddress(const ipv4_addr* fw_addr) { setV4(); v4() = fw_addr->addr; }
154163

164+
IPAddress& operator=(const ipv4_addr& fw_addr) { setV4(); v4() = fw_addr.addr; return *this; }
165+
IPAddress& operator=(const ipv4_addr* fw_addr) { setV4(); v4() = fw_addr->addr; return *this; }
166+
155167
operator ip_addr_t () const { return _ip; }
156168
operator const ip_addr_t*() const { return &_ip; }
157169
operator ip_addr_t*() { return &_ip; }
@@ -166,6 +178,9 @@ class IPAddress: public Printable {
166178
IPAddress(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); }
167179
IPAddress(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); }
168180

181+
IPAddress& operator=(const ip_addr_t& lwip_addr) { ip_addr_copy(_ip, lwip_addr); return *this; }
182+
IPAddress& operator=(const ip_addr_t* lwip_addr) { ip_addr_copy(_ip, *lwip_addr); return *this; }
183+
169184
uint16_t* raw6()
170185
{
171186
setV6();

libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
182182
size_t len = pb->len;
183183
#if LWIP_VERSION_MAJOR == 1
184184
// check UdpContext.h
185-
const ip_addr_t* saddr = &current_iphdr_src;
185+
ip_addr_t* saddr = &current_iphdr_src;
186186
#else
187187
// check UdpContext.h
188188
const ip_addr_t* saddr = &ip_data.current_iphdr_src;

libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2+
#include <lwip/init.h>
3+
4+
#if LWIP_VERSION_MAJOR == 1
5+
6+
void setup() {
7+
Serial.begin(115200);
8+
Serial.println("wifi_softap_add_dhcps_lease() is not implemented with lwIP-v1");
9+
}
10+
11+
void loop() {
12+
}
13+
14+
#else
15+
116
/* Create a WiFi access point and provide static lease */
217

318
#include <ESP8266WiFi.h>
@@ -19,9 +34,7 @@ void handleRoot() {
1934
char wifiClientMac[18];
2035
unsigned char number_client;
2136
struct station_info *stat_info;
22-
struct ip4_addr *IPaddress;
2337

24-
IPAddress address;
2538
int i = 1;
2639

2740
number_client = wifi_softap_get_station_num();
@@ -31,13 +44,11 @@ void handleRoot() {
3144
result += String(number_client);
3245
result += "</h1></br>";
3346
while (stat_info != NULL) {
34-
IPaddress = &stat_info->ip;
35-
address = IPaddress->addr;
3647

3748
result += "Client ";
3849
result += String(i);
3950
result += " = ";
40-
result += String(address.toString());
51+
result += IPAddress(stat_info->ip).toString();
4152
result += " - ";
4253
sprintf(wifiClientMac, "%02X:%02X:%02X:%02X:%02X:%02X", MAC2STR(stat_info->bssid));
4354
result += wifiClientMac;
@@ -93,3 +104,5 @@ void setup() {
93104
void loop() {
94105
server.handleClient();
95106
}
107+
108+
#endif // lwIP-v2

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) {
534534
for (netif* intf = netif_list; intf; intf = intf->next) {
535535

536536
// unconditionally update all known interfaces
537+
#if LWIP_VERSION_MAJOR == 1
538+
intf->hostname = (char*)wifi_station_get_hostname();
539+
#else
537540
intf->hostname = wifi_station_get_hostname();
541+
#endif
538542

539543
if (netif_dhcp_data(intf) != nullptr) {
540544
// renew already started DHCP leases

libraries/ESP8266WiFi/src/WiFiServerSecureBearSSL.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,30 @@ void WiFiServerSecure::setECCert(const X509List *chain, unsigned cert_issuer_key
7676
// Return a client if there's an available connection waiting. If one is returned,
7777
// then any validation (i.e. client cert checking) will have succeeded.
7878
WiFiClientSecure WiFiServerSecure::available(uint8_t* status) {
79+
WiFiClientSecure client;
80+
7981
(void) status; // Unused
8082
if (_unclaimed) {
8183
if (_sk && _sk->isRSA()) {
8284
WiFiClientSecure result(_unclaimed, _chain, _sk, _iobuf_in_size, _iobuf_out_size, _client_CA_ta);
8385
_unclaimed = _unclaimed->next();
8486
result.setNoDelay(_noDelay);
8587
DEBUGV("WS:av\r\n");
86-
return result;
88+
client = result;
8789
} else if (_sk && _sk->isEC()) {
8890
WiFiClientSecure result(_unclaimed, _chain, _cert_issuer_key_type, _sk, _iobuf_in_size, _iobuf_out_size, _client_CA_ta);
8991
_unclaimed = _unclaimed->next();
9092
result.setNoDelay(_noDelay);
9193
DEBUGV("WS:av\r\n");
92-
return result;
94+
client = result;
9395
} else {
9496
// No key was defined, so we can't actually accept and attempt accept() and SSL handshake.
9597
DEBUGV("WS:nokey\r\n");
9698
}
99+
} else {
100+
optimistic_yield(1000);
97101
}
98-
99-
// Something weird, return a no-op object
100-
optimistic_yield(1000);
101-
return WiFiClientSecure();
102+
return client;
102103
}
103104

104105

libraries/ESP8266mDNS/src/LEAmDNS.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
*
2323
*/
2424

25+
#include <Schedule.h>
26+
2527
#include "LEAmDNS_Priv.h"
2628

29+
2730
namespace esp8266 {
2831

2932
/*
@@ -87,28 +90,30 @@ MDNSResponder::~MDNSResponder(void) {
8790
*/
8891
bool MDNSResponder::begin(const char* p_pcHostname) {
8992

90-
bool bResult = (0 != m_pcHostname);
93+
bool bResult = false;
9194

92-
if (0 == m_pcHostname) {
95+
if (0 == m_pUDPContext) {
9396
if (_setHostname(p_pcHostname)) {
9497

9598
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& pEvent) {
9699
(void) pEvent;
97-
_restart();
100+
// Ensure that _restart() runs in USER context
101+
schedule_function(std::bind(&MDNSResponder::_restart, this));
98102
});
99103

100104
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& pEvent) {
101105
(void) pEvent;
102-
_restart();
106+
// Ensure that _restart() runs in USER context
107+
schedule_function(std::bind(&MDNSResponder::_restart, this));
103108
});
104109

105110
bResult = _restart();
106111
}
112+
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
107113
}
108114
else {
109-
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls (Ignored host domain: '%s')!\n"), (p_pcHostname ?: "-")););
115+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls to begin (Ignored host domain: '%s')!\n"), (p_pcHostname ?: "-")););
110116
}
111-
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
112117
return bResult;
113118
}
114119

libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// cherry pick from lwip1 dns.c/mdns.c source files:
3434
#define DNS_MQUERY_PORT 5353
35-
#define DNS_MQUERY_IPV4_GROUP_INIT ipaddr_addr("224.0.0.251") /* resolver1.opendns.com */
35+
#define DNS_MQUERY_IPV4_GROUP_INIT IPAddress(224,0,0,251) /* resolver1.opendns.com */
3636
#define DNS_RRCLASS_ANY 255 /* any class */
3737

3838
#else // lwIP > 1

tests/build1.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir=$(mktemp -d)
4+
5+
source "$TRAVIS_BUILD_DIR"/tests/common.sh
6+
7+
if [ -z "$BUILD_PARITY" ]; then
8+
mod=1
9+
rem=0
10+
elif [ "$BUILD_PARITY" = "even" ]; then
11+
mod=2
12+
rem=0
13+
elif [ "$BUILD_PARITY" = "odd" ]; then
14+
mod=2
15+
rem=1
16+
fi
17+
18+
install_arduino nodebug
19+
build_sketches_with_arduino "$mod" "$rem" hb1
20+
21+
rm -rf "$cache_dir"
22+

tests/host/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ MOCK_CPP_FILES_COMMON := $(addprefix common/,\
8787
WMath.cpp \
8888
MockSerial.cpp \
8989
MockTools.cpp \
90+
MocklwIP.cpp \
9091
)
9192

9293
MOCK_CPP_FILES := $(MOCK_CPP_FILES_COMMON) $(addprefix common/,\

tests/host/common/MocklwIP.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#include <lwip/netif.h>
3+
4+
extern "C"
5+
{
6+
7+
netif* netif_list = nullptr;
8+
9+
err_t dhcp_renew(struct netif *netif)
10+
{
11+
(void)netif;
12+
return ERR_OK;
13+
}
14+
15+
} // extern "C"

tests/host/common/user_interface.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ bool wifi_station_get_config_default (struct station_config *config)
280280
}
281281

282282
char wifi_station_get_hostname_str [128];
283-
char* wifi_station_get_hostname (void)
283+
const char* wifi_station_get_hostname (void)
284284
{
285285
return strcpy(wifi_station_get_hostname_str, "esposix");
286286
}
@@ -312,7 +312,7 @@ bool wifi_station_set_config_current (struct station_config *config)
312312
return true;
313313
}
314314

315-
bool wifi_station_set_hostname (char *name)
315+
bool wifi_station_set_hostname (const char *name)
316316
{
317317
(void)name;
318318
return true;

tests/run_CI_locally.sh

+21-12
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ while true; do
5454
Which build?
5555
1. main
5656
2. main + IPv6
57-
3. debug even
58-
4. debug odd
59-
5. platformio
60-
6. package
61-
7. host
62-
8. style
57+
3. main with lwIP-v1.4
58+
4. debug even
59+
5. debug odd
60+
6. platformio
61+
7. package
62+
8. host
63+
9. style
6364
EOF
6465

6566
read ans
@@ -68,12 +69,13 @@ EOF
6869
case "$ans" in
6970
1) BUILD_TYPE=build;;
7071
2) BUILD_TYPE=build6;;
71-
3) BUILD_TYPE=debug_even;;
72-
4) BUILD_TYPE=debug_odd;;
73-
5) BUILD_TYPE=platformio;;
74-
6) BUILD_TYPE=package;;
75-
7) BUILD_TYPE=host;;
76-
8) BUILD_TYPE=style;;
72+
3) BUILD_TYPE=build1;;
73+
4) BUILD_TYPE=debug_even;;
74+
5) BUILD_TYPE=debug_odd;;
75+
6) BUILD_TYPE=platformio;;
76+
7) BUILD_TYPE=package;;
77+
8) BUILD_TYPE=host;;
78+
9) BUILD_TYPE=style;;
7779
esac
7880
test -z "$BUILD_TYPE" || break
7981
done
@@ -105,6 +107,13 @@ elif [ "$BUILD_TYPE" = "build6_even" ]; then
105107
elif [ "$BUILD_TYPE" = "build6_odd" ]; then
106108
BUILD_PARITY=odd tests/build6.sh
107109

110+
elif [ "$BUILD_TYPE" = "build1" ]; then
111+
tests/build1.sh
112+
elif [ "$BUILD_TYPE" = "build1_even" ]; then
113+
BUILD_PARITY=even tests/build1.sh
114+
elif [ "$BUILD_TYPE" = "build1_odd" ]; then
115+
BUILD_PARITY=odd tests/build1.sh
116+
108117
elif [ "$BUILD_TYPE" = "platformio" ]; then
109118
tests/platformio-custom.sh
110119
elif [ "$BUILD_TYPE" = "platformio_even" ]; then

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

2.39 KB
Binary file not shown.

tools/sdk/lib/liblwip2-1460.a

1.86 KB
Binary file not shown.

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

2.39 KB
Binary file not shown.

tools/sdk/lib/liblwip2-536.a

1.86 KB
Binary file not shown.

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

4.79 KB
Binary file not shown.

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

4.79 KB
Binary file not shown.
+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-11-g87c709d"
4+
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.1"
55
#endif // LWIP_HASH_H

tools/sdk/lwip2/include/lwip/apps/sntp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ void sntp_setservername(u8_t idx, const char *server);
6767
const char *sntp_getservername(u8_t idx);
6868
#endif /* SNTP_SERVER_DNS */
6969

70-
#if SNTP_GET_SERVERS_FROM_DHCP
70+
#if SNTP_GET_SERVERS_FROM_DHCP || SNTP_GET_SERVERS_FROM_DHCPV6
7171
void sntp_servermode_dhcp(int set_servers_from_dhcp);
72-
#else /* SNTP_GET_SERVERS_FROM_DHCP */
72+
#else /* SNTP_GET_SERVERS_FROM_DHCP || SNTP_GET_SERVERS_FROM_DHCPV6 */
7373
#define sntp_servermode_dhcp(x)
74-
#endif /* SNTP_GET_SERVERS_FROM_DHCP */
74+
#endif /* SNTP_GET_SERVERS_FROM_DHCP || SNTP_GET_SERVERS_FROM_DHCPV6 */
7575

7676
#ifdef __cplusplus
7777
}

0 commit comments

Comments
 (0)