yoyo

Fork of FTPClient by Akshay Tom

Committer:
Ricky_Kwon
Date:
Wed Jul 29 00:03:21 2015 +0000
Revision:
3:4fd8e5cd6307
Parent:
1:2630b5456598
Child:
4:8ecc32e7c69b
optimization

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ricky_Kwon 0:61da21bfd120 1 #ifndef FTP_CLIENT_H
Ricky_Kwon 0:61da21bfd120 2 #define FTP_CLIENT_H
Ricky_Kwon 0:61da21bfd120 3 #include "mbed.h"
Ricky_Kwon 0:61da21bfd120 4 #include "SDFileSystem.h"
Ricky_Kwon 0:61da21bfd120 5 #define MAX_SS 256
Ricky_Kwon 3:4fd8e5cd6307 6 /** FTPClient class.
Ricky_Kwon 3:4fd8e5cd6307 7 * Used file transfer with FTPServer like ALFTP(http://software.altools.co.kr/ko-kr/closed.html)
Ricky_Kwon 3:4fd8e5cd6307 8 * This test was completed in ALFTP
Ricky_Kwon 3:4fd8e5cd6307 9 */
Ricky_Kwon 0:61da21bfd120 10 class FTPClient{
Ricky_Kwon 0:61da21bfd120 11 public:
Ricky_Kwon 3:4fd8e5cd6307 12 /** Create FTPClient instance */
Ricky_Kwon 0:61da21bfd120 13 FTPClient(PinName mosi, PinName miso, PinName sclk, PinName ssel, const char* root);
Ricky_Kwon 0:61da21bfd120 14 ~FTPClient() {};
Ricky_Kwon 0:61da21bfd120 15
Ricky_Kwon 3:4fd8e5cd6307 16 /** Connect to FTPServer
Ricky_Kwon 3:4fd8e5cd6307 17 *
Ricky_Kwon 3:4fd8e5cd6307 18 * @param FTPServer IP, FTPServer PORT, FTPServer login ID, FTPServer login PASS
Ricky_Kwon 3:4fd8e5cd6307 19 * @returns
Ricky_Kwon 3:4fd8e5cd6307 20 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 21 * 0 on open error
Ricky_Kwon 3:4fd8e5cd6307 22 */
Ricky_Kwon 0:61da21bfd120 23 bool open(char* ip, int port, char* id, char* pass);
Ricky_Kwon 3:4fd8e5cd6307 24
Ricky_Kwon 3:4fd8e5cd6307 25 /** Get file from FTPServer
Ricky_Kwon 3:4fd8e5cd6307 26 *
Ricky_Kwon 3:4fd8e5cd6307 27 * @param My file name, FTPServer file name
Ricky_Kwon 3:4fd8e5cd6307 28 * @returns
Ricky_Kwon 3:4fd8e5cd6307 29 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 30 * 0 on getfile error
Ricky_Kwon 3:4fd8e5cd6307 31 */
Ricky_Kwon 0:61da21bfd120 32 bool getfile(char* myfilename, char* filename);
Ricky_Kwon 3:4fd8e5cd6307 33
Ricky_Kwon 3:4fd8e5cd6307 34 /** Put file to FTPServer
Ricky_Kwon 3:4fd8e5cd6307 35 *
Ricky_Kwon 3:4fd8e5cd6307 36 * @param My file name, FTPServer file name
Ricky_Kwon 3:4fd8e5cd6307 37 * @returns
Ricky_Kwon 3:4fd8e5cd6307 38 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 39 * 0 on putfile error
Ricky_Kwon 3:4fd8e5cd6307 40 */
Ricky_Kwon 0:61da21bfd120 41 bool putfile(char* myfilename, char* filename);
Ricky_Kwon 3:4fd8e5cd6307 42
Ricky_Kwon 3:4fd8e5cd6307 43 /** View FTPServer directory
Ricky_Kwon 3:4fd8e5cd6307 44 *
Ricky_Kwon 3:4fd8e5cd6307 45 * @param
Ricky_Kwon 3:4fd8e5cd6307 46 * @returns
Ricky_Kwon 3:4fd8e5cd6307 47 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 48 * 0 on dir error
Ricky_Kwon 3:4fd8e5cd6307 49 */
Ricky_Kwon 0:61da21bfd120 50 bool dir();
Ricky_Kwon 3:4fd8e5cd6307 51
Ricky_Kwon 3:4fd8e5cd6307 52 /** View FTPServer directory
Ricky_Kwon 3:4fd8e5cd6307 53 *
Ricky_Kwon 3:4fd8e5cd6307 54 * @param
Ricky_Kwon 3:4fd8e5cd6307 55 * @returns
Ricky_Kwon 3:4fd8e5cd6307 56 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 57 * 0 on ls error
Ricky_Kwon 3:4fd8e5cd6307 58 */
Ricky_Kwon 0:61da21bfd120 59 bool ls();
Ricky_Kwon 3:4fd8e5cd6307 60
Ricky_Kwon 3:4fd8e5cd6307 61 /** Delete FTPServer file
Ricky_Kwon 3:4fd8e5cd6307 62 *
Ricky_Kwon 3:4fd8e5cd6307 63 * @param FTPServer file name
Ricky_Kwon 3:4fd8e5cd6307 64 * @returns
Ricky_Kwon 3:4fd8e5cd6307 65 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 66 * 0 on delete error
Ricky_Kwon 3:4fd8e5cd6307 67 */
Ricky_Kwon 0:61da21bfd120 68 bool fdelete(char* filename);
Ricky_Kwon 3:4fd8e5cd6307 69
Ricky_Kwon 3:4fd8e5cd6307 70 /** Make FTPServer directory
Ricky_Kwon 3:4fd8e5cd6307 71 *
Ricky_Kwon 3:4fd8e5cd6307 72 * @param FTPServer directory name
Ricky_Kwon 3:4fd8e5cd6307 73 * @returns
Ricky_Kwon 3:4fd8e5cd6307 74 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 75 * 0 on mkdir error
Ricky_Kwon 3:4fd8e5cd6307 76 */
Ricky_Kwon 0:61da21bfd120 77 bool mkdir(char* dirname);
Ricky_Kwon 3:4fd8e5cd6307 78
Ricky_Kwon 3:4fd8e5cd6307 79 /** Change current FTPServer directory
Ricky_Kwon 3:4fd8e5cd6307 80 *
Ricky_Kwon 3:4fd8e5cd6307 81 * @param FTPServer directory name
Ricky_Kwon 3:4fd8e5cd6307 82 * @returns
Ricky_Kwon 3:4fd8e5cd6307 83 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 84 * 0 on mkdir error
Ricky_Kwon 3:4fd8e5cd6307 85 */
Ricky_Kwon 0:61da21bfd120 86 bool cd(char* dirname);
Ricky_Kwon 3:4fd8e5cd6307 87
Ricky_Kwon 3:4fd8e5cd6307 88 /** Disconnect from FTPServer
Ricky_Kwon 3:4fd8e5cd6307 89 *
Ricky_Kwon 3:4fd8e5cd6307 90 * @param
Ricky_Kwon 3:4fd8e5cd6307 91 * @returns
Ricky_Kwon 3:4fd8e5cd6307 92 * 1 on success,
Ricky_Kwon 3:4fd8e5cd6307 93 * 0 on Disconnect error
Ricky_Kwon 3:4fd8e5cd6307 94 */
Ricky_Kwon 1:2630b5456598 95 bool quit();
Ricky_Kwon 3:4fd8e5cd6307 96
Ricky_Kwon 1:2630b5456598 97 private:
Ricky_Kwon 0:61da21bfd120 98 TCPSocketConnection* FTPClientControlSock;
Ricky_Kwon 0:61da21bfd120 99 TCPSocketConnection* FTPClientDataSock;
Ricky_Kwon 0:61da21bfd120 100
Ricky_Kwon 0:61da21bfd120 101 bool blogin;
Ricky_Kwon 0:61da21bfd120 102 bool bopenflag;
Ricky_Kwon 0:61da21bfd120 103 bool brfileflag;
Ricky_Kwon 0:61da21bfd120 104 bool bsfileflag;
Ricky_Kwon 0:61da21bfd120 105 bool bdirflag;
Ricky_Kwon 0:61da21bfd120 106 bool blsflag;
Ricky_Kwon 0:61da21bfd120 107 bool bfdeleteflag;
Ricky_Kwon 0:61da21bfd120 108 bool bmkdirflag;
Ricky_Kwon 0:61da21bfd120 109 bool bcdflag;
Ricky_Kwon 1:2630b5456598 110 bool bquitflag;
Ricky_Kwon 0:61da21bfd120 111
Ricky_Kwon 0:61da21bfd120 112 char ftpServer_data_ip_addr[4];
Ricky_Kwon 0:61da21bfd120 113 char ftpServer_data_ip_addr_str[20];
Ricky_Kwon 0:61da21bfd120 114 int remote_port;
Ricky_Kwon 0:61da21bfd120 115
Ricky_Kwon 0:61da21bfd120 116 char rbuf[256];
Ricky_Kwon 0:61da21bfd120 117 char sbuf[256];
Ricky_Kwon 0:61da21bfd120 118
Ricky_Kwon 0:61da21bfd120 119 int remain_datasize;
Ricky_Kwon 0:61da21bfd120 120 int i;
Ricky_Kwon 0:61da21bfd120 121 int remain_filesize;
Ricky_Kwon 0:61da21bfd120 122 int send_byte;
Ricky_Kwon 0:61da21bfd120 123 int size;
Ricky_Kwon 0:61da21bfd120 124 FILE *fp;
Ricky_Kwon 0:61da21bfd120 125 SDFileSystem _SDFileSystem;
Ricky_Kwon 3:4fd8e5cd6307 126
Ricky_Kwon 3:4fd8e5cd6307 127 int pportc(char * arg);
Ricky_Kwon 0:61da21bfd120 128 };
Ricky_Kwon 0:61da21bfd120 129 #endif