Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit f1b79ef

Browse files
committed
Add fix for LwIP2
1 parent 94c7dfe commit f1b79ef

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/ESPAsyncTCP.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C"{
2727
#include "lwip/tcp.h"
2828
#include "lwip/inet.h"
2929
#include "lwip/dns.h"
30+
#include "lwip/init.h"
3031
}
3132
#include <tcp_axtls.h>
3233

@@ -110,11 +111,12 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){
110111
return false;
111112
ip_addr_t addr;
112113
addr.addr = ip;
114+
#if LWIP_VERSION_MAJOR == 1
113115
netif* interface = ip_route(&addr);
114116
if (!interface){ //no route to host
115117
return false;
116118
}
117-
119+
#endif
118120
tcp_pcb* pcb = tcp_new();
119121
if (!pcb){ //could not allocate pcb
120122
return false;
@@ -448,7 +450,11 @@ long AsyncClient::_poll(tcp_pcb* pcb){
448450
return ERR_OK;
449451
}
450452

451-
void AsyncClient::_dns_found(ip_addr_t *ipaddr){
453+
#if LWIP_VERSION_MAJOR == 1
454+
void AsyncClient::_dns_found(struct ip_addr *ipaddr){
455+
#else
456+
void AsyncClient::_dns_found(const ip_addr *ipaddr){
457+
#endif
452458
if(ipaddr){
453459
#if ASYNC_TCP_SSL_ENABLED
454460
connect(IPAddress(ipaddr->addr), _connect_port, _pcb_secure);
@@ -464,8 +470,11 @@ void AsyncClient::_dns_found(ip_addr_t *ipaddr){
464470
}
465471

466472
// lWIP Callbacks
467-
473+
#if LWIP_VERSION_MAJOR == 1
468474
void AsyncClient::_s_dns_found(const char *name, ip_addr_t *ipaddr, void *arg){
475+
#else
476+
void AsyncClient::_s_dns_found(const char *name, const ip_addr *ipaddr, void *arg){
477+
#endif
469478
reinterpret_cast<AsyncClient*>(arg)->_dns_found(ipaddr);
470479
}
471480

src/ESPAsyncTCP.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,21 @@ class AsyncClient {
9191
#endif
9292
long _poll(tcp_pcb* pcb);
9393
long _sent(tcp_pcb* pcb, uint16_t len);
94+
#if LWIP_VERSION_MAJOR == 1
9495
void _dns_found(struct ip_addr *ipaddr);
96+
#else
97+
void _dns_found(const ip_addr *ipaddr);
98+
#endif
9599
static long _s_poll(void *arg, struct tcp_pcb *tpcb);
96100
static long _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, long err);
97101
static void _s_error(void *arg, long err);
98102
static long _s_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len);
99103
static long _s_connected(void* arg, void* tpcb, long err);
104+
#if LWIP_VERSION_MAJOR == 1
100105
static void _s_dns_found(const char *name, struct ip_addr *ipaddr, void *arg);
106+
#else
107+
static void _s_dns_found(const char *name, const ip_addr *ipaddr, void *arg);
108+
#endif
101109
#if ASYNC_TCP_SSL_ENABLED
102110
static void _s_data(void *arg, struct tcp_pcb *tcp, uint8_t * data, size_t len);
103111
static void _s_handshake(void *arg, struct tcp_pcb *tcp, SSL *ssl);

0 commit comments

Comments
 (0)