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
Diff: GSMLibrary.cpp
- Revision:
- 26:838a9d26e8e9
- Parent:
- 25:9de265c5bb28
- Child:
- 27:fe1c7eaf5b88
--- a/GSMLibrary.cpp Sun Apr 12 01:05:55 2015 +0000 +++ b/GSMLibrary.cpp Sun Apr 12 03:09:15 2015 +0000 @@ -5,8 +5,6 @@ //Global defines #define TIMEOUTLIMIT SECONDS_TIMEOUT/TIME_CONST //$change check with main code this will set up condition fior timeout. -#define BEGIN_PHOTODIODE_DATA "CLS:" -#define BEGIN_GPS_DATA "GPS:" //Extra defines for transmitter #define START_SMS_TRANSMISSION "START" @@ -15,6 +13,8 @@ #define RECEIVER_PHONE_NUMBER "\"+13853357314\"" #define AT_CMGS "AT+CMGS=" RECEIVER_PHONE_NUMBER #define NUM_SIZE 25 +#define BEGIN_SENSOR_DATA "$" +#define END_SENSOR_DATA "%" //definition for AT comands to send #define AT_OK "AT" @@ -88,28 +88,26 @@ if (!gsm_ready()) //Don't send if gsm not ready return; - //Concatenate photodiode data + //Concatenate data gsm_msg[0] = NULL; - strcat(gsm_msg, BEGIN_PHOTODIODE_DATA); - snprintf(num, NUM_SIZE, ",%d:%d:%d,", hh, mm, ss); - strcat(gsm_msg, num); + strcat(gsm_msg, BEGIN_SENSOR_DATA); snprintf(num, NUM_SIZE, "%f,", L); strcat(gsm_msg, num); snprintf(num, NUM_SIZE, "%f,", Lref); strcat(gsm_msg, num); snprintf(num, NUM_SIZE, "%f,", S); strcat(gsm_msg, num); - snprintf(num, NUM_SIZE, "%f\n", Sref); + snprintf(num, NUM_SIZE, "%f,", Sref); strcat(gsm_msg, num); - - //Concatenate gps data - strcat(gsm_msg, BEGIN_GPS_DATA); + snprintf(num, NUM_SIZE, "%d:%d:%d,", hh, mm, ss); + strcat(gsm_msg, num); if (ns != NULL) //If there is a gps fix, ns will be set { - snprintf(num, NUM_SIZE, ",%.4f%c,%.4f%c\n", lat, ns, lon, we); + snprintf(num, NUM_SIZE, "%.4f,%.4f", (ns == 'N') ? lat : -lat, (we == 'E') ? lon : -lon); strcat(gsm_msg, num); } - else strcat(gsm_msg, ",NONE\n"); + else strcat(gsm_msg, "0,0"); + strcat(gsm_msg, END_SENSOR_DATA); send = true; //Mark that we are currently sending a message strcat(gsm_msg, SMS_END_CHAR); //Add SMS end char