Tracks GPS coordinates of an asset. Uses: GPS GSM Accelerometer mbed

Dependencies:   mbed MODSERIAL ADXL345 MODGPS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SecurityMechanism.cpp Source File

SecurityMechanism.cpp

00001 #include "SecurityMechanism.h"
00002 #include "GPS.h"
00003 #include "sms.h"
00004 #include <string>
00005 
00006 extern Serial pc;
00007 extern GPS gps;
00008 extern DigitalOut gps_on;
00009 extern DigitalOut gps_xstandby;
00010 
00011 extern bool command_sent;
00012 extern bool movement_detected;
00013 extern string phoneNumber;
00014 
00015 
00016 /*void process_command (string command) {
00017 }//*/
00018 
00019 /*void alert () {
00020 }//*/
00021 
00022 void send_location () {
00023     //if gps off, turn it on
00024     if(gps_on == 0) {
00025         pc.printf("Turning on GPS\r\n");
00026         gps_on = 1;
00027         gps_xstandby = 1;
00028         //wait to turn on
00029         wait(45);
00030     }
00031     //send coordinates
00032     char link[64];
00033     gps.latitude();
00034     gps.longitude();
00035     sprintf(link, "%s", "http://maps.google.com/maps?daddr=");
00036     sprintf(link, "%s%.4f,%.4f", link, gps.latitude(), gps.longitude());
00037     //pc.printf("%s\r\n", link);
00038     send_SMS(phoneNumber, link);
00039 }