Sam Clarke / Mbed 2 deprecated GPS-GPRS_Tracker

Dependencies:   GPS MODSERIAL mbed-rtos mbed

Revision:
9:bec6e8f731f2
Parent:
8:d4773b6449c5
Child:
10:059cde049cd6
diff -r d4773b6449c5 -r bec6e8f731f2 main.cpp
--- a/main.cpp	Tue Oct 09 06:37:57 2012 +0000
+++ b/main.cpp	Tue Oct 09 18:48:48 2012 +0000
@@ -3,16 +3,14 @@
 #include "rtos.h"
 #include "MODSERIAL.h"
 #include <string>
-#include <iostream>
 
 using namespace std;
 
-const string GoogleChunk = "http://maps.google.com/maps?q=";
+const string GoogleChunk = "https://maps.google.com.au/maps?q=";
 const string GoogleExtras = "&z=20";
 char GPRSbuffer[512];
 char NUMBER[11];
 char MESSAGE[5];
-string dump;
 int index;
 long int number;
 int i = 0;
@@ -53,7 +51,13 @@
     GPRS.printf("AT+CMGS=\"+%s\"\r\n", NUMBER);
     wait(1);
     // Write out the GPS data in a message
-    GPRS.printf("Time: %4.2f \nAltitude: %3.2fm\nSpeed: %3.2f Kn\nHeading: %3.2f Deg\nValidity: %c\nFix: %s\nSatellites: %d", gps.time, gps.altitude, gps.speed, gps.heading,gps.validity,gps.fixtype,gps.satellites);
+    GPRS.printf("Time: %4.2f \nAltitude: %3.2fm\nSpeed: %3.2f Kn\nHeading: %3.2f Deg\nValidity: %c\nSatellites: %d\nFix code: %d \nFix: ", gps.time, gps.altitude, gps.speed, gps.heading, gps.validity, gps.satellites, gps.fixtype);
+    if(gps.fixtype == 1) {
+        GPRS.printf("Positive");
+    }
+    if(gps.fixtype == 2) {
+        GPRS.printf("Differential");
+    }
     wait(1);
     // Send it...
     GPRS.putc(0x1A);
@@ -82,11 +86,10 @@
         i++;
     }
     // Uncomment the following to debug
-    //pc.printf("\nbuffer = %s", GPRSbuffer);
+    pc.printf("\nbuffer = %s", GPRSbuffer);
 
     // If we get an SMS notification....
     if (sscanf(GPRSbuffer, "$$+CMTI: \"SM\",%d", &index)>0) {
-        i=0;
         pc.printf("\nSMS recieved @ index [%d]", index);
         memset(GPRSbuffer, '0', 512);
         i = 0;
@@ -95,14 +98,13 @@
     }
 
     if (strncmp(GPRSbuffer, "$$+CMGR",7) == 0 ) {
-    for (int k = 24; k < 35; k++) {
+        for (int k = 24; k < 35; k++) {
             NUMBER[k-24] = GPRSbuffer[k];
         }
         for (int k = 64; k < 68; k++) {
             MESSAGE[k-64] = GPRSbuffer[k];
         }
         sendSms();
-        //wait(4);
         // Reset the GPRS buffer
         memset(GPRSbuffer, '0', 512);
         // Reset the char counter
@@ -117,16 +119,12 @@
     }
 
     if (strncmp(GPRSbuffer, "$$RING",6) == 0) {
-    //dump = "fixed";
-    GPRS.printf("ATH0\r\n");
-        wait(1);
+        GPRS.printf("ATH0\r\n");
         // Flush any incoming rings in the MODSERIAL buffer
         GPRS.rxBufferFlush();
         pc.printf("\nCall recieved");
         // Do the send SMS routine...
         sendSms();
-        // Wait for the cascade of [\r\nOK\r\n][\r\nOK\r\n]'s from the SMS's to finish
-        //wait(4);
         // Flush out any left in the serial buffer
         GPRS.rxBufferFlush();
         // Reset the GPRS buffer
@@ -134,14 +132,13 @@
         // Reset the char counter
         i = 0;
     }
-
+    pc.printf("\nWaiting for SMS or call...\n");
+    pc.printf("\nThe last number was :+%s", NUMBER);
+    pc.printf("\nThe last message was :%s", MESSAGE);
     // Reset the GPRS buffer
     memset(GPRSbuffer, '0', 512);
     // Reset the char counter
     i = 0;
-    pc.printf("\nWaiting for SMS or call...\n");
-    pc.printf("\nThe last number was :+%s", NUMBER);
-    pc.printf("\nThe last message was :%s", MESSAGE);
 }
 
 int main()
@@ -150,17 +147,17 @@
     GPRS.baud(19200);
     Thread thread(led_thread);
     memset(GPRSbuffer, '0', 512);
-    pc.printf("I'm Alive...\n");
+    pc.printf("\nI'm Alive...\n");
     // Setup the GPS
     gps.Init();
     // Set the GPRS AT echo off
     GPRS.printf("ATE0\r\n");
-    pc.printf("GPRS Echo OFF\n");
+    pc.printf("\nGPRS echo [OFF]\n");
     wait(1);
     // Delete all messages on the sim card
     GPRS.printf("AT+CMGDA=\"DEL ALL\"\r\n");
     wait(1);
-    pc.printf("Messages Cleared...\n");
+    pc.printf("\nMessages Cleared...\n");
     wait(1);
     // Flush out any \r\nOK\r\n's
     GPRS.rxBufferFlush();