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

remove lwip-v1.4 specific code #7436

Merged
merged 17 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 14 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,27 @@ jobs:
env:
- BUILD_PARITY=odd

- name: "Debug (1)"
- name: "Debug IPv6 (1)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/debug.sh
script: $TRAVIS_BUILD_DIR/tests/debug6.sh
env:
- BUILD_PARITY=even
- name: "Debug (2)"
- name: "Debug IPv6 (2)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/debug.sh
script: $TRAVIS_BUILD_DIR/tests/debug6.sh
env:
- BUILD_PARITY=odd

- name: "Build IPv6 (1)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/build6.sh
env:
- BUILD_PARITY=even
- name: "Build IPv6 (2)"
stage: build
script: $TRAVIS_BUILD_DIR/tests/build6.sh
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: "Build IPv6 (1)"
# stage: build
# script: $TRAVIS_BUILD_DIR/tests/build6.sh
# env:
# - BUILD_PARITY=even
# - name: "Build IPv6 (2)"
# stage: build
# script: $TRAVIS_BUILD_DIR/tests/build6.sh
# env:
# - BUILD_PARITY=odd

- name: "Mac OSX can build sketches"
os: osx
Expand Down
238 changes: 0 additions & 238 deletions boards.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cores/esp8266/AddrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct netifWrapper
const char* ifmac () const { return (const char*)_netif->hwaddr; }
int ifnumber () const { return _netif->num; }
bool ifUp () const { return !!(_netif->flags & NETIF_FLAG_UP); }
CONST netif* interface () const { return _netif; }
const netif* interface () const { return _netif; }

const ip_addr_t* ipFromNetifNum () const
{
Expand Down
2 changes: 0 additions & 2 deletions cores/esp8266/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ class Client: public Stream {
uint8_t* rawIPAddress(IPAddress& addr) {
return addr.raw_address();
}
#if LWIP_VERSION_MAJOR != 1
const uint8_t* rawIPAddress(const IPAddress& addr) {
return addr.raw_address();
}
#endif
};

#endif
19 changes: 0 additions & 19 deletions cores/esp8266/Esp-version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@
#include <Arduino.h>
#include <user_interface.h>
#include <core_version.h>
#include <lwip/init.h> // LWIP_VERSION_*
#include <lwipopts.h> // LWIP_HASH_STR (lwip2)
#include <bearssl/bearssl_git.h> // BEARSSL_GIT short hash

#define STRHELPER(x) #x
#define STR(x) STRHELPER(x) // stringifier

static const char arduino_esp8266_git_ver [] PROGMEM = "/Core:" STR(ARDUINO_ESP8266_GIT_DESC) "=";
#if LWIP_VERSION_MAJOR > 1
#if LWIP_IPV6
static const char lwip_version [] PROGMEM = "/lwIP:IPv6+" LWIP_HASH_STR;
#else
static const char lwip_version [] PROGMEM = "/lwIP:" LWIP_HASH_STR;
#endif
#endif
static const char bearssl_version [] PROGMEM = "/BearSSL:" STR(BEARSSL_GIT);

String EspClass::getFullVersion() {
Expand All @@ -45,23 +42,7 @@ String EspClass::getFullVersion() {
s += system_get_sdk_version();
s += FPSTR(arduino_esp8266_git_ver);
s += String(esp8266::coreVersionNumeric());
#if LWIP_VERSION_MAJOR == 1
s += F("/lwIP:");
s += LWIP_VERSION_MAJOR;
s += '.';
s += LWIP_VERSION_MINOR;
s += '.';
s += LWIP_VERSION_REVISION;
#if LWIP_VERSION_IS_DEVELOPMENT
s += F("-dev");
#endif
#if LWIP_VERSION_IS_RC
s += F("rc");
s += String(LWIP_VERSION_RC);
#endif
#else // LWIP_VERSION_MAJOR != 1
s += FPSTR(lwip_version);
#endif // LWIP_VERSION_MAJOR != 1
s += FPSTR(bearssl_version);

return s;
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ bool IPAddress::isValid(const char* arg) {
return IPAddress().fromString(arg);
}

CONST IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
const IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
const IPAddress INADDR_NONE(255,255,255,255);

/**************************************/
Expand Down
21 changes: 2 additions & 19 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,11 @@

#include <lwip/init.h>
#include <lwip/ip_addr.h>
#include <lwip/ip4_addr.h>

#if LWIP_VERSION_MAJOR == 1
// compatibility macros to make lwIP-v1 compiling lwIP-v2 API
#define LWIP_IPV6_NUM_ADDRESSES 0
#define ip_2_ip4(x) (x)
#define ipv4_addr ip_addr
#define ipv4_addr_t ip_addr_t
#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 IP_ADDR_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
struct ip_addr: ipv4_addr { };
#endif // !LWIP_IPV6
#endif // lwIP-v2+

// A class to make it easier to handle and pass around IP addresses
// IPv6 update:
Expand Down Expand Up @@ -220,7 +203,7 @@ class IPAddress: public Printable {

};

extern CONST IPAddress INADDR_ANY;
extern const IPAddress INADDR_ANY;
extern const IPAddress INADDR_NONE;

#endif
4 changes: 2 additions & 2 deletions cores/esp8266/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ class UDP: public Stream {
// Return the port of the host who sent the current incoming packet
virtual uint16_t remotePort() =0;
protected:

uint8_t* rawIPAddress(IPAddress& addr) {
return addr.raw_address();
}
#if LWIP_VERSION_MAJOR != 1

const uint8_t* rawIPAddress(const IPAddress& addr) {
return addr.raw_address();
}
#endif
};

#endif
40 changes: 0 additions & 40 deletions cores/esp8266/sntp-lwip2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,6 @@ void settimeofday_cb (const TrivialCB& cb)

extern "C" {

#if LWIP_VERSION_MAJOR == 1

#include <pgmspace.h>

static const char stod14[] PROGMEM = "settimeofday() can't set time!\n";
bool sntp_set_timezone(sint8 timezone);
bool sntp_set_timezone_in_seconds(int32_t timezone)
{
return sntp_set_timezone((sint8)(timezone/(60*60))); //TODO: move this to the same file as sntp_set_timezone() in lwip1.4, and implement correctly over there.
}

void sntp_set_daylight(int daylight);

int settimeofday(const struct timeval* tv, const struct timezone* tz)
{
if (tz) /*before*/
{
sntp_set_timezone_in_seconds(tz->tz_minuteswest * 60);
// apparently tz->tz_dsttime is a bitfield and should not be further used (cf man)
sntp_set_daylight(0);
}
if (tv) /* after*/
{
// can't call lwip1.4's static sntp_set_system_time()
os_printf(stod14);

// reset time subsystem
timeshift64_is_set = false;

return -1;
}
return 0;
}

#endif // lwip 1.4 only

#if LWIP_VERSION_MAJOR == 2

#include <lwip/apps/sntp.h>

uint32_t sntp_real_timestamp = 0;
Expand Down Expand Up @@ -128,6 +90,4 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
return 0;
}

#endif // lwip2 only

};
9 changes: 0 additions & 9 deletions cores/esp8266/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ int clock_gettime(clockid_t unused, struct timespec *tp)
return 0;
}

#if LWIP_VERSION_MAJOR == 1
// hack for espressif time management included in patched lwIP-1.4
#define sntp_real_timestamp sntp_get_current_timestamp()
#endif

#if LWIP_VERSION_MAJOR != 1

// backport Espressif api

bool sntp_set_timezone_in_seconds (int32_t timezone_sec)
Expand All @@ -103,8 +96,6 @@ uint32 sntp_get_current_timestamp()
return sntp_real_timestamp;
}

#endif

time_t time(time_t * t)
{
if (t)
Expand Down
2 changes: 0 additions & 2 deletions doc/faq/a05-board-generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ As of today you can:

* change led pin ``LED_BUILTIN`` for the two generic boards

* change the default lwIP version (1.4 or 2)

* create an abridged boards.txt file


Expand Down
5 changes: 1 addition & 4 deletions doc/faq/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ This is not needed anymore:
PCBs in time-wait state are limited to 5 and removed when that number is
exceeded.

Ref. `lwIP-v1.4 <https://github.com/esp8266/Arduino/commit/07f4d4c241df2c552899857f39a4295164f686f2#diff-f8258e71e25fb9985ca3799e3d8b88ecR399>`__,
`lwIP-v2 <https://github.com/d-a-v/esp82xx-nonos-linklayer/commit/420960dfc0dbe07114f7364845836ac333bc84f7>`__
Ref. `<https://github.com/d-a-v/esp82xx-nonos-linklayer/commit/420960dfc0dbe07114f7364845836ac333bc84f7>`__

For reference:

Expand All @@ -139,8 +138,6 @@ same (s-ip,s-port,d-ip,d-port) when the first is already closed but still
having duplicate packets lost in internet arriving later during the second.
Artificially clearing them is a workaround to help saving precious heap.

The following lines are compatible with both lwIP versions:

.. code:: cpp

// no need for #include
Expand Down
9 changes: 2 additions & 7 deletions libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,16 @@ void ESP8266NetBIOS::end()
}
}

void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint16_t port)
void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t port)
{
(void)upcb;
(void)addr;
(void)port;
while(pb != NULL) {
uint8_t * data = (uint8_t*)((pb)->payload);
size_t len = pb->len;
#if LWIP_VERSION_MAJOR == 1
// check UdpContext.h
ip_addr_t* saddr = &current_iphdr_src;
#else
// check UdpContext.h
const ip_addr_t* saddr = &ip_data.current_iphdr_src;
#endif

if (len >= sizeof(struct NBNSQUESTION)) {
struct NBNSQUESTION * question = (struct NBNSQUESTION *)data;
Expand Down Expand Up @@ -267,7 +262,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
}
}

void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, CONST ip_addr_t *addr, uint16_t port)
void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port)
{
reinterpret_cast<ESP8266NetBIOS*>(arg)->_recv(upcb, p, addr, port);
}
Expand Down
5 changes: 2 additions & 3 deletions libraries/ESP8266NetBIOS/ESP8266NetBIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define __ESPNBNS_h__

extern "C" {
#include "lwip/init.h" // LWIP_VERSION_
#include <lwip/ip_addr.h>
}
#include <ESP8266WiFi.h>
Expand All @@ -28,8 +27,8 @@ class ESP8266NetBIOS
void _getnbname(char *nbname, char *name, uint8_t maxlen);
void _makenbname(char *name, char *nbname, uint8_t outlen);

void _recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint16_t port);
static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, CONST ip_addr_t *addr, uint16_t port);
void _recv(udp_pcb *upcb, pbuf *pb, const ip_addr_t *addr, uint16_t port);
static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port);

public:
ESP8266NetBIOS();
Expand Down
16 changes: 0 additions & 16 deletions libraries/ESP8266WiFi/examples/StaticLease/StaticLease.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@

#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 Down Expand Up @@ -104,5 +90,3 @@ void setup() {
void loop() {
server.handleClient();
}

#endif // lwIP-v2
Loading