DCS_TEAM / Mbed 2 deprecated DCS

Dependencies:   MBed_Adafruit-GPS-Library SDFileSystem mbed GSM_Library

Fork of DCS by Brandon Crofts

Revision:
2:5c0513ab856e
Parent:
1:8614e190908b
Child:
3:91171e819b08
diff -r 8614e190908b -r 5c0513ab856e GSMLibrary.cpp
--- a/GSMLibrary.cpp	Fri Mar 06 22:36:44 2015 +0000
+++ b/GSMLibrary.cpp	Fri Mar 06 23:14:13 2015 +0000
@@ -29,12 +29,19 @@
 extern Serial pc;
 extern Serial gsm;
 extern uint8_t buffer[BUFFER_LENGTH];//buffer storing char
+char gsm_message[MESSAGE_SIZE];
 
 //Internal variables
 gsm_states gsm_current_state = GSM_INITIALIZE;
 char send = 0;
 int timeout_count = 0;
 
+bool gsm_ready(){
+    if(send)
+        return false;
+    return true;    
+}
+
 void gsm_tick()
 {
     if (getGSMIdleBit() || gsm_timeOut() || (send && gsm_current_state == GSM_INITIALIZE))  //question with send...
@@ -46,8 +53,6 @@
     }
 }
 
-
-
 //Advance timeout counter; if timeout, return true
 bool gsm_timeOut()
 {
@@ -64,7 +69,6 @@
 void gsm_nextStateLogic()
 {
     printQueue(); //$debug
-
     switch(gsm_current_state)
     {
         case GSM_INITIALIZE:
@@ -115,7 +119,8 @@
             pc.printf("gsm_success state\r\n");//&debug
             if(findInQueue(AT_SENDSMS_RESPONSE))         //This appears to be a bug. It was in Danilo's original code as well.
                 pc.printf("Message SENT! msgID: %iY\r\n",parseInt());//&debug
-            gsm_current_state = GSM_AT_CMGS;                //Confusing part. Do we always go backwards here?
+            gsm_current_state = GSM_INITIALIZE;//Confusing part. Do we always go backwards here?
+            send =0;
             break;
         default:
             pc.printf("This is a state error");
@@ -157,7 +162,7 @@
             break;
         case GSM_AT_SENDSMS:
             pc.printf("sending MESSAGE_BODY\r\n");//&debug
-            gsm.puts(MESSAGE_BODY); //substitute char included
+            gsm.puts(gsm_message); //substitute char included
             gsm.puts("\r\n"); 
             break;
         case GSM_SUCCESS:
@@ -168,7 +173,8 @@
 }
 
 //set send falg on
-void gsm_send_sms(){
+void gsm_send_sms(char message[MESSAGE_SIZE]){
+    gsm_message = message;
     send = 1;
 }