Prototyping the Adaptable Emergency System on an C027 board.

Dependencies:   C027_Support mbed

Fork of c027_prototyping by Philémon Favrod

Files at this revision

API Documentation at this revision

Comitter:
aroulin
Date:
Tue Sep 30 16:06:35 2014 +0000
Parent:
2:0eb41327c023
Parent:
3:12e1c2c71cf2
Child:
5:6d0cdd715100
Child:
7:eeef6f9fa1db
Commit message:
Merge GPS Locate and SMS features

Changed in this revision

cell_locate.cpp Show diff for this revision Revisions of this file
cell_locate.h Show diff for this revision Revisions of this file
gps_locate.c Show diff for this revision Revisions of this file
gps_locate.cpp Show annotated file Show diff for this revision Revisions of this file
gps_locate.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
sms_lib.c Show diff for this revision Revisions of this file
sms_lib.cpp Show annotated file Show diff for this revision Revisions of this file
sms_lib.h Show annotated file Show diff for this revision Revisions of this file
--- a/cell_locate.cpp	Tue Sep 30 15:34:10 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-#include "cell_locate.h"
-
-#include "MDM.h"
-
-int cell_locate_init(void)
-{
-    
-}
-
-int cell_locate(cell_locate_data_t *cell_locate_data)
-{
-        
-    return 0;
-}
\ No newline at end of file
--- a/cell_locate.h	Tue Sep 30 15:34:10 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-
-#ifndef __CELL_LOCATE_H__
-#define __CELL_LOCATE_H__
-
-struct cell_locate_data_t {
-    float latitude;
-    float longitude;
-};
-
-int cell_locate(cell_locate_data_t *cell_locate_data);
-
-#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gps_locate.cpp	Tue Sep 30 16:06:35 2014 +0000
@@ -0,0 +1,46 @@
+#include "gps_locate.h"
+#include "GPS.h"
+
+int gps_on(void)
+{
+    return 0;
+}
+
+int gps_off(void)
+{
+    return 0;
+}
+
+int gps_locate(struct gps_data_t* gps_data)
+{/*
+    // Power on gps
+    GPSI2C gps;
+
+    int ret = 0;
+    char buf[512] = {0};
+
+    while ((ret = gps.getMessage(buf, sizeof(buf))) > 0) {
+        int len = LENGTH(ret);
+        if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6)) {
+            if (!strncmp("$GPGLL", buf, 6)) {
+                double la = 0, lo = 0;
+                char ch;
+                if (gps.getNmeaAngle(1,buf,len,la) &&
+                        gps.getNmeaAngle(3,buf,len,lo) &&
+                        gps.getNmeaItem(6,buf,len,ch) && ch == 'A') {
+                    printf("GPS Location: %.5f %.5f\r\n", la, lo);
+                    printf(link, "I am here!\n"
+                            "https://maps.google.com/?q=%.5f,%.5f", la, lo);     
+                }
+            } else if (!strncmp("$GPGGA", buf, 6)) {
+                double a = 0;
+                if (gps.getNmeaItem(9,buf,len,a)) // altitude msl [m]
+                    printf("GPS Altitude: %.1f\r\n", a);
+            } else if (!strncmp("$GPVTG", buf, 6)) {
+                double s = 0;
+                if (gps.getNmeaItem(7,buf,len,s)) // speed [km/h]
+                    printf("GPS Speed: %.1f\r\n", s);
+            }
+        }
+    }*/ return 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gps_locate.h	Tue Sep 30 16:06:35 2014 +0000
@@ -0,0 +1,17 @@
+#ifndef __GPS_LOCATE_H__
+#define __GPS_LOCATE_H__
+
+struct gps_data_t {
+    double la;
+    double lo;
+    double altitude;
+    double speed;
+} gps_data_t; 
+
+int gps_on(void);
+
+int gps_off(void);
+
+int gps_locate(struct gps_data_t* gps_data);
+
+#endif
\ No newline at end of file
--- a/main.cpp	Tue Sep 30 15:34:10 2014 +0000
+++ b/main.cpp	Tue Sep 30 16:06:35 2014 +0000
@@ -1,27 +1,8 @@
 #include "mbed.h"
-#include "MDM.h"
-
-DigitalOut myled(LED); 
-
+#include "sms_lib.h"
 
 int main() {
-    MDMSerial mdm;
-    
-    MDMParser::DevStatus devStatus = {};
-    
-    bool mdmOk = mdm.init("5554", &devStatus);
-    mdm.dumpDevStatus(&devStatus);
-    
-    if (!mdmOk) {
-        printf("ERROR");
-    }
-    
-    mdm.sendFormated("AT+ULOCCELL=0");
-    if (RESP_OK == mdm.waitFinalResp()) {
-        printf("Receive OK");
-    } else {
-        printf("Does not receive OK");
-    }
-    
+    printf("Hello");
+    init_sms_features();
     return 0;
 }
--- a/sms_lib.c	Tue Sep 30 15:34:10 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#include "mbed.h"
-#include "MDM.h"
-
-#include "sms_lib.h"
-
-static MDMSerial mdm;
-
-int init_sms_features(void)
-{
-    static const char *SIMPIN = "5554";
-    
-    MDMParser::DevStatus devStatus = {};
-    MDMParser::NetStatus netStatus = {};
-    bool mdmOk = mdm.init(SIMPIN, &devStatus);
-    mdm.dumpDevStatus(&devStatus);
-    
-    if (mdmOk) {
-        mdmOk = mdm.registerNet(&netStatus);
-        mdm.dumpNetStatus(&netStatus);
-    }
-    
-    if (mdmOk) {
-        myled = 1;
-        wait(1);
-        myled = 0;
-        if (mdm.smsSend("+41763211792", "Salut toi!")) {
-            c027_mdm_powerOff();
-            while (1) {
-                myled = 1;
-            }
-        } else {
-            while (1) {
-                myled = !myled;
-                wait(1);
-            }
-        }
-        
-    } else {
-        while (1) {
-            myled = !myled;
-            wait(0.2);
-        }
-    }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sms_lib.cpp	Tue Sep 30 16:06:35 2014 +0000
@@ -0,0 +1,43 @@
+#include "MDM.h"
+
+#include "sms_lib.h"
+
+DigitalOut myled(LED);
+
+int init_sms_features(void)
+{
+    MDMSerial mdm;
+    static const char *SIMPIN = "5554";
+    
+    MDMParser::DevStatus devStatus = {};
+    MDMParser::NetStatus netStatus = {};
+    bool mdmOk = mdm.init(SIMPIN, &devStatus);
+    mdm.dumpDevStatus(&devStatus);
+    
+    if (mdmOk) {
+        mdmOk = mdm.registerNet(&netStatus);
+        mdm.dumpNetStatus(&netStatus);
+    }
+    
+    if (mdmOk) {
+        myled = 1;
+        wait(1);
+        myled = 0;
+        if (mdm.smsSend("+41763211792", "Salut toi!")) {
+            while (1) {
+                myled = 1;
+            }
+        } else {
+            while (1) {
+                myled = !myled;
+                wait(1);
+            }
+        }
+        
+    } else {
+        while (1) {
+            myled = !myled;
+            wait(0.2);
+        }
+    }
+}
\ No newline at end of file
--- a/sms_lib.h	Tue Sep 30 15:34:10 2014 +0000
+++ b/sms_lib.h	Tue Sep 30 16:06:35 2014 +0000
@@ -9,4 +9,4 @@
 int init_sms_features(void);
 
 
-#endif __SMS_LIB_H__
\ No newline at end of file
+#endif
\ No newline at end of file