test ethernet

Dependencies:   EthernetInterface HTTPClient MbedJSONValue mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
Sytten
Date:
Fri Oct 20 18:34:54 2017 +0000
Commit message:
init

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
MbedJSONValue.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/EthernetInterface.lib	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/EthernetInterface/#183490eb1b4a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/HTTPClient/#cca5d89e6a2b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedJSONValue.lib	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/samux/code/MbedJSONValue/#10a99cdf7846
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "HTTPClient.h"
+ 
+int main() {
+    // Ethernet setup
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    
+    // Http client
+    HTTPClient http;
+    int i = 0;
+    while(i < 100) {
+        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';
+            printf("Received %d chars from server:\n%s\n", ret, buffer);
+        }
+          
+        sock.close();
+        i++;
+        wait(1);
+    }
+    
+    eth.disconnect();
+    
+    while(1) {}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed-rtos/#5713cbbdb706
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 20 18:34:54 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/675da3299148
\ No newline at end of file