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 12:48:05 2015 +0000
Parent:
16:ded63414139d
Commit message:
fix gpio speed config, ethernet library works now.

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
diff -r ded63414139d -r bbdfe971ff07 EthernetInterface.lib
--- a/EthernetInterface.lib	Mon Mar 02 08:25:41 2015 +0000
+++ b/EthernetInterface.lib	Mon Mar 02 12:48:05 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/yihui/code/EthernetInterface-arch-max-dev/#c488e56bea47
+http://developer.mbed.org/users/yihui/code/EthernetInterface-arch-max-dev/#34f536b71858
diff -r ded63414139d -r bbdfe971ff07 main.cpp
--- a/main.cpp	Mon Mar 02 08:25:41 2015 +0000
+++ b/main.cpp	Mon Mar 02 12:48:05 2015 +0000
@@ -3,38 +3,31 @@
 
 int main() {
     EthernetInterface eth;
-    eth.init("192.168.1.3", "255.255.255.0", "192.168.1.1"); 
-    // 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 out_buffer[] = "very important data";
-    
+    char buffer[300];
+    int ret;
     while (true) {
-        printf("Broadcasting...\n");
-        sock.sendTo(broadcast, out_buffer, sizeof(out_buffer));
-        Thread::wait(1000);
+        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);
     }
-#else
-    UDPSocket socket;
-    socket.bind(2015);
-    socket.set_broadcasting();
+      
+    sock.close();
     
-    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
-}
+    eth.disconnect();
+    
+    while(1) {} 
+}
\ No newline at end of file