test

Dependencies:   C027 HTTPClient UbloxUSBModem mbed

Fork of C027_HTTPClientTest by u-blox

Revision:
11:ab536fc3a722
Parent:
10:e2315bcdd7be
Child:
13:bcdb607b2c76
--- a/main.cpp	Wed Nov 06 10:49:08 2013 +0000
+++ b/main.cpp	Wed Feb 19 16:10:01 2014 +0000
@@ -1,20 +1,22 @@
 #include "mbed.h"
 #include "C027.h"
 #include "UbloxUSBGSMModem.h"
-#include "UbloxUSBCDMAModem.h"
 
 #include "HTTPClient.h"
 
 C027 c027;
 
-void test(void const*)
+int main(void)
 {
-    c027.mdmPower(true);
+     c027.mdmWakeup();
+     c027.mdmReset();
+     c027.mdmPower(true);
     UbloxUSBGSMModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
     HTTPClient http;
     char str[512];
 
-    int ret = modem.connect("internet"); // eventaully set another apn here
+    puts("Trying to connect to modem...");
+    int ret = modem.connect("public4.m2minternet.com"); // eventaully set another apn here
     if(ret)
     {
         printf("Could not connect %d\n", ret);
@@ -23,7 +25,7 @@
     
     //GET data
     printf("Trying to fetch page...\n");
-    ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
+    ret = http.get("http://nocore.info:8888/", str, 128);
     if (!ret) {
         printf("Page fetched successfully - read %d characters\n", strlen(str));
         printf("Result: %s\n", str);
@@ -32,12 +34,11 @@
     }
 
     //POST data
-    HTTPMap map;
     HTTPText text(str, 512);
-    map.put("Hello", "World");
-    map.put("test", "1234");
+    HTTPText data("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
+    //HTTPText data("23123123lala");
     printf("Trying to post data...\n");
-    ret = http.post("http://httpbin.org/post", map, &text);
+    ret = http.post("http://nocore.info:8888/", data, &text);
     if (!ret) {
         printf("Executed POST successfully - read %d characters\n", strlen(str));
         printf("Result: %s\n", str);
@@ -48,19 +49,5 @@
     modem.disconnect();
     c027.mdmPower(false);
     
-    while(1) {
-    }
-}
-
-
-int main()
-{
-    Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
-    DigitalOut led(LED); // on rev A you should reasign the signal to A0
-    while(1) {
-        led=!led;
-        Thread::wait(1000);
-    }
-
     return 0;
 }