From 5c3b253c93d12b8baa28810daa44348a031c09de Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 27 Jan 2019 22:43:05 +0100 Subject: [PATCH 1/6] adaptations for lwIP-v1.4 --- cores/esp8266/IPAddress.h | 2 ++ libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 8 ++++++++ libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h | 2 +- tests/host/common/user_interface.cpp | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cores/esp8266/IPAddress.h b/cores/esp8266/IPAddress.h index e93e6cc3c4..0759fef782 100644 --- a/cores/esp8266/IPAddress.h +++ b/cores/esp8266/IPAddress.h @@ -35,9 +35,11 @@ #define IP_IS_V4_VAL(x) (1) #define IP_SET_TYPE_VAL(x,y) do { (void)0; } while (0) #define IP_ANY_TYPE (&ip_addr_any) +#define IP4_ADDR_ANY IPADDR_ANY #define IP4_ADDR_ANY4 IPADDR_ANY #define IPADDR4_INIT(x) { x } #define CONST /* nothing: lwIP-v1 does not use const */ +#define ip4_addr_netcmp ip_addr_netcmp #else // lwIP-v2+ #define CONST const #if !LWIP_IPV6 diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index ac03a3754d..40e6fdd26c 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -501,6 +501,10 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) { - no '-' as last char */ +#if LWIP_VERSION_MAJOR == 1 +#define netif_dhcp_data(netif) ((netif)->dhcp) +#endif + size_t len = strlen(aHostname); if (len == 0 || len > 32) { @@ -534,7 +538,11 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) { for (netif* intf = netif_list; intf; intf = intf->next) { // unconditionally update all known interfaces +#if LWIP_VERSION_MAJOR == 1 + intf->hostname = (char*)wifi_station_get_hostname(); +#else intf->hostname = wifi_station_get_hostname(); +#endif if (netif_dhcp_data(intf) != nullptr) { // renew already started DHCP leases diff --git a/libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h b/libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h index d923f9a976..c58aebdc74 100644 --- a/libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h +++ b/libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h @@ -32,7 +32,7 @@ // cherry pick from lwip1 dns.c/mdns.c source files: #define DNS_MQUERY_PORT 5353 -#define DNS_MQUERY_IPV4_GROUP_INIT ipaddr_addr("224.0.0.251") /* resolver1.opendns.com */ +#define DNS_MQUERY_IPV4_GROUP_INIT IPAddress(224,0,0,251) /* resolver1.opendns.com */ #define DNS_RRCLASS_ANY 255 /* any class */ #else // lwIP > 1 diff --git a/tests/host/common/user_interface.cpp b/tests/host/common/user_interface.cpp index 34e9621e26..8ed56a9ec0 100644 --- a/tests/host/common/user_interface.cpp +++ b/tests/host/common/user_interface.cpp @@ -280,7 +280,7 @@ bool wifi_station_get_config_default (struct station_config *config) } char wifi_station_get_hostname_str [128]; -char* wifi_station_get_hostname (void) +const char* wifi_station_get_hostname (void) { return strcpy(wifi_station_get_hostname_str, "esposix"); } @@ -312,7 +312,7 @@ bool wifi_station_set_config_current (struct station_config *config) return true; } -bool wifi_station_set_hostname (char *name) +bool wifi_station_set_hostname (const char *name) { (void)name; return true; From f68501452441c35a41ea27ee472753670cc240c2 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 27 Jan 2019 22:55:45 +0100 Subject: [PATCH 2/6] add lwIP-v1.4 in CI --- .travis.yml | 11 +++++++++++ tests/build1.sh | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 tests/build1.sh diff --git a/.travis.yml b/.travis.yml index a1343eb6df..2a1c422061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,6 +65,17 @@ jobs: env: - BUILD_PARITY=odd + - name: "Build lwIP-v1.4 (1)" + stage: build + script: $TRAVIS_BUILD_DIR/tests/build1.sh + env: + - BUILD_PARITY=even + - name: "Build lwIP-v1.4 (2)" + stage: build + script: $TRAVIS_BUILD_DIR/tests/build1.sh + env: + - BUILD_PARITY=odd + - name: "Host tests" stage: build script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh diff --git a/tests/build1.sh b/tests/build1.sh new file mode 100755 index 0000000000..df50b4c38d --- /dev/null +++ b/tests/build1.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +cache_dir=$(mktemp -d) + +source "$TRAVIS_BUILD_DIR"/tests/common.sh + +if [ -z "$BUILD_PARITY" ]; then + mod=1 + rem=0 +elif [ "$BUILD_PARITY" = "even" ]; then + mod=2 + rem=0 +elif [ "$BUILD_PARITY" = "odd" ]; then + mod=2 + rem=1 +fi + +install_arduino nodebug +build_sketches_with_arduino "$mod" "$rem" hb1 + +rm -rf "$cache_dir" + From fd16775b8bcc215f84c094f260ef5c4439817f74 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sun, 27 Jan 2019 22:59:44 +0100 Subject: [PATCH 3/6] simplify --- cores/esp8266/IPAddress.h | 1 + libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cores/esp8266/IPAddress.h b/cores/esp8266/IPAddress.h index 0759fef782..99a2198730 100644 --- a/cores/esp8266/IPAddress.h +++ b/cores/esp8266/IPAddress.h @@ -40,6 +40,7 @@ #define IPADDR4_INIT(x) { x } #define CONST /* nothing: lwIP-v1 does not use const */ #define ip4_addr_netcmp ip_addr_netcmp +#define netif_dhcp_data(netif) ((netif)->dhcp) #else // lwIP-v2+ #define CONST const #if !LWIP_IPV6 diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index 40e6fdd26c..2c362a06b9 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -501,10 +501,6 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) { - no '-' as last char */ -#if LWIP_VERSION_MAJOR == 1 -#define netif_dhcp_data(netif) ((netif)->dhcp) -#endif - size_t len = strlen(aHostname); if (len == 0 || len > 32) { From 74f89c862e818146e3346a946814ebd10a721130 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Mon, 28 Jan 2019 15:45:21 +0100 Subject: [PATCH 4/6] lwIP-v1.4: fix netbios --- libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp | 2 +- tests/run_CI_locally.sh | 26 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp b/libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp index 6e021c8877..aedcfcdc7c 100644 --- a/libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp +++ b/libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp @@ -182,7 +182,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1 size_t len = pb->len; #if LWIP_VERSION_MAJOR == 1 // check UdpContext.h - const ip_addr_t* saddr = ¤t_iphdr_src; + ip_addr_t* saddr = ¤t_iphdr_src; #else // check UdpContext.h const ip_addr_t* saddr = &ip_data.current_iphdr_src; diff --git a/tests/run_CI_locally.sh b/tests/run_CI_locally.sh index 5b23a2e4b5..3bd48010f3 100755 --- a/tests/run_CI_locally.sh +++ b/tests/run_CI_locally.sh @@ -54,12 +54,13 @@ while true; do Which build? 1. main 2. main + IPv6 -3. debug even -4. debug odd -5. platformio -6. package -7. host -8. style +3. main with lwIP-v1.4 +4. debug even +5. debug odd +6. platformio +7. package +8. host +9. style EOF read ans @@ -68,12 +69,13 @@ EOF case "$ans" in 1) BUILD_TYPE=build;; 2) BUILD_TYPE=build6;; - 3) BUILD_TYPE=debug_even;; - 4) BUILD_TYPE=debug_odd;; - 5) BUILD_TYPE=platformio;; - 6) BUILD_TYPE=package;; - 7) BUILD_TYPE=host;; - 8) BUILD_TYPE=style;; + 3) BUILD_TYPE=build1;; + 4) BUILD_TYPE=debug_even;; + 5) BUILD_TYPE=debug_odd;; + 6) BUILD_TYPE=platformio;; + 7) BUILD_TYPE=package;; + 8) BUILD_TYPE=host;; + 9) BUILD_TYPE=style;; esac test -z "$BUILD_TYPE" || break done From 1b85f85b77a8e168ff2c57477447264a63b5813c Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Mon, 28 Jan 2019 15:47:14 +0100 Subject: [PATCH 5/6] add lwIP-v1.4 CI tests in local runner --- tests/run_CI_locally.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/run_CI_locally.sh b/tests/run_CI_locally.sh index 3bd48010f3..65b91277f2 100755 --- a/tests/run_CI_locally.sh +++ b/tests/run_CI_locally.sh @@ -107,6 +107,13 @@ elif [ "$BUILD_TYPE" = "build6_even" ]; then elif [ "$BUILD_TYPE" = "build6_odd" ]; then BUILD_PARITY=odd tests/build6.sh +elif [ "$BUILD_TYPE" = "build1" ]; then + tests/build1.sh +elif [ "$BUILD_TYPE" = "build1_even" ]; then + BUILD_PARITY=even tests/build1.sh +elif [ "$BUILD_TYPE" = "build1_odd" ]; then + BUILD_PARITY=odd tests/build1.sh + elif [ "$BUILD_TYPE" = "platformio" ]; then tests/platformio-custom.sh elif [ "$BUILD_TYPE" = "platformio_even" ]; then From 4c311ff62cfe36ee89e0a3b70fa4f3083e05e045 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Mon, 28 Jan 2019 16:49:53 +0100 Subject: [PATCH 6/6] fix StaticLease example with lwIP-v1 --- .../examples/StaticLease/StaticLease.ino | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino b/libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino index 51c0b97874..fa183d0fbe 100644 --- a/libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino +++ b/libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino @@ -1,3 +1,18 @@ + +#include + +#if LWIP_VERSION_MAJOR == 1 + +void setup() { + Serial.begin(115200); + Serial.println("wifi_softap_add_dhcps_lease() is not implemented with lwIP-v1"); +} + +void loop() { +} + +#else + /* Create a WiFi access point and provide static lease */ #include @@ -19,9 +34,7 @@ void handleRoot() { char wifiClientMac[18]; unsigned char number_client; struct station_info *stat_info; - struct ip4_addr *IPaddress; - IPAddress address; int i = 1; number_client = wifi_softap_get_station_num(); @@ -31,13 +44,11 @@ void handleRoot() { result += String(number_client); result += "
"; while (stat_info != NULL) { - IPaddress = &stat_info->ip; - address = IPaddress->addr; result += "Client "; result += String(i); result += " = "; - result += String(address.toString()); + result += IPAddress(stat_info->ip).toString(); result += " - "; sprintf(wifiClientMac, "%02X:%02X:%02X:%02X:%02X:%02X", MAC2STR(stat_info->bssid)); result += wifiClientMac; @@ -93,3 +104,5 @@ void setup() { void loop() { server.handleClient(); } + +#endif // lwIP-v2