uses pushing box to publish to google spreadsheets with a state machine instead of a while loop
Fork of GSM_PUSHING_BOX_STATE_MACHINE by
GSMLibrary.h@29:bc5f53f2922a, 2015-04-25 (annotated)
- Committer:
- es_marble
- Date:
- Sat Apr 25 15:39:00 2015 +0000
- Revision:
- 29:bc5f53f2922a
- Parent:
- 24:7d2ff444d6d8
- Child:
- 31:a1e9fd23eb6a
Finish adding comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
danilob | 0:41904adca656 | 1 | #ifndef GSMLIBRARY_H |
danilob | 0:41904adca656 | 2 | #define GSMLIBRARY_H |
danilob | 0:41904adca656 | 3 | |
danilob | 0:41904adca656 | 4 | #include "mbed.h" |
es_marble | 24:7d2ff444d6d8 | 5 | |
es_marble | 29:bc5f53f2922a | 6 | #define TIME_CONST 2 //Specify length of each GSM tick (currently 1.8 seconds but we rounded up to 2 to simplify calculations) |
es_marble | 24:7d2ff444d6d8 | 7 | #define SECONDS_TIMEOUT 30 |
es_marble | 29:bc5f53f2922a | 8 | #define SMS_END_CHAR "\x1A" //Character that must be appended to end of text message before it will be sent |
es_marble | 29:bc5f53f2922a | 9 | #define SMS_ESCAPE_CHAR "\x1A" //Character that can be appended to end of text message to abort sending it |
danilob | 0:41904adca656 | 10 | |
danilob | 0:41904adca656 | 11 | enum gsm_states{GSM_INITIALIZE, |
es_marble | 29:bc5f53f2922a | 12 | GSM_AT_OK, //Make sure communication is established with GSM |
es_marble | 29:bc5f53f2922a | 13 | GSM_AT_CSQ, //Check signal strength |
es_marble | 29:bc5f53f2922a | 14 | GSM_AT_CREG, //Check if phone is connected to network |
es_marble | 24:7d2ff444d6d8 | 15 | GSM_AT_CNMI, //Turn off incoming SMS notifications |
es_marble | 29:bc5f53f2922a | 16 | GSM_AT_CMGF, //Change to text message mode |
es_marble | 29:bc5f53f2922a | 17 | GSM_READ_MSG, //Check for new messages. |
es_marble | 29:bc5f53f2922a | 18 | GSM_AT_CMGS, //Input phone number and indicate beginning of SMS message body |
es_marble | 29:bc5f53f2922a | 19 | GSM_AT_SENDSMS, //Write message, finish with SMS_END_CHAR |
es_marble | 29:bc5f53f2922a | 20 | GSM_DEL_R_MSGS //Delete unread messages (if present) |
danilob | 0:41904adca656 | 21 | }; |
danilob | 0:41904adca656 | 22 | |
danilob | 0:41904adca656 | 23 | //GSM state machine |
danilob | 0:41904adca656 | 24 | void gsm_tick(); |
es_marble | 16:6807d437cd48 | 25 | bool gsm_timeOut(); |
es_marble | 24:7d2ff444d6d8 | 26 | void gsm_printState(); |
es_marble | 16:6807d437cd48 | 27 | void gsm_nextStateLogic(); |
es_marble | 16:6807d437cd48 | 28 | void gsm_mealyOutputs(); |
danilob | 0:41904adca656 | 29 | |
danilob | 0:41904adca656 | 30 | //Initialize DMA data transfer, and UART3. |
danilob | 0:41904adca656 | 31 | void gsm_initialize(); |
danilob | 0:41904adca656 | 32 | |
es_marble | 29:bc5f53f2922a | 33 | //returns 1 for ready to send again, 0 for busy. |
danilob | 17:360afa1e6809 | 34 | bool gsm_ready(); |
danilob | 17:360afa1e6809 | 35 | |
es_marble | 24:7d2ff444d6d8 | 36 | //Have the GSM send data - L = long, S = short, hh/mm/ss for time, "lat ns" for latitute, "lon we" for longitude |
es_marble | 24:7d2ff444d6d8 | 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); |
danilob | 0:41904adca656 | 38 | |
es_marble | 29:bc5f53f2922a | 39 | //Brings state machine back to initialize state (notice this is a bit different than the initialize function) |
es_marble | 29:bc5f53f2922a | 40 | //This will set flags to their initial values and prepare gsm to start anew. |
es_marble | 24:7d2ff444d6d8 | 41 | void gsm_reset(); |
danilob | 0:41904adca656 | 42 | |
es_marble | 29:bc5f53f2922a | 43 | //For debugging: print registers related to DMA and UART setup |
es_marble | 29:bc5f53f2922a | 44 | void print_registers(); |
danilob | 0:41904adca656 | 45 | |
danilob | 0:41904adca656 | 46 | #endif |