FTPGET

Dependencies:   SDFileSystem dspmodified mbed

Fork of fft_merge_main_codev1 by Testbed

Revision:
17:a5afe7677838
Parent:
15:e8defe4bdd37
Parent:
16:0ffa3f28fb20
Child:
18:4954e8028d0a
--- a/main.cpp	Mon Jan 26 09:12:38 2015 +0000
+++ b/main.cpp	Mon Jan 26 12:41:27 2015 +0000
@@ -67,9 +67,10 @@
 //--------------------------------------------------------------------------------------------------//
 //                  Send AT Command (1 response with clk variable)                                                    //
 //--------------------------------------------------------------------------------------------------//
-int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout, bool clk_flag)
+bool sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout, bool clk_flag)
 {
-    uint8_t x=0,answer=0;                                                                           //x=0 and answer=0, if not put, AT+CCLK?\r is not executed
+    int x=0,
+    bool answer=0;                                                                           //x=0 and answer=0, if not put, AT+CCLK?\r is not executed
     char response[100];
     memset(response, '\0', 100);                                                                    // Initialize the string
     wait_ms(100);
@@ -447,20 +448,20 @@
     int ftp_close_attempt=0;
     /*if(sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0)) {
     } else {*/
-        while(!sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0)) {
-            sendATcommand("AT+SAPBR=0,1","OK",5,0);
-            ftp_close_attempt++;
-            if(ftp_close_attempt>3) {
-                return 0;
-            }
+    while(!sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0)) {
+        sendATcommand("AT+SAPBR=0,1","OK",5,0);
+        ftp_close_attempt++;
+        if(ftp_close_attempt>3) {
+            return 0;
         }
+    }
     //}
     do{
         sendATcommand("AT+SAPBR=1,1", "OK", 10,0);
         ftp_connect_attempt++;
-        if(ftp_connect_attempt>3) {
+        if(ftp_connect_attempt>3){
             return 0;
-        }
+            }
         }
     while(sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0));
     sendATcommand("AT+FTPTYPE=\"I\"", "OK", 5,0);