ECE420 Project

Dependencies:   mbed

Fork of FONA_CellPhone by Dream Team

Files at this revision

API Documentation at this revision

Comitter:
nakita94
Date:
Wed Jun 22 01:33:03 2016 +0000
Parent:
17:b01377595122
Commit message:
6/21/2106 changes

Changed in this revision

Adafruit_FONA.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b01377595122 -r a4f1b2947109 Adafruit_FONA.cpp
--- a/Adafruit_FONA.cpp	Wed Mar 30 16:19:51 2016 +0000
+++ b/Adafruit_FONA.cpp	Wed Jun 22 01:33:03 2016 +0000
@@ -7,7 +7,8 @@
 
   These displays use TTL Serial to communicate, 2 pins are required to
   interface
-  Adafruit invests time and resources providing this open source code,
+  Adafruit invests time and r
+  esources providing this open source code,
   please support Adafruit and open-source hardware by purchasing
   products from Adafruit!
 
@@ -29,24 +30,35 @@
 sendCheckReply returns a boolean where its true when FONA responds with the string of its second input
 
 */
+Serial pc(USBTX, USBRX);
 
 
 bool Adafruit_FONA::begin(int baudrate) {
     mySerial.baud(baudrate); //set the baud rate of the fona serial connection
+    pc.printf("Set the baud rate\r\n");
     mySerial.attach(this, &Adafruit_FONA::onSerialDataReceived, Serial::RxIrq); //attached onSerialDataReceived as Serial receive interrupt
     
     // INIT Reboot process
     _rstpin = HIGH;
     wait_ms(10);
+    pc.printf("Set rstpin high\r\n");
     _rstpin = LOW;
     wait_ms(100);
+    pc.printf("Set rstpin low\r\n");
     _rstpin = HIGH;
+    pc.printf("Set rstpin high\r\n");
     
-    // give 3 seconds to reboot
-    wait_ms(3000);
+    // give 7 seconds to reboot
+    wait_ms(7000);
     
     // flushes the serial port
-    while (readable()) getc();
+    while (mySerial.readable()){
+         pc.printf("Flushing the serial port\r\n");
+         mySerial.getc();
+    }
+    pc.printf("Flushed the serial port\r\n");
+    
+    char temp;
     
     // Make sure FONA is alive
     sendCheckReply("AT", "OK");
@@ -59,9 +71,11 @@
     // turn off Echo!
     sendCheckReply("ATE0", "OK");
     wait_ms(100);
+    pc.printf("Turned off echo\r\n");
     
     // Just checks if the FONA even responds, if it doesnt, then return false
-    if (! sendCheckReply("ATE0", "OK")) {
+    if (! sendCheckReply("ATE0", "OK") {
+        pc.printf("checks if the FONA responds \r\n");
         return false;
     }
     
@@ -1218,8 +1232,8 @@
             break;
         }
     
-        while(readable()) {
-            char c =  getc();
+        while(mySerial.readable()) {
+            char c =  mySerial.getc();
             if (c == '\r') continue;
             if (c == 0xA) {
                 if (replyidx == 0)   // the first 0x0A is ignored
@@ -1250,7 +1264,8 @@
     printf("\t---> %s\r\n", send);
 #endif
 
-    mySerial.printf("%s\r\n",send);
+    mySerial.printf("%s",send);
+    pc.printf("%s\r\n",send);
 
     uint8_t l = readline(timeout);
 #ifdef ADAFRUIT_FONA_DEBUG
@@ -1267,7 +1282,8 @@
     printf("\t---> %s%s\r\n", prefix, suffix);
 #endif
     
-    mySerial.printf("%s%s\r\n", prefix, suffix);
+    mySerial.printf("%s%s", prefix, suffix);
+    pc.printf("%s%s\r\n", prefix, suffix);
     
     uint8_t l = readline(timeout);
 #ifdef ADAFRUIT_FONA_DEBUG
@@ -1285,6 +1301,8 @@
 #endif
     
     mySerial.printf("%s%d\r\n", prefix, suffix);
+    pc.printf("%s%d\r\n", prefix, suffix);
+    
     
     uint8_t l = readline(timeout);
 #ifdef ADAFRUIT_FONA_DEBUG
@@ -1302,6 +1320,8 @@
 #endif
     
     mySerial.printf("%s%d,%d\r\n", prefix, suffix1, suffix2);
+    pc.printf("%s%d,%d\r\n", prefix, suffix1, suffix2);
+    
     
     uint8_t l = readline(timeout);
 #ifdef ADAFRUIT_FONA_DEBUG
diff -r b01377595122 -r a4f1b2947109 main.cpp
--- a/main.cpp	Wed Mar 30 16:19:51 2016 +0000
+++ b/main.cpp	Wed Jun 22 01:33:03 2016 +0000
@@ -55,6 +55,7 @@
         led1 = 1;
     }
     
+    
     virtual void onNoCarrier() {
         led1 = 0; 
     }