yoyo
Fork of FTPClient by
FTPClient.h@5:087a3ccad604, 2018-02-01 (annotated)
- Committer:
- Dxmanas
- Date:
- Thu Feb 01 07:59:48 2018 +0000
- Revision:
- 5:087a3ccad604
- Parent:
- 4:8ecc32e7c69b
commit
Who changed what in which revision?
User | Revision | Line number | New 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 | |
akshaytom | 4:8ecc32e7c69b | 16 | //bool open(char []); //new open command to check |
akshaytom | 4:8ecc32e7c69b | 17 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 18 | /** Connect to FTPServer |
Ricky_Kwon | 3:4fd8e5cd6307 | 19 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 20 | * @param FTPServer IP, FTPServer PORT, FTPServer login ID, FTPServer login PASS |
Ricky_Kwon | 3:4fd8e5cd6307 | 21 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 22 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 23 | * 0 on open error |
Ricky_Kwon | 3:4fd8e5cd6307 | 24 | */ |
akshaytom | 4:8ecc32e7c69b | 25 | bool open(char [], int, char [], char []); |
akshaytom | 4:8ecc32e7c69b | 26 | //bool open(char* ip, int port, char* id, char* pass); |
Ricky_Kwon | 3:4fd8e5cd6307 | 27 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 28 | /** Get file from FTPServer |
Ricky_Kwon | 3:4fd8e5cd6307 | 29 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 30 | * @param My file name, FTPServer file name |
Ricky_Kwon | 3:4fd8e5cd6307 | 31 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 32 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 33 | * 0 on getfile error |
Ricky_Kwon | 3:4fd8e5cd6307 | 34 | */ |
Ricky_Kwon | 0:61da21bfd120 | 35 | bool getfile(char* myfilename, char* filename); |
Ricky_Kwon | 3:4fd8e5cd6307 | 36 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 37 | /** Put file to FTPServer |
Ricky_Kwon | 3:4fd8e5cd6307 | 38 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 39 | * @param My file name, FTPServer file name |
Ricky_Kwon | 3:4fd8e5cd6307 | 40 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 41 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 42 | * 0 on putfile error |
Ricky_Kwon | 3:4fd8e5cd6307 | 43 | */ |
Ricky_Kwon | 0:61da21bfd120 | 44 | bool putfile(char* myfilename, char* filename); |
Ricky_Kwon | 3:4fd8e5cd6307 | 45 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 46 | /** View FTPServer directory |
Ricky_Kwon | 3:4fd8e5cd6307 | 47 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 48 | * @param |
Ricky_Kwon | 3:4fd8e5cd6307 | 49 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 50 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 51 | * 0 on dir error |
Ricky_Kwon | 3:4fd8e5cd6307 | 52 | */ |
Ricky_Kwon | 0:61da21bfd120 | 53 | bool dir(); |
Ricky_Kwon | 3:4fd8e5cd6307 | 54 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 55 | /** View FTPServer directory |
Ricky_Kwon | 3:4fd8e5cd6307 | 56 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 57 | * @param |
Ricky_Kwon | 3:4fd8e5cd6307 | 58 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 59 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 60 | * 0 on ls error |
Ricky_Kwon | 3:4fd8e5cd6307 | 61 | */ |
Ricky_Kwon | 0:61da21bfd120 | 62 | bool ls(); |
Ricky_Kwon | 3:4fd8e5cd6307 | 63 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 64 | /** Delete FTPServer file |
Ricky_Kwon | 3:4fd8e5cd6307 | 65 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 66 | * @param FTPServer file name |
Ricky_Kwon | 3:4fd8e5cd6307 | 67 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 68 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 69 | * 0 on delete error |
Ricky_Kwon | 3:4fd8e5cd6307 | 70 | */ |
Ricky_Kwon | 0:61da21bfd120 | 71 | bool fdelete(char* filename); |
Ricky_Kwon | 3:4fd8e5cd6307 | 72 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 73 | /** Make FTPServer directory |
Ricky_Kwon | 3:4fd8e5cd6307 | 74 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 75 | * @param FTPServer directory name |
Ricky_Kwon | 3:4fd8e5cd6307 | 76 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 77 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 78 | * 0 on mkdir error |
Ricky_Kwon | 3:4fd8e5cd6307 | 79 | */ |
Ricky_Kwon | 0:61da21bfd120 | 80 | bool mkdir(char* dirname); |
Ricky_Kwon | 3:4fd8e5cd6307 | 81 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 82 | /** Change current FTPServer directory |
Ricky_Kwon | 3:4fd8e5cd6307 | 83 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 84 | * @param FTPServer directory name |
Ricky_Kwon | 3:4fd8e5cd6307 | 85 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 86 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 87 | * 0 on mkdir error |
Ricky_Kwon | 3:4fd8e5cd6307 | 88 | */ |
Ricky_Kwon | 0:61da21bfd120 | 89 | bool cd(char* dirname); |
Ricky_Kwon | 3:4fd8e5cd6307 | 90 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 91 | /** Disconnect from FTPServer |
Ricky_Kwon | 3:4fd8e5cd6307 | 92 | * |
Ricky_Kwon | 3:4fd8e5cd6307 | 93 | * @param |
Ricky_Kwon | 3:4fd8e5cd6307 | 94 | * @returns |
Ricky_Kwon | 3:4fd8e5cd6307 | 95 | * 1 on success, |
Ricky_Kwon | 3:4fd8e5cd6307 | 96 | * 0 on Disconnect error |
Ricky_Kwon | 3:4fd8e5cd6307 | 97 | */ |
Ricky_Kwon | 1:2630b5456598 | 98 | bool quit(); |
Ricky_Kwon | 3:4fd8e5cd6307 | 99 | |
Ricky_Kwon | 1:2630b5456598 | 100 | private: |
Ricky_Kwon | 0:61da21bfd120 | 101 | TCPSocketConnection* FTPClientControlSock; |
Ricky_Kwon | 0:61da21bfd120 | 102 | TCPSocketConnection* FTPClientDataSock; |
Ricky_Kwon | 0:61da21bfd120 | 103 | |
Ricky_Kwon | 0:61da21bfd120 | 104 | bool blogin; |
Ricky_Kwon | 0:61da21bfd120 | 105 | bool bopenflag; |
Ricky_Kwon | 0:61da21bfd120 | 106 | bool brfileflag; |
Ricky_Kwon | 0:61da21bfd120 | 107 | bool bsfileflag; |
Ricky_Kwon | 0:61da21bfd120 | 108 | bool bdirflag; |
Ricky_Kwon | 0:61da21bfd120 | 109 | bool blsflag; |
Ricky_Kwon | 0:61da21bfd120 | 110 | bool bfdeleteflag; |
Ricky_Kwon | 0:61da21bfd120 | 111 | bool bmkdirflag; |
Ricky_Kwon | 0:61da21bfd120 | 112 | bool bcdflag; |
Ricky_Kwon | 1:2630b5456598 | 113 | bool bquitflag; |
Ricky_Kwon | 0:61da21bfd120 | 114 | |
Ricky_Kwon | 0:61da21bfd120 | 115 | char ftpServer_data_ip_addr[4]; |
Ricky_Kwon | 0:61da21bfd120 | 116 | char ftpServer_data_ip_addr_str[20]; |
Ricky_Kwon | 0:61da21bfd120 | 117 | int remote_port; |
Ricky_Kwon | 0:61da21bfd120 | 118 | |
Ricky_Kwon | 0:61da21bfd120 | 119 | char rbuf[256]; |
Ricky_Kwon | 0:61da21bfd120 | 120 | char sbuf[256]; |
Ricky_Kwon | 0:61da21bfd120 | 121 | |
Ricky_Kwon | 0:61da21bfd120 | 122 | int remain_datasize; |
Ricky_Kwon | 0:61da21bfd120 | 123 | int i; |
Ricky_Kwon | 0:61da21bfd120 | 124 | int remain_filesize; |
Ricky_Kwon | 0:61da21bfd120 | 125 | int send_byte; |
Ricky_Kwon | 0:61da21bfd120 | 126 | int size; |
Ricky_Kwon | 0:61da21bfd120 | 127 | FILE *fp; |
Ricky_Kwon | 0:61da21bfd120 | 128 | SDFileSystem _SDFileSystem; |
Ricky_Kwon | 3:4fd8e5cd6307 | 129 | |
Ricky_Kwon | 3:4fd8e5cd6307 | 130 | int pportc(char * arg); |
Ricky_Kwon | 0:61da21bfd120 | 131 | }; |
Ricky_Kwon | 0:61da21bfd120 | 132 | #endif |