http client example

Dependencies:   C027_Support HTTPClient mbed

Fork of HTTPClient_HelloWorld by Donatien Garnier

Revision:
7:b14d0f112a73
Parent:
6:6ff6061a0f76
Child:
8:eea979594a37
--- a/main.cpp	Tue May 27 09:17:49 2014 +0000
+++ b/main.cpp	Fri Jun 06 15:18:36 2014 +0000
@@ -11,7 +11,7 @@
 /*! The APN of your network operator SIM, sometimes it is "internet" check your 
     contract with the network operator. You can also try to look-up your settings in 
     google: https://www.google.de/search?q=APN+list */
-#define APN         "gprs.swisscom.ch"
+#define APN         NULL
 //! Set the user name for your APN, or NULL if not needed
 #define USERNAME    NULL
 //! Set the password for your APN, or NULL if not needed
@@ -24,11 +24,33 @@
 {
     // turn on the supplies of the Modem
     MDMSerial mdm;
-    //mdm.setDebug(4); // enable this for debugging issues 
+    mdm.setDebug(4); // enable this for debugging issues 
     if (!mdm.connect(SIMPIN, APN,USERNAME,PASSWORD))
         return -1;
-    
     HTTPClient http;
+    {
+        char urlString[100] = "http://192.38.36.13/hanshenrik/GPRS/gprs.php?mode=";
+        char url[200];
+        char databuffer[100];
+        strcpy (url,urlString);
+        int id = 10;
+        float la = 10.0, lo = 20.0;
+        float pres = 30.0, temp = 40.0, o3 = 50.0;
+        int co2 = 200;
+        //sprintf(databuffer, "latitude&id=%d&data=%.5f", id, la); //This is a short URL that works!
+        sprintf(databuffer, "update&id=%d&lat=%.1f&lng=%.1f&pres=%.1f&temp=%.1f&co2=%d&o3=%.1f",id,la,lo,pres,temp,co2,o3);
+        printf("URL string: \"%s\"\r\n", url);
+        wait_ms(1000);
+        strcat(url, databuffer);
+        wait_ms(1000);
+        printf("URL string: \"%s\"\r\n", url);
+        wait_ms(1000);
+        int ret = http.get(url, str, 128);
+        wait_ms(1000);
+        printf("%d \"%s\"\r\n", ret, str);
+        wait_ms(1000);
+        while (1);
+    }       
     
     //GET data
     printf("\nTrying to fetch page...\n");