Tracks GPS coordinates of an asset. Uses: GPS GSM Accelerometer mbed
Dependencies: mbed MODSERIAL ADXL345 MODGPS
SecurityMechanism.cpp@0:4415987ca08f, 2012-05-04 (annotated)
- Committer:
- gsulc
- Date:
- Fri May 04 14:11:45 2012 +0000
- Revision:
- 0:4415987ca08f
v0.5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gsulc | 0:4415987ca08f | 1 | #include "SecurityMechanism.h" |
gsulc | 0:4415987ca08f | 2 | #include "GPS.h" |
gsulc | 0:4415987ca08f | 3 | #include "sms.h" |
gsulc | 0:4415987ca08f | 4 | #include <string> |
gsulc | 0:4415987ca08f | 5 | |
gsulc | 0:4415987ca08f | 6 | extern Serial pc; |
gsulc | 0:4415987ca08f | 7 | extern GPS gps; |
gsulc | 0:4415987ca08f | 8 | extern DigitalOut gps_on; |
gsulc | 0:4415987ca08f | 9 | extern DigitalOut gps_xstandby; |
gsulc | 0:4415987ca08f | 10 | |
gsulc | 0:4415987ca08f | 11 | extern bool command_sent; |
gsulc | 0:4415987ca08f | 12 | extern bool movement_detected; |
gsulc | 0:4415987ca08f | 13 | extern string phoneNumber; |
gsulc | 0:4415987ca08f | 14 | |
gsulc | 0:4415987ca08f | 15 | |
gsulc | 0:4415987ca08f | 16 | /*void process_command (string command) { |
gsulc | 0:4415987ca08f | 17 | }//*/ |
gsulc | 0:4415987ca08f | 18 | |
gsulc | 0:4415987ca08f | 19 | /*void alert () { |
gsulc | 0:4415987ca08f | 20 | }//*/ |
gsulc | 0:4415987ca08f | 21 | |
gsulc | 0:4415987ca08f | 22 | void send_location () { |
gsulc | 0:4415987ca08f | 23 | //if gps off, turn it on |
gsulc | 0:4415987ca08f | 24 | if(gps_on == 0) { |
gsulc | 0:4415987ca08f | 25 | pc.printf("Turning on GPS\r\n"); |
gsulc | 0:4415987ca08f | 26 | gps_on = 1; |
gsulc | 0:4415987ca08f | 27 | gps_xstandby = 1; |
gsulc | 0:4415987ca08f | 28 | //wait to turn on |
gsulc | 0:4415987ca08f | 29 | wait(45); |
gsulc | 0:4415987ca08f | 30 | } |
gsulc | 0:4415987ca08f | 31 | //send coordinates |
gsulc | 0:4415987ca08f | 32 | char link[64]; |
gsulc | 0:4415987ca08f | 33 | gps.latitude(); |
gsulc | 0:4415987ca08f | 34 | gps.longitude(); |
gsulc | 0:4415987ca08f | 35 | sprintf(link, "%s", "http://maps.google.com/maps?daddr="); |
gsulc | 0:4415987ca08f | 36 | sprintf(link, "%s%.4f,%.4f", link, gps.latitude(), gps.longitude()); |
gsulc | 0:4415987ca08f | 37 | //pc.printf("%s\r\n", link); |
gsulc | 0:4415987ca08f | 38 | send_SMS(phoneNumber, link); |
gsulc | 0:4415987ca08f | 39 | } |