test

Dependencies:   GPS TextLCD mbed

Fork of GPS_classroom by Narongdet Phonphuak

Revision:
3:37086b58ab05
Parent:
2:8c0dcaa10883
Child:
4:41de6c2673f3
diff -r 8c0dcaa10883 -r 37086b58ab05 main.cpp
--- a/main.cpp	Sat May 23 04:27:29 2015 +0000
+++ b/main.cpp	Sat May 23 04:39:50 2015 +0000
@@ -60,7 +60,14 @@
     lcd.setAddress(0,0);
     lcd.printf("Initial GPS...\n");
     esp.printf("AT+RST\r\n");
-    
+    MBED_ASSERT(find_response("OK") == 0);
+    esp.printf("AT+CWMODE=1\r\n");
+    MBED_ASSERT(find_response("OK") == 0);
+    esp.printf("AT+CWJAP=\"%s\",\"%s\"\r\n","Fookies-One(m8)","12312344");
+    wait(5);
+    MBED_ASSERT(find_response("OK") == 0); 
+    esp.printf("AT+CIPMUX=0\r\n");
+    MBED_ASSERT(find_response("OK") == 0); 
     while(1){
         if(gps.sample())
         {
@@ -68,6 +75,21 @@
             lcd.printf("%6.3f,%7.3f",gps.latitude,gps.longitude);
         }
         wait(0.5);
+        if(bt==1)
+        {
+            sprintf(message,"GET /apps/thingtweet/1/statuses/update?key=T5M60A23PDCU6NIH&status=%.3f,%.3f",gps.latitude,gps.longitude);
+            esp.printf("AT+CIPSTART=\"TCP\",\"%s\",%s\r\n","184.106.153.149","80");
+            esp.printf("AT+CIPSEND=0,%d\r\n",strlen(message));
+            if(find_response(">") == 0) 
+            {
+                esp.printf(message);
+            }
+            wait(2);  
+            flush_fifo();
+            esp.printf("AT+CIPCLOSE\r\n");
+            wait(0.5);  
+            flush_fifo();
+        }
     }
 }    
             
\ No newline at end of file