From e9f3fa0fe1929e602399d375abefb0d478027032 Mon Sep 17 00:00:00 2001 From: cassy73 Date: Thu, 29 Dec 2016 12:38:40 +0100 Subject: [PATCH] Add files via upload --- Dns.cpp | 2 +- Dns.h | 2 +- UIPClient.cpp | 2 +- UIPClient.h | 21 ++++++++++++--------- UIPServer.h | 23 ++++++++++++++--------- UIPUdp.cpp | 7 ++++++- UIPUdp.h | 26 +++++++++++++++----------- library.properties | 2 +- 8 files changed, 51 insertions(+), 34 deletions(-) diff --git a/Dns.cpp b/Dns.cpp index 92accbb..fb3dfeb 100644 --- a/Dns.cpp +++ b/Dns.cpp @@ -258,7 +258,7 @@ uint16_t DNSClient::BuildRequest(const char* aName) } -uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress) +int16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress) { uint32_t startTime = millis(); diff --git a/Dns.h b/Dns.h index 1346841..e6c3461 100644 --- a/Dns.h +++ b/Dns.h @@ -31,7 +31,7 @@ class DNSClient protected: uint16_t BuildRequest(const char* aName); - uint16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); + int16_t ProcessResponse(uint16_t aTimeout, IPAddress& aAddress); IPAddress iDNSServer; uint16_t iRequestId; diff --git a/UIPClient.cpp b/UIPClient.cpp index 7fd42fe..fc24d05 100644 --- a/UIPClient.cpp +++ b/UIPClient.cpp @@ -194,7 +194,7 @@ UIPClient::write(const uint8_t *buf, size_t size) return _write(data, buf, size); } -size_t +int16_t UIPClient::_write(uip_userdata_t* u, const uint8_t *buf, size_t size) { #if ACTLOGLEVEL>=LOG_DEBUG_V3 diff --git a/UIPClient.h b/UIPClient.h index 8244ace..cc54e46 100644 --- a/UIPClient.h +++ b/UIPClient.h @@ -22,11 +22,12 @@ #include "ethernet_comp.h" #if defined(ARDUINO) - #include "Print.h" - #include "Client.h" + #include "Print.h" + #include "Client.h" #endif #if defined(__MBED__) - #include "mbed/Client.h" + #include "mbed/Print.h" + #include "mbed/Client.h" #endif #include "utility/mempool.h" #include "utility/logging.h" @@ -66,8 +67,12 @@ typedef struct { #endif } uip_userdata_t; -class UIPClient : public Client { - +#if defined(ARDUINO) + class UIPClient : public Client { +#endif +#if defined(__MBED__) + class UIPClient : public Print, public Client { +#endif public: UIPClient(); virtual int connect(IPAddress ip, uint16_t port); @@ -86,9 +91,7 @@ class UIPClient : public Client { virtual int peek(); virtual void flush(); - #if defined(ARDUINO) - using Print::write; - #endif + using Print::write; private: UIPClient(struct uip_conn *_conn); @@ -99,7 +102,7 @@ class UIPClient : public Client { static uip_userdata_t all_data[UIP_CONNS]; static uip_userdata_t* _allocateData(); - static size_t _write(uip_userdata_t *,const uint8_t *buf, size_t size); + static int16_t _write(uip_userdata_t *,const uint8_t *buf, size_t size); static int _available(uip_userdata_t *); static uint8_t _currentBlock(memhandle* blocks); diff --git a/UIPServer.h b/UIPServer.h index ea6621b..4fdb53c 100644 --- a/UIPServer.h +++ b/UIPServer.h @@ -21,24 +21,29 @@ #include "ethernet_comp.h" #if defined(ARDUINO) - #include "Server.h" + #include "Print.h" + #include "Server.h" #endif #if defined(__MBED__) - #include "mbed/Server.h" + #include "mbed/Print.h" + #include "mbed/Server.h" #endif #include "UIPClient.h" -class UIPServer : public Server { - +#if defined(ARDUINO) + class UIPServer : public Server { +#endif +#if defined(__MBED__) + class UIPServer : public Print, public Server { +#endif public: UIPServer(uint16_t); UIPClient available(); virtual void begin(); - size_t write(uint8_t); - size_t write(const uint8_t *buf, size_t size); - #if defined(ARDUINO) - using Print::write; - #endif + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + + using Print::write; private: uint16_t _port; diff --git a/UIPUdp.cpp b/UIPUdp.cpp index c8ac503..92a0780 100644 --- a/UIPUdp.cpp +++ b/UIPUdp.cpp @@ -121,7 +121,12 @@ UIPUDP::beginPacket(IPAddress ip, uint16_t port) } #if ACTLOGLEVEL>=LOG_DEBUG LogObject.uart_send_str(F("rip: ")); - LogObject.uart_send_dec(ip); + #if defined(ARDUINO) + LogObject.print(ip); + #endif + #if defined(__MBED__) + LogObject.printf("%d.%d.%d.%d",ip[0],ip[1],ip[2],ip[3]); + #endif LogObject.uart_send_str(F(", port: ")); LogObject.uart_send_decln(port); #endif diff --git a/UIPUdp.h b/UIPUdp.h index 675c014..b1ee080 100644 --- a/UIPUdp.h +++ b/UIPUdp.h @@ -21,14 +21,16 @@ #define UIPUDP_H #include "ethernet_comp.h" -#if defined(__MBED__) - #include - #include "mbed/Udp.h" -#endif #if defined(ARDUINO) #include + #include "Print.h" #include #endif +#if defined(__MBED__) + #include + #include "mbed/Print.h" + #include "mbed/Udp.h" +#endif #include "utility/mempool.h" extern "C" { #include "utility/uip.h" @@ -46,9 +48,12 @@ typedef struct { bool send; } uip_udp_userdata_t; -class UIPUDP : public UDP -{ - +#if defined(ARDUINO) + class UIPUDP : public UDP { +#endif +#if defined(__MBED__) + class UIPUDP : public Print, public UDP { +#endif private: struct uip_udp_conn *_uip_udp_conn; @@ -74,10 +79,9 @@ class UIPUDP : public UDP virtual size_t write(uint8_t); // Write size bytes from buffer into the packet virtual size_t write(const uint8_t *buffer, size_t size); - - #if defined(ARDUINO) - using Print::write; - #endif + + using Print::write; + // Start processing the next available incoming packet // Returns the size of the packet in bytes, or 0 if no packets are available virtual int parsePacket(void); diff --git a/library.properties b/library.properties index 28bdc27..dfdba3f 100644 --- a/library.properties +++ b/library.properties @@ -6,6 +6,6 @@ paragraph=implements the same API as stock Ethernet-lib. Just replace the includ url=https://github.com/ntruchsess/arduino_uip architectures=* category=Communication -version=1.2.0 +version=1.2.1 dependencies= core-dependencies=arduino (>=1.5.0)