Prototyping the Adaptable Emergency System on an C027 board.

Dependencies:   C027_Support mbed

Fork of c027_prototyping by Philémon Favrod

main.cpp

Committer:
aroulin
Date:
2014-10-01
Revision:
16:2b2f2a3bde5a
Parent:
15:41e3e4613e34
Child:
17:726bbc1b73ee

File content as of revision 16:2b2f2a3bde5a:

#include "mbed.h"
#include "gps_locate.h"
#include "sms_lib.h"
#include "MDM.h"

int main() {
    
    Timer programTimer;
    
    programTimer.start();
    struct gps_data_t gps_data;
    if(gps_locate(&gps_data)) {
        printf("Hello here is the position: ");
        printf("https://maps.google.com/?q=%.5f,%.5f\r\n", gps_data.la, gps_data.lo);
    }
    
    MDMSerial mdm;
    init_sms_features(&mdm);

    struct sms_data_t sms; 
    sms.phone_num = "+41763211792";
    sms.msg_buf = "Je suis une carte u-blox. Tu veux etre mon ami ?";
    printf("Now I will send a SMS\r\n");
    send_sms(&sms);
    
    printf("And then wait to receive one\r\n");
    char buf1[32];
    char buf2[256];
    sms.phone_num = buf1;
    sms.msg_buf = buf2;
    Timer smsTimer;
    smsTimer.start();
    while(smsTimer.read() < 40) {
        if(read_sms(&sms)) {
            printf("Received sms from %s:\r\n%s\r\n", sms.phone_num, sms.msg_buf);
            break;
        }
    } 
    
    programTimer.stop();
    printf("Program time: %f seconds\r\n", programTimer.read());
    return 0;
}