Prototyping the Adaptable Emergency System on an C027 board.
Dependencies: C027_Support mbed
Fork of c027_prototyping by
main.cpp@16:2b2f2a3bde5a, 2014-10-01 (annotated)
- Committer:
- aroulin
- Date:
- Wed Oct 01 08:47:54 2014 +0000
- Revision:
- 16:2b2f2a3bde5a
- Parent:
- 15:41e3e4613e34
- Child:
- 17:726bbc1b73ee
Adds some timers to timeout GPS test and receive SMS test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
philemonf | 0:164fb9518d1a | 1 | #include "mbed.h" |
aroulin | 7:eeef6f9fa1db | 2 | #include "gps_locate.h" |
aroulin | 13:3c1f0b8c1d21 | 3 | #include "sms_lib.h" |
philemonf | 11:5354c4819b25 | 4 | #include "MDM.h" |
philemonf | 1:23ffa0e091bc | 5 | |
philemonf | 0:164fb9518d1a | 6 | int main() { |
aroulin | 16:2b2f2a3bde5a | 7 | |
aroulin | 16:2b2f2a3bde5a | 8 | Timer programTimer; |
aroulin | 16:2b2f2a3bde5a | 9 | |
aroulin | 16:2b2f2a3bde5a | 10 | programTimer.start(); |
aroulin | 7:eeef6f9fa1db | 11 | struct gps_data_t gps_data; |
aroulin | 16:2b2f2a3bde5a | 12 | if(gps_locate(&gps_data)) { |
aroulin | 16:2b2f2a3bde5a | 13 | printf("Hello here is the position: "); |
aroulin | 16:2b2f2a3bde5a | 14 | printf("https://maps.google.com/?q=%.5f,%.5f\r\n", gps_data.la, gps_data.lo); |
aroulin | 16:2b2f2a3bde5a | 15 | } |
aroulin | 13:3c1f0b8c1d21 | 16 | |
aroulin | 14:d1f114749b3c | 17 | MDMSerial mdm; |
aroulin | 14:d1f114749b3c | 18 | init_sms_features(&mdm); |
aroulin | 15:41e3e4613e34 | 19 | |
aroulin | 13:3c1f0b8c1d21 | 20 | struct sms_data_t sms; |
aroulin | 16:2b2f2a3bde5a | 21 | sms.phone_num = "+41763211792"; |
aroulin | 13:3c1f0b8c1d21 | 22 | sms.msg_buf = "Je suis une carte u-blox. Tu veux etre mon ami ?"; |
aroulin | 16:2b2f2a3bde5a | 23 | printf("Now I will send a SMS\r\n"); |
aroulin | 13:3c1f0b8c1d21 | 24 | send_sms(&sms); |
aroulin | 13:3c1f0b8c1d21 | 25 | |
aroulin | 16:2b2f2a3bde5a | 26 | printf("And then wait to receive one\r\n"); |
aroulin | 14:d1f114749b3c | 27 | char buf1[32]; |
aroulin | 14:d1f114749b3c | 28 | char buf2[256]; |
aroulin | 14:d1f114749b3c | 29 | sms.phone_num = buf1; |
aroulin | 14:d1f114749b3c | 30 | sms.msg_buf = buf2; |
aroulin | 16:2b2f2a3bde5a | 31 | Timer smsTimer; |
aroulin | 16:2b2f2a3bde5a | 32 | smsTimer.start(); |
aroulin | 16:2b2f2a3bde5a | 33 | while(smsTimer.read() < 40) { |
aroulin | 16:2b2f2a3bde5a | 34 | if(read_sms(&sms)) { |
aroulin | 16:2b2f2a3bde5a | 35 | printf("Received sms from %s:\r\n%s\r\n", sms.phone_num, sms.msg_buf); |
aroulin | 16:2b2f2a3bde5a | 36 | break; |
aroulin | 16:2b2f2a3bde5a | 37 | } |
aroulin | 16:2b2f2a3bde5a | 38 | } |
aroulin | 16:2b2f2a3bde5a | 39 | |
aroulin | 16:2b2f2a3bde5a | 40 | programTimer.stop(); |
aroulin | 16:2b2f2a3bde5a | 41 | printf("Program time: %f seconds\r\n", programTimer.read()); |
philemonf | 1:23ffa0e091bc | 42 | return 0; |
aroulin | 14:d1f114749b3c | 43 | } |