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:
6:8fdb30dc3108
Parent:
5:79e4c91f2b73
Child:
7:e60a2ee53aa0
--- a/Adafruit_FONA.cpp	Wed Sep 05 20:26:07 2018 +0000
+++ b/Adafruit_FONA.cpp	Thu Sep 06 20:17:02 2018 +0000
@@ -1170,8 +1170,29 @@
     printf("AT+CIPOPEN=0,\"TCP\",\"%s\",%d\r\n", server, port);
 #endif
 
-    // AT+CIPOPEN=0,"TCP","217.182.85.123",2323
-    if (! sendCheckReply("AT+CIPOPEN=0,\"TCP\",\"217.182.85.123\",2323", "CONNECT 4800", 5000)) return false;
+    mySerial.printf("AT+CIPOPEN=0,\"TCP\",\"%s\",%d\r\n", server, port);
+
+    if (! expectReply("CONNECT 4800")) return false;
+
+    return true;
+}
+
+bool Adafruit_FONA_3G::sslTCPconnect(char *server, uint16_t port)
+{
+    flushInput();
+
+    // start common channel
+    if (! sendCheckReply("AT+CCHSTART", ok_reply, 3000) ) return false;
+    
+    wait(5);
+
+#ifdef ADAFRUIT_FONA_DEBUG
+    printf("AT+CCHOPEN=0,\"%s\",%d,2\r\n", server, port);
+#endif
+
+    mySerial.printf("AT+CCHOPEN=0,\"%s\",%d,2\r\n", server, port);
+
+    if (! expectReply(ok_reply)) return false;
 
     return true;
 }
@@ -1204,6 +1225,11 @@
     return sendCheckReply("AT+CIPCLOSE=0", ok_reply);
 }
 
+bool Adafruit_FONA_3G::sslTCPclose(void)
+{
+    return sendCheckReply("AT+CCHCLOSE=0", ok_reply);
+}
+
 bool Adafruit_FONA::TCPconnected(void)
 {
     if (! sendCheckReply("AT+CIPSTATUS", ok_reply, 100) ) return false;
@@ -1251,6 +1277,26 @@
     return true;
 }
 
+bool Adafruit_FONA_3G::sslTCPsend(char *packet, uint8_t len)
+{
+    mySerial.printf("AT+CCHSEND=0,%d\r\n", len);
+    readline();
+#ifdef ADAFRUIT_FONA_DEBUG
+    printf("\t<--- %s\r\n", replybuffer);
+#endif
+    if (replybuffer[0] != '>') return false;
+
+    for (uint16_t i=0; i<len; i++) {
+        mySerial.putc(packet[i]);
+    }
+    readline(3000); // wait up to 3 seconds to send the data
+#ifdef ADAFRUIT_FONA_DEBUG
+    printf("\t<--- %s\r\n", replybuffer);
+#endif
+
+    return (strcmp(replybuffer, "OK") == 0);
+}
+
 uint16_t Adafruit_FONA::TCPavailable(void)
 {
     uint16_t avail;