UIPEthernet library for Arduino IDE, Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32,Nordic nRF51,Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API. Compiled and tested on Nucleo-F302R8. Master repository is: https://github.com/UIPEthernet/UIPEthernet/

Revision:
12:aef29fbc4a62
Parent:
11:3fb19220d9ec
Child:
20:fe5026169ec6
--- a/examples/TcpClient/TcpClient.ino	Thu Dec 29 13:07:19 2016 +0100
+++ b/examples/TcpClient/TcpClient.ino	Thu Dec 29 14:09:13 2016 +0100
@@ -37,7 +37,12 @@
 int main() {
 #endif
   #if ACTLOGLEVEL>LOG_NONE
-    LogObject.begin(9600);
+    #if defined(ARDUINO)
+      LogObject.begin(9600);
+    #endif
+    #if defined(__MBED__)
+      Serial LogObject(SERIAL_TX,SERIAL_RX);
+    #endif
   #endif
 
   uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
@@ -45,13 +50,33 @@
 
   #if ACTLOGLEVEL>=LOG_INFO
     LogObject.uart_send_str(F("localIP: "));
-    LogObject.println(Ethernet.localIP());
+    #if defined(ARDUINO)
+      LogObject.println(Ethernet.localIP());
+    #endif
+    #if defined(__MBED__)
+      LogObject.printf("%d.%d.%d.%d",Ethernet.localIP()[0],Ethernet.localIP()[1],Ethernet.localIP()[2],Ethernet.localIP()[3]);
+    #endif
     LogObject.uart_send_str(F("subnetMask: "));
-    LogObject.println(Ethernet.subnetMask());
+    #if defined(ARDUINO)
+      LogObject.println(Ethernet.subnetMask());
+    #endif
+    #if defined(__MBED__)
+      LogObject.printf("%d.%d.%d.%d",Ethernet.subnetMask()[0],Ethernet.subnetMask()[1],Ethernet.subnetMask()[2],Ethernet.subnetMask()[3]);
+    #endif
     LogObject.uart_send_str(F("gatewayIP: "));
-    LogObject.println(Ethernet.gatewayIP());
+    #if defined(ARDUINO)
+      LogObject.println(Ethernet.gatewayIP());
+    #endif
+    #if defined(__MBED__)
+      LogObject.printf("%d.%d.%d.%d",Ethernet.gatewayIP()[0],Ethernet.gatewayIP()[1],Ethernet.gatewayIP()[2],Ethernet.gatewayIP()[3]);
+    #endif
     LogObject.uart_send_str(F("dnsServerIP: "));
-    LogObject.println(Ethernet.dnsServerIP());
+    #if defined(ARDUINO)
+      LogObject.println(Ethernet.dnsServerIP());
+    #endif
+    #if defined(__MBED__)
+      LogObject.printf("%d.%d.%d.%d",Ethernet.dnsServerIP()[0],Ethernet.dnsServerIP()[1],Ethernet.dnsServerIP()[2],Ethernet.dnsServerIP()[3]);
+    #endif
   #endif
 
   next = 0;
@@ -87,10 +112,16 @@
             }
           while((size = client.available()) > 0)
             {
-              uint8_t* msg = (uint8_t*)malloc(size);
+              uint8_t* msg = (uint8_t*)malloc(size+1);
+              memset(msg, 0, size+1);
               size = client.read(msg,size);
               #if ACTLOGLEVEL>=LOG_INFO
-                LogObject.write(msg,size);
+                #if defined(ARDUINO)
+                  LogObject.write(msg,size);
+                #endif
+                #if defined(__MBED__)
+                  LogObject.uart_send_str(msg);
+                #endif
               #endif
               free(msg);
             }