Example Get requests using Ethernet

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
ndaniel7
Date:
Tue Dec 08 00:10:57 2015 +0000
Parent:
16:0a1035af04b4
Commit message:
Added example

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0a1035af04b4 -r 46186f7da7eb main.cpp
--- a/main.cpp	Mon Dec 07 21:27:52 2015 +0000
+++ b/main.cpp	Tue Dec 08 00:10:57 2015 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include <string>
 
 Serial pc(USBTX,USBRX);
 
@@ -35,6 +36,8 @@
     //Instead of printing here, do what you did before to convert the string, and just append buffer to a string (below the break),
     //    replacing pc.printf
     //Then we can do string find to snipe the values we want (have to do math to grab the right amount)
+    //Implemented example here, testStr now holds the received text (so you can search it)
+    string testStr = "";
     char buffer[600];
     int ret;
     while (true) {
@@ -43,8 +46,10 @@
             break;
         buffer[ret] = '\0';
         pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
+        string conv(buffer);
+        testStr = testStr + conv;
     }
-      
+    pc.printf("Stringified %s\n", testStr);
     sock.close();
     wait(0.2);
     sock.connect("192.184.82.3", 5000);