Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adaptations for lwIP-v1.4 #5682

Merged
merged 6 commits into from Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cores/esp8266/IPAddress.h
Expand Up @@ -35,9 +35,12 @@
#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
#define netif_dhcp_data(netif) ((netif)->dhcp)
#else // lwIP-v2+
#define CONST const
#if !LWIP_IPV6
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp
Expand Up @@ -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 = &current_iphdr_src;
ip_addr_t* saddr = &current_iphdr_src;
#else
// check UdpContext.h
const ip_addr_t* saddr = &ip_data.current_iphdr_src;
Expand Down
23 changes: 18 additions & 5 deletions libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino
@@ -1,3 +1,18 @@

#include <lwip/init.h>

#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 <ESP8266WiFi.h>
Expand All @@ -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();
Expand All @@ -31,13 +44,11 @@ void handleRoot() {
result += String(number_client);
result += "</h1></br>";
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;
Expand Down Expand Up @@ -93,3 +104,5 @@ void setup() {
void loop() {
server.handleClient();
}

#endif // lwIP-v2
4 changes: 4 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Expand Up @@ -534,7 +534,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
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266mDNS/src/LEAmDNS_lwIPdefs.h
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions 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"

4 changes: 2 additions & 2 deletions tests/host/common/user_interface.cpp
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
Expand Down
33 changes: 21 additions & 12 deletions tests/run_CI_locally.sh
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -105,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
Expand Down