ECE4180 lab2 part 5

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Revision:
15:da930157dc32
Parent:
11:59dcefdda506
diff -r 72be2b8b7f24 -r da930157dc32 main.cpp
--- a/main.cpp	Wed May 14 15:07:26 2014 +0000
+++ b/main.cpp	Tue Oct 06 19:24:51 2015 +0000
@@ -1,12 +1,31 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
 
+Serial pc(USBTX, USBRX); // tx, rx
+
+extern "C" void mbed_mac_address(char *mac);
+ 
 int main() {
+    
+    // to get the mac address of the mbed
+    char mac[6];
+    mbed_mac_address(mac);
+    for(int i=0; i<6;i++) {
+        printf("%02X ", mac[i]);
+    }
+    printf("\n");
+
     EthernetInterface eth;
     eth.init(); //Use DHCP
-    eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
     
+    pc.printf("Testing Init");
+    int err = eth.connect(15000);
+    if (err != 0 ) {
+        pc.printf("Error in connection error code is  %d. \n", err);
+    } else {
+       // exit(1);
+    }
+    pc.printf("IP Address is %s\n", eth.getIPAddress());
     TCPSocketConnection sock;
     sock.connect("mbed.org", 80);