Library for the Adafruit FONA. This is a port of the original Arduino library available at: https://github.com/adafruit/Adafruit_FONA_Library . - Modified by Marc PLOUHINEC 27/06/2015 for use in mbed - Modified by lionel VOIRIN 05/08/2018 for use Adafruit FONA 3

Dependents:   Adafruit_FONA_3G_Library_Test

Revision:
10:7951d9691cb2
Parent:
9:b18cfba4283a
Child:
11:5f66d83249ea
--- a/Adafruit_FONA.cpp	Tue Oct 23 19:16:20 2018 +0000
+++ b/Adafruit_FONA.cpp	Mon Feb 25 20:27:24 2019 +0000
@@ -236,7 +236,13 @@
 }
 
 /********* Serial port ********************************************/
-bool Adafruit_FONA::setBaudrate(uint16_t baud)
+
+bool Adafruit_FONA::getBaudrate(uint32_t *baud)
+{
+    return sendParseReply("AT+IPREX?", "+IPREX: ", baud);
+}
+
+bool Adafruit_FONA::setBaudrate(uint32_t baud)
 {
     return sendCheckReply("AT+IPREX=", baud, ok_reply);
 }
@@ -1363,12 +1369,40 @@
     }
     printf("\r\n");
 #endif
+    
+    readline();
 
     memcpy(buff, replybuffer, avail);
 
     return avail;
 }
 
+
+uint16_t Adafruit_FONA_3G::sslTCPread(char *buff)
+{
+    uint16_t avail;
+
+    readline();
+    if (! parseReply("+CCHRECV: DATA,0,", &avail)) return false;
+
+    readRaw(avail);
+
+#ifdef ADAFRUIT_FONA_DEBUG
+    printf("%d bytes read\r\n", avail);
+    for (uint8_t i=0; i<avail; i++) {
+        printf("%c", replybuffer[i]);
+    }
+    printf("\r\n");
+#endif
+
+    memcpy(buff, replybuffer, avail);
+    
+    replybuffer[0] = 0;
+
+    return avail;
+}
+
+
 /********* HTTP LOW LEVEL FUNCTIONS  ************************************/
 
 bool Adafruit_FONA::HTTP_init()
@@ -1775,6 +1809,24 @@
     return (strcmp(replybuffer, reply) == 0);
 }
 
+bool Adafruit_FONA::parseReply(const char* toreply, uint32_t *v, char divider, uint8_t index)
+{
+    char *p = strstr(replybuffer, toreply);  // get the pointer to the voltage
+    if (p == 0) return false;
+    p += strlen(toreply);
+
+    for (uint8_t i=0; i<index; i++) {
+        // increment dividers
+        p = strchr(p, divider);
+        if (!p) return false;
+        p++;
+    }
+
+    *v = atoi(p);
+
+    return true;
+}
+
 bool Adafruit_FONA::parseReply(const char* toreply, uint16_t *v, char divider, uint8_t index)
 {
     char *p = strstr(replybuffer, toreply);  // get the pointer to the voltage
@@ -1856,6 +1908,17 @@
     return true;
 }
 
+bool Adafruit_FONA::sendParseReply(const char* tosend, const char* toreply, uint32_t *v, char divider, uint8_t index)
+{
+    getReply(tosend);
+
+    if (! parseReply(toreply, v, divider, index)) return false;
+
+    readline(); // eat 'OK'
+
+    return true;
+}
+
 bool Adafruit_FONA::sendParseReply(const char* tosend, const char* toreply, uint16_t *v, char divider, uint8_t index)
 {
     getReply(tosend);
@@ -1880,6 +1943,24 @@
     return true;
 }
 
+bool Adafruit_FONA_3G::parseReply(const char* toreply, uint16_t *v, char divider, uint8_t index)
+{
+    char *p = strstr(replybuffer, toreply);  // get the pointer to the voltage
+    if (p == 0) return false;
+    p += strlen(toreply);
+
+    for (uint8_t i=0; i<index; i++) {
+        // increment dividers
+        p = strchr(p, divider);
+        if (!p) return false;
+        p++;
+    }
+
+    *v = atoi(p);
+
+    return true;
+}
+
 bool Adafruit_FONA_3G::parseReply(const char* toreply, float *f, char divider, uint8_t index)
 {
     char *p = strstr(replybuffer, toreply);  // get the pointer to the voltage