FTPClient

Fork of FTPClient by Ricky Kwon

Files at this revision

API Documentation at this revision

Comitter:
akshaytom
Date:
Thu Dec 14 04:49:35 2017 +0000
Parent:
3:4fd8e5cd6307
Commit message:
wefghjssyuiy

Changed in this revision

FTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
FTPClient.h Show annotated file Show diff for this revision Revisions of this file
diff -r 4fd8e5cd6307 -r 8ecc32e7c69b FTPClient.cpp
--- a/FTPClient.cpp	Wed Jul 29 00:03:21 2015 +0000
+++ b/FTPClient.cpp	Thu Dec 14 04:49:35 2017 +0000
@@ -3,6 +3,7 @@
 #include "FTPClient.h"
 //#define DEBUG
 FTPClient::FTPClient(PinName mosi, PinName miso, PinName sclk, PinName ssel, const char* root) : _SDFileSystem(mosi, miso, sclk, ssel, root){
+    //printf("Object");
     blogin = false;
     bopenflag = false;
     brfileflag = false;
@@ -12,8 +13,70 @@
     bmkdirflag = false;
     bcdflag = false;
     bquitflag = false;
+    //printf("Object");
 }
-bool FTPClient::open(char* ip, int port, char* id, char* pass){
+
+// made for checking
+
+
+bool FTPClient::open(char ip[], int port, char id[], char pass[]){
+    //printf("\nInside Open");
+/*
+      printf("\n%s",ip);
+      printf("\n%d",port);
+      printf("\n%s",id);
+      printf("\n%s",pass);
+      printf("\nHappens");
+      printf("\nHappens\n");
+  */
+    
+    FTPClientControlSock = new TCPSocketConnection();
+    FTPClientDataSock = new TCPSocketConnection();
+    //printf("\nHappens\n");
+    #if 0
+    do{
+        FTPClientControlSock->connect(ip, port);
+    }while(!FTPClientControlSock->is_connected());
+    #endif
+    #if 1
+    while (FTPClientControlSock->connect(ip, port) < 0) {
+    #ifdef DEBUG
+        printf("Unable to connect to (%s) on port (%d)\r\n", ip, port);
+    #endif
+        wait(1);
+    }
+    #endif
+    
+    while(!blogin){
+        size = FTPClientControlSock->receive(rbuf, sizeof(rbuf));
+        if(size > 0){
+        #ifdef DEBUG
+            printf("Received message from server: %s\r\n", rbuf);
+        #endif
+            if (!strncmp(rbuf, "220", 3)){
+                printf("%s\r\n", rbuf);
+                sprintf(sbuf, "user %s\r\n", id);             
+                FTPClientControlSock->send(sbuf, strlen(sbuf));
+            }
+            else if (!strncmp(rbuf, "331", 3)){
+                sprintf(sbuf, "pass %s\r\n", pass);             
+                FTPClientControlSock->send(sbuf, strlen(sbuf));
+            }
+            else if (!strncmp(rbuf, "230", 3)){
+                blogin = true;
+            }
+            else{
+                blogin = true;
+            }
+        }  
+    }
+    return 1;
+}
+//*/
+/*
+bool FTPClient::open(char* ip, int port, char* id, char* pass)
+{    
+    printf("Inside Open");
     
     FTPClientControlSock = new TCPSocketConnection;
     FTPClientDataSock = new TCPSocketConnection;
@@ -57,7 +120,7 @@
     }
     return 1;
 }
-
+*/
 bool FTPClient::getfile(char* myfilename, char* filename){
     
     if(blogin){
diff -r 4fd8e5cd6307 -r 8ecc32e7c69b FTPClient.h
--- a/FTPClient.h	Wed Jul 29 00:03:21 2015 +0000
+++ b/FTPClient.h	Thu Dec 14 04:49:35 2017 +0000
@@ -13,6 +13,8 @@
     FTPClient(PinName mosi, PinName miso, PinName sclk, PinName ssel, const char* root);
     ~FTPClient() {};
     
+    //bool open(char []); //new open command to check
+    
     /** Connect to FTPServer
      *
      * @param FTPServer IP, FTPServer PORT, FTPServer login ID, FTPServer login PASS
@@ -20,7 +22,8 @@
      *   1 on success,
      *   0 on open error
      */
-    bool open(char* ip, int port, char* id, char* pass);
+     bool open(char [], int, char [], char []);
+    //bool open(char* ip, int port, char* id, char* pass);
     
     /** Get file from FTPServer
      *