TCP Socket Hello World with Ethernet

Dependencies:   EthernetInterface IAP mbed-rtos mbed

Fork of TCPSocket_HelloWorld by Seeed

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Tue May 12 07:29:44 2015 +0000
Parent:
17:0d74817db362
Commit message:
use LPC1768 serial number as unique MAC address

Changed in this revision

IAP.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IAP.lib	Tue May 12 07:29:44 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/okano/code/IAP/#c8bf974ecb33
--- a/main.cpp	Thu Apr 23 02:01:38 2015 +0000
+++ b/main.cpp	Tue May 12 07:29:44 2015 +0000
@@ -1,10 +1,14 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "IAP.h"
+
 
 int main() {
+    printf("-------- Arch Pro Ethernet -----------\n");
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
+    printf("MAC Address is %s\n", eth.getMACAddress());
     printf("IP Address is %s\n", eth.getIPAddress());
     
     TCPSocketConnection sock;
@@ -30,13 +34,18 @@
     while(1) {}
 }
 
-// override the default weak function to provide a specific mac address
-extern "C" void mbed_mac_address(char *mac)
-{
-    mac[0] = 0x01;
-    mac[1] = 0x23;
-    mac[2] = 0x45;
-    mac[3] = 0x67;
-    mac[4] = 0x89;
-    mac[5] = 0xAB;
+extern "C" void mbed_mac_address(char *mac) {
+    IAP iap;
+    
+    int *serial_number_array = iap.read_serial();   // 4 int
+    char *ptr = (char *)serial_number_array;
+    
+    mac[0] = ptr[0];
+    mac[1] = ptr[1];
+    mac[2] = ptr[2];
+    mac[3] = ptr[3];
+    mac[4] = ptr[4];
+    mac[5] = ptr[5];
 };
+
+
--- a/mbed-rtos.lib	Thu Apr 23 02:01:38 2015 +0000
+++ b/mbed-rtos.lib	Tue May 12 07:29:44 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#34292fba723c
+http://mbed.org/users/mbed_official/code/mbed-rtos/#85a52b7ef44b
--- a/mbed.bld	Thu Apr 23 02:01:38 2015 +0000
+++ b/mbed.bld	Tue May 12 07:29:44 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file