1000char test

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Revision:
4:f99718565897
Parent:
3:2d0c5df8d3ec
--- a/main.cpp	Tue Mar 08 00:42:54 2016 +0000
+++ b/main.cpp	Tue Mar 08 06:19:53 2016 +0000
@@ -4,7 +4,6 @@
 
 EthernetInterface eth;
 HTTPClient http;
-char str[512];
 
 int main() 
 {
@@ -12,6 +11,13 @@
 
     eth.connect();
     
+    int a = 1;
+    
+    char str[4096];
+
+    
+     int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 4096);
+    /*
     //GET data
     printf("\nTrying to fetch page...\n");
     int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
@@ -23,19 +29,21 @@
     else
     {
       printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
+    }*/
     
     //POST data
     HTTPMap map;
-    HTTPText inText(str, 512);
-    map.put("data", "{\"ts\":1457348930,\"dv\":\"JulianTestSensor\",\"s00\":[94,-384,4138]}");
-    //map.put("data", "{\"ts\":1457071217,\"dv\":\"JulianTestSensor\",\"s00\":[140,-357,4142],\"s01\":[134,-354,4127],\"s02\":[140,-355,4136],\"s03\":[128,-354,4103],\"s04\":[137,-359,4184],\"s05\":[133,-357,4099],\"s06\":[139,-355,4116],\"s07\":[142,-348,4157],\"s08\":[137,-356,4131],\"s09\":[135,-355,4120],\"s10\":[138,-355,4123],\"s11\":[143,-349,4145],\"s12\":[141,-357,4121]}");
-    //map.put("data", "{\"ts\":1457071217,\"dv\":\"JulianTestSensor\",\"s00\":[140,-357,4142],\"s01\":[134,-354,4127],\"s02\":[140,-355,4136],\"s03\":[128,-354,4103],\"s04\":[137,-359,4184],\"s05\":[133,-357,4099],\"s06\":[139,-355,4116],\"s07\":[142,-348,4157],\"s08\":[137,-356,4131],\"s09\":[135,-355,4120],\"s10\":[138,-355,4123],\"s11\":[143,-349,4145],\"s12\":[141,-357,4121],\"s13\":[136,-353,4114],\"s14\":[142,-354,4158],\"s15\":[137,-355,4109],\"s16\":[138,-356,4144],\"s17\":[139,-357,4116],\"s18\":[136,-358,4137],\"s19\":[136,-356,4145],\"s20\":[136,-354,4133],\"s21\":[136,-358,4135],\"s22\":[139,-351,4130],\"s23\":[136,-361,4144],\"s24\":[136,-359,4131]}");
+    HTTPText inText(str, 1024);
+    map.put("data", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345");
+    //map.put("data", "{\"ts\":1457348930,\"dv\":\"karlotest1\",\"s00\":[94,-384,4138]}");
+    //map.put("data", "{\"ts\":1457071217,\"dv\":\"karlotest2a\",\"s00\":[140,-357,4142],\"s01\":[134,-354,4127],\"s02\":[140,-355,4136],\"s03\":[128,-354,4103],\"s04\":[137,-359,4184],\"s05\":[133,-357,4099],\"s06\":[139,-355,4116],\"s07\":[142,-348,4157],\"s08\":[137,-356,4131],\"s09\":[135,-355,4120],\"s10\":[138,-355,4123],\"s11\":[143,-349,4145],\"s12\":[141,-357,4121]}");
+    //map.put("data", "{\"ts\":1457071217,\"dv\":\"karlotest2b\",\"s00\":[140,-357,4142],\"s01\":[134,-354,4127],\"s02\":[140,-355,4136],\"s03\":[128,-354,4103],\"s04\":[137,-359,4184],\"s05\":[133,-357,4099],\"s06\":[139,-355,4116],\"s07\":[142,-348,4157],\"s08\":[137,-356,4131],\"s09\":[135,-355,4120],\"s10\":[138,-355,4123],\"s11\":[143,-349,4145],\"s12\":[141,-357,4121],\"s13\":[136,-353,4114],\"s14\":[142,-354,4158],\"s15\":[137,-355,4109],\"s16\":[138,-356,4144],\"s17\":[139,-357,4116],\"s18\":[136,-358,4137],\"s19\":[136,-356,4145],\"s20\":[136,-354,4133],\"s21\":[136,-358,4135],\"s22\":[139,-351,4130],\"s23\":[136,-361,4144],\"s24\":[136,-359,4131]}");
     //map.put("hello", "world");
     //map.put("test", "1234");
     printf("\nTrying to post data...\n");
     //ret = http.post("http://httpbin.org/post", map, &inText);
-    ret = http.post("http://catcher.sensoresmx.info/", map, &inText);
+    while(a<100001){
+    ret = http.post("http://catcher.sensoresmx.info/index2.php", map, &inText);
     if (!ret)
     {
       printf("Executed POST successfully - read %d characters\n", strlen(str));
@@ -45,7 +53,9 @@
     {
       printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
     }
-    
+    a++;
+    }
+    /*
     //PUT data
     strcpy(str, "This is a PUT test!");
     HTTPText outText(str);
@@ -61,10 +71,11 @@
     {
       printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
     }
+    */
     
     //DELETE data
     //HTTPText inText(str, 512);
-    printf("\nTrying to delete resource...\n");
+   /* printf("\nTrying to delete resource...\n");
     ret = http.del("http://httpbin.org/delete", &inText);
     if (!ret)
     {
@@ -74,10 +85,10 @@
     else
     {
       printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
+    }*/
     
     eth.disconnect();  
 
-    while(1) {
-    }
+    /*while(1) {
+    }*/
 }