4180 Ethernet Basic

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
nyengele
Date:
Wed Sep 14 20:06:27 2016 +0000
Commit message:
4180 Ethernet Basic

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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7e976d2fd636 EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Wed Sep 14 20:06:27 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
diff -r 000000000000 -r 7e976d2fd636 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 14 20:06:27 2016 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+int main()
+{
+    Serial pc(USBTX, USBRX);
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    pc.printf("IP Address is %s\n", eth.getIPAddress());
+
+    TCPSocketConnection sock;
+    sock.connect("mbed.org", 80);
+
+    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+
+    char buffer[300];
+    int ret;
+    while (true) {
+        ret = sock.receive(buffer, sizeof(buffer)-1);
+        if (ret <= 0)
+            break;
+        buffer[ret] = '\0';
+        pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }
+
+    sock.close();
+
+    eth.disconnect();
+
+    while(1) {}
+}
\ No newline at end of file
diff -r 000000000000 -r 7e976d2fd636 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Sep 14 20:06:27 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#f62a48e9da94
diff -r 000000000000 -r 7e976d2fd636 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 14 20:06:27 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file