From 5116a46f09a4c52c9a0e37665c2c1841bf00bfb0 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Sat, 14 Oct 2017 23:11:56 +0800 Subject: [PATCH] WiFiClient,WiFiServer: update to match new err_t definition --- libraries/ESP8266WiFi/src/WiFiServer.cpp | 4 ++-- libraries/ESP8266WiFi/src/WiFiServer.h | 4 ++-- .../ESP8266WiFi/src/include/ClientContext.h | 24 +++++++------------ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/libraries/ESP8266WiFi/src/WiFiServer.cpp b/libraries/ESP8266WiFi/src/WiFiServer.cpp index 3c65bf44f..380c4ad6e 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.cpp +++ b/libraries/ESP8266WiFi/src/WiFiServer.cpp @@ -151,7 +151,7 @@ T* slist_append_tail(T* head, T* item) { return head; } -int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err) { +long WiFiServer::_accept(tcp_pcb* apcb, long err) { (void) err; DEBUGV("WS:ac\r\n"); ClientContext* client = new ClientContext(apcb, &WiFiServer::_s_discard, this); @@ -166,7 +166,7 @@ void WiFiServer::_discard(ClientContext* client) { DEBUGV("WS:dis\r\n"); } -int8_t WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, int8_t err) { +long WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, long err) { return reinterpret_cast(arg)->_accept(newpcb, err); } diff --git a/libraries/ESP8266WiFi/src/WiFiServer.h b/libraries/ESP8266WiFi/src/WiFiServer.h index 06f7d9c59..8d16e9faa 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.h +++ b/libraries/ESP8266WiFi/src/WiFiServer.h @@ -62,10 +62,10 @@ public: using Print::write; protected: - int8_t _accept(tcp_pcb* newpcb, int8_t err); + long _accept(tcp_pcb* newpcb, long err); void _discard(ClientContext* client); - static int8_t _s_accept(void *arg, tcp_pcb* newpcb, int8_t err); + static long _s_accept(void *arg, tcp_pcb* newpcb, long err); static void _s_discard(void* server, ClientContext* ctx); }; diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index de6d8e150..639b3587c 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -29,12 +29,6 @@ typedef void (*discard_cb_t)(void*, ClientContext*); extern "C" void esp_yield(); extern "C" void esp_schedule(); -#ifdef LWIP_OPEN_SRC -typedef err_t recv_ret_t; -#else -typedef int32_t recv_ret_t; -#endif - #include "DataSource.h" class ClientContext @@ -45,7 +39,7 @@ public: { tcp_setprio(pcb, TCP_PRIO_MIN); tcp_arg(pcb, this); - tcp_recv(pcb, (tcp_recv_fn) &_s_recv); + tcp_recv(pcb, &_s_recv); tcp_sent(pcb, &_s_sent); tcp_err(pcb, &_s_error); tcp_poll(pcb, &_s_poll, 1); @@ -78,7 +72,7 @@ public: tcp_poll(_pcb, NULL, 0); err = tcp_close(_pcb); if(err != ERR_OK) { - DEBUGV(":tc err %d\r\n", err); + DEBUGV(":tc err %d\r\n", (int) err); tcp_abort(_pcb); err = ERR_ABRT; } @@ -126,7 +120,7 @@ public: int connect(ip_addr_t* addr, uint16_t port) { - err_t err = tcp_connect(_pcb, addr, port, reinterpret_cast(&ClientContext::_s_connected)); + err_t err = tcp_connect(_pcb, addr, port, &ClientContext::_s_connected); if (err != ERR_OK) { return 0; } @@ -396,7 +390,7 @@ protected: break; } err_t err = tcp_write(_pcb, buf, next_chunk, TCP_WRITE_FLAG_COPY); - DEBUGV(":wrc %d %d %d\r\n", next_chunk, will_send, err); + DEBUGV(":wrc %d %d %d\r\n", next_chunk, will_send, (int) err); _datasource->release_buffer(buf, next_chunk); if (err == ERR_OK) { _written += next_chunk; @@ -456,7 +450,7 @@ protected: } } - recv_ret_t _recv(tcp_pcb* pcb, pbuf* pb, err_t err) + err_t _recv(tcp_pcb* pcb, pbuf* pb, err_t err) { (void) pcb; (void) err; @@ -481,7 +475,7 @@ protected: void _error(err_t err) { (void) err; - DEBUGV(":er %d %08x\r\n", err, (uint32_t) _datasource); + DEBUGV(":er %d 0x%08x\r\n", (int) err, (uint32_t) _datasource); tcp_arg(_pcb, NULL); tcp_sent(_pcb, NULL); tcp_recv(_pcb, NULL); @@ -490,7 +484,7 @@ protected: _notify_error(); } - int8_t _connected(void* pcb, int8_t err) + err_t _connected(struct tcp_pcb *pcb, err_t err) { (void) err; assert(pcb == _pcb); @@ -505,7 +499,7 @@ protected: return ERR_OK; } - static recv_ret_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, err_t err) + static err_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, err_t err) { return reinterpret_cast(arg)->_recv(tpcb, pb, err); } @@ -525,7 +519,7 @@ protected: return reinterpret_cast(arg)->_sent(tpcb, len); } - static int8_t _s_connected(void* arg, void* pcb, int8_t err) + static err_t _s_connected(void* arg, struct tcp_pcb *pcb, err_t err) { return reinterpret_cast(arg)->_connected(pcb, err); }