port ethernet libray for stm32f407 (seeed arch max). it works.

Dependencies:   EthernetInterface-arch-max-dev mbed-rtos mbed-src

Fork of TCPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Mon Mar 02 08:25:41 2015 +0000
Parent:
15:69e41cbbc8ac
Child:
17:bbdfe971ff07
Commit message:
developing stm32f407 ethernet, able to receive data

Changed in this revision

EthernetInterface.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-src.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Sun Sep 21 05:55:13 2014 +0000
+++ b/EthernetInterface.lib	Mon Mar 02 08:25:41 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#5887ae6c0c2c
+http://developer.mbed.org/users/yihui/code/EthernetInterface-arch-max-dev/#c488e56bea47
--- a/main.cpp	Sun Sep 21 05:55:13 2014 +0000
+++ b/main.cpp	Mon Mar 02 08:25:41 2015 +0000
@@ -3,29 +3,38 @@
 
 int main() {
     EthernetInterface eth;
-    eth.init(); //Use DHCP
+    eth.init("192.168.1.3", "255.255.255.0", "192.168.1.1"); 
+    // eth.init(); // use DHCP
     eth.connect();
     printf("IP Address is %s\n", eth.getIPAddress());
     
-    TCPSocketConnection sock;
-    sock.connect("mbed.org", 80);
+#if 0    
+    UDPSocket sock;
+    sock.init();
+    sock.set_broadcasting();
     
-    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
-    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    Endpoint broadcast;
+    broadcast.set_address("255.255.255.255", 2015);
     
-    char buffer[300];
-    int ret;
+    char out_buffer[] = "very important data";
+    
     while (true) {
-        ret = sock.receive(buffer, sizeof(buffer)-1);
-        if (ret <= 0)
-            break;
-        buffer[ret] = '\0';
-        printf("Received %d chars from server:\n%s\n", ret, buffer);
+        printf("Broadcasting...\n");
+        sock.sendTo(broadcast, out_buffer, sizeof(out_buffer));
+        Thread::wait(1000);
     }
-      
-    sock.close();
+#else
+    UDPSocket socket;
+    socket.bind(2015);
+    socket.set_broadcasting();
     
-    eth.disconnect();
-    
-    while(1) {}
+    Endpoint broadcaster;
+    char buffer[256];
+    while (true) {
+        printf("\nWait for packet...\n");
+        int n = socket.receiveFrom(broadcaster, buffer, sizeof(buffer));
+        buffer[n] = '\0';
+        printf("Packet from \"%s\": %s\n", broadcaster.get_address(), buffer);
+    }
+#endif
 }
--- a/mbed-rtos.lib	Sun Sep 21 05:55:13 2014 +0000
+++ b/mbed-rtos.lib	Mon Mar 02 08:25:41 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#631c0f1008c3
+http://mbed.org/users/mbed_official/code/mbed-rtos/#721c3a93a7b8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Mon Mar 02 08:25:41 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#37da4976ca27
--- a/mbed.bld	Sun Sep 21 05:55:13 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file