works through pushing box to log data to google spreadsheet
Dependencies: MBed_Adafruit-GPS-Library SDFileSystem mbed
Fork of GPR_Interface by
GSMLibrary.h@11:045cb766d9a5, 2015-10-21 (annotated)
- Committer:
- DeWayneDennis
- Date:
- Wed Oct 21 19:41:42 2015 +0000
- Revision:
- 11:045cb766d9a5
Changed GPR Interface to work with pushingbox
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DeWayneDennis | 11:045cb766d9a5 | 1 | #ifndef GSMLIBRARY_H |
DeWayneDennis | 11:045cb766d9a5 | 2 | #define GSMLIBRARY_H |
DeWayneDennis | 11:045cb766d9a5 | 3 | |
DeWayneDennis | 11:045cb766d9a5 | 4 | #include "mbed.h" |
DeWayneDennis | 11:045cb766d9a5 | 5 | |
DeWayneDennis | 11:045cb766d9a5 | 6 | #define TIME_CONST 1 //Specify length of each GSM tick (currently 1 seconds in our debugger) |
DeWayneDennis | 11:045cb766d9a5 | 7 | #define SECONDS_TIMEOUT 30 |
DeWayneDennis | 11:045cb766d9a5 | 8 | #define SMS_END_CHAR "\x1A" //Character that must be appended to end of text message before it will be sent |
DeWayneDennis | 11:045cb766d9a5 | 9 | #define SMS_ESCAPE_CHAR "\x1A" //Character that can be appended to end of text message to abort sending it |
DeWayneDennis | 11:045cb766d9a5 | 10 | |
DeWayneDennis | 11:045cb766d9a5 | 11 | enum gsm_states{GSM_INITIALIZE, |
DeWayneDennis | 11:045cb766d9a5 | 12 | GSM_AT_OK, //Make sure communication is established with GSM |
DeWayneDennis | 11:045cb766d9a5 | 13 | GSM_AT_CSQ, //Check signal strength |
DeWayneDennis | 11:045cb766d9a5 | 14 | GSM_AT_CREG, //Check if phone is connected to network |
DeWayneDennis | 11:045cb766d9a5 | 15 | GSM_AT_CNMI, //Turn off incoming SMS notifications |
DeWayneDennis | 11:045cb766d9a5 | 16 | GSM_AT_CMGF, //Change to text message mode |
DeWayneDennis | 11:045cb766d9a5 | 17 | GSM_READ_MSG, //Check for new messages. |
DeWayneDennis | 11:045cb766d9a5 | 18 | GSM_AT_CMGS, //Input phone number and indicate beginning of SMS message body |
DeWayneDennis | 11:045cb766d9a5 | 19 | GSM_AT_SENDSMS, //Write message, finish with SMS_END_CHAR |
DeWayneDennis | 11:045cb766d9a5 | 20 | GSM_DEL_R_MSGS //Delete unread messages (if present) |
DeWayneDennis | 11:045cb766d9a5 | 21 | }; |
DeWayneDennis | 11:045cb766d9a5 | 22 | |
DeWayneDennis | 11:045cb766d9a5 | 23 | //GSM state machine |
DeWayneDennis | 11:045cb766d9a5 | 24 | void gsm_tick(); |
DeWayneDennis | 11:045cb766d9a5 | 25 | bool gsm_timeOut(); |
DeWayneDennis | 11:045cb766d9a5 | 26 | void gsm_printState(); |
DeWayneDennis | 11:045cb766d9a5 | 27 | void gsm_nextStateLogic(); |
DeWayneDennis | 11:045cb766d9a5 | 28 | void gsm_mealyOutputs(); |
DeWayneDennis | 11:045cb766d9a5 | 29 | |
DeWayneDennis | 11:045cb766d9a5 | 30 | //Initialize DMA data transfer, and UART3. |
DeWayneDennis | 11:045cb766d9a5 | 31 | void gsm_initialize(); |
DeWayneDennis | 11:045cb766d9a5 | 32 | |
DeWayneDennis | 11:045cb766d9a5 | 33 | //returns 1 for ready to send again, 0 for busy. |
DeWayneDennis | 11:045cb766d9a5 | 34 | bool gsm_ready(); |
DeWayneDennis | 11:045cb766d9a5 | 35 | |
DeWayneDennis | 11:045cb766d9a5 | 36 | //Have the GSM send data - L = long, S = short, hh/mm/ss for time, "lat ns" for latitute, "lon we" for longitude |
DeWayneDennis | 11:045cb766d9a5 | 37 | void gsm_send_data(float L, float Lref, float S, float Sref, int hh, int mm, int ss, float lat, char ns, float lon, char we); |
DeWayneDennis | 11:045cb766d9a5 | 38 | |
DeWayneDennis | 11:045cb766d9a5 | 39 | //Brings state machine back to initialize state (notice this is a bit different than the initialize function) |
DeWayneDennis | 11:045cb766d9a5 | 40 | //This will set flags to their initial values and prepare gsm to start anew. |
DeWayneDennis | 11:045cb766d9a5 | 41 | void gsm_reset(); |
DeWayneDennis | 11:045cb766d9a5 | 42 | |
DeWayneDennis | 11:045cb766d9a5 | 43 | //For debugging: print registers related to DMA and UART setup |
DeWayneDennis | 11:045cb766d9a5 | 44 | void print_registers(); |
DeWayneDennis | 11:045cb766d9a5 | 45 | |
DeWayneDennis | 11:045cb766d9a5 | 46 | #endif |