uses pushing box to publish to google spreadsheets with a state machine instead of a while loop

Fork of GSM_Library by DCS_TEAM

Committer:
es_marble
Date:
Sat Apr 11 23:21:46 2015 +0000
Revision:
24:7d2ff444d6d8
Parent:
23:5227fb014aad
Child:
29:bc5f53f2922a
added final GSM_Library code

Who changed what in which revision?

UserRevisionLine numberNew 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 24:7d2ff444d6d8 6 #define TIME_CONST 1
es_marble 24:7d2ff444d6d8 7 #define SECONDS_TIMEOUT 30
es_marble 24:7d2ff444d6d8 8 #define SMS_END_CHAR "\x1A"
es_marble 24:7d2ff444d6d8 9 #define SMS_ESCAPE_CHAR "\x1A"
danilob 0:41904adca656 10
danilob 0:41904adca656 11 enum gsm_states{GSM_INITIALIZE,
danilob 0:41904adca656 12 GSM_AT_OK, //Make sure communication is stablished betheen fdm and gsm
danilob 0:41904adca656 13 GSM_AT_CSQ, //Check signal strength if strenght lower than 10 keep trying
danilob 0:41904adca656 14 GSM_AT_CREG, //Checking if phone is conected to network
es_marble 24:7d2ff444d6d8 15 GSM_AT_CNMI, //Turn off incoming SMS notifications
danilob 0:41904adca656 16 GSM_AT_CMGF, //prepare phone to send message by CMGF=1
es_marble 24:7d2ff444d6d8 17 GSM_READ_MSG, //check for a new message. if so will set transmitter mode on.
danilob 0:41904adca656 18 GSM_AT_CMGS, //input phone number by CMGS= "+phonenumber"
danilob 0:41904adca656 19 GSM_AT_SENDSMS, //write message, finish with alt+z
es_marble 24:7d2ff444d6d8 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
danilob 17:360afa1e6809 33 //returns 1 for eady 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
danilob 0:41904adca656 39 //Brings state machine back to initialize state (notice this is different than initialize function)
danilob 0:41904adca656 40 //this will set flags to initial values and prepare gsm to work anew.
es_marble 24:7d2ff444d6d8 41 void gsm_reset();
danilob 0:41904adca656 42
danilob 0:41904adca656 43 //used for debuging purposes, it print all main registers from dma0 and uart3
danilob 0:41904adca656 44 void print_registers();
danilob 0:41904adca656 45
danilob 0:41904adca656 46 #endif