ghtfgtr
Dependencies: FTPClient SDFileSystem WIZnetInterface_Ricky mbed
main.cpp@0:e35dac7e4c95, 2017-11-28 (annotated)
- Committer:
- wiznetw7500
- Date:
- Tue Nov 28 09:47:16 2017 +0000
- Revision:
- 0:e35dac7e4c95
ghytfrf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wiznetw7500 | 0:e35dac7e4c95 | 1 | #include "mbed.h" |
wiznetw7500 | 0:e35dac7e4c95 | 2 | #include "SDFileSystem.h" |
wiznetw7500 | 0:e35dac7e4c95 | 3 | #include "EthernetInterface.h" |
wiznetw7500 | 0:e35dac7e4c95 | 4 | #include "FTPClient.h" |
wiznetw7500 | 0:e35dac7e4c95 | 5 | #include <string.h> |
wiznetw7500 | 0:e35dac7e4c95 | 6 | #include <stdio.h> |
wiznetw7500 | 0:e35dac7e4c95 | 7 | #define FTP_SERVER_PORT 21 |
wiznetw7500 | 0:e35dac7e4c95 | 8 | static char buf[256]; |
wiznetw7500 | 0:e35dac7e4c95 | 9 | static char ID[]={"user"}; //Set FTPServer Login ID |
wiznetw7500 | 0:e35dac7e4c95 | 10 | static char PASSWORD[]={"1234"}; //Set FTPServer Login Password |
wiznetw7500 | 0:e35dac7e4c95 | 11 | FTPClient FTP(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500 |
wiznetw7500 | 0:e35dac7e4c95 | 12 | Serial pc(USBTX, USBRX); |
wiznetw7500 | 0:e35dac7e4c95 | 13 | int main() { |
wiznetw7500 | 0:e35dac7e4c95 | 14 | pc.baud(9600); |
wiznetw7500 | 0:e35dac7e4c95 | 15 | |
wiznetw7500 | 0:e35dac7e4c95 | 16 | pc.printf("------------------------------FTP Client Example-------------------------------------------!\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 17 | |
wiznetw7500 | 0:e35dac7e4c95 | 18 | |
wiznetw7500 | 0:e35dac7e4c95 | 19 | char ftpServer_control_ip_addr[] = "demo.wftpserver.com"; // FTP Server location |
wiznetw7500 | 0:e35dac7e4c95 | 20 | char* userid = "demo-user"; //FTP Server User ID |
wiznetw7500 | 0:e35dac7e4c95 | 21 | char* password = "demo-user"; //FTP Server Password |
wiznetw7500 | 0:e35dac7e4c95 | 22 | EthernetInterface eth; |
wiznetw7500 | 0:e35dac7e4c95 | 23 | uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x12, 0x34, 0x45}; |
wiznetw7500 | 0:e35dac7e4c95 | 24 | char IP_Addr[] = "192.168.0.100"; |
wiznetw7500 | 0:e35dac7e4c95 | 25 | char IP_Subnet[] = "255.255.255.0"; |
wiznetw7500 | 0:e35dac7e4c95 | 26 | char IP_Gateway[] = "192.168.0.1"; |
wiznetw7500 | 0:e35dac7e4c95 | 27 | eth.init(mac_addr, IP_Addr, IP_Subnet, IP_Gateway); //Use Static |
wiznetw7500 | 0:e35dac7e4c95 | 28 | eth.connect(); |
wiznetw7500 | 0:e35dac7e4c95 | 29 | pc.printf("The IP address of the client is %s\r\n",eth.getIPAddress()); |
wiznetw7500 | 0:e35dac7e4c95 | 30 | |
wiznetw7500 | 0:e35dac7e4c95 | 31 | while(1) { |
wiznetw7500 | 0:e35dac7e4c95 | 32 | char Msg_c = pc.getc(); |
wiznetw7500 | 0:e35dac7e4c95 | 33 | |
wiznetw7500 | 0:e35dac7e4c95 | 34 | if(Msg_c==0x31){ |
wiznetw7500 | 0:e35dac7e4c95 | 35 | |
wiznetw7500 | 0:e35dac7e4c95 | 36 | pc.printf("Connecting...FTPServer\r\nIP:%s, PORT:%d\r\n", ftpServer_control_ip_addr, FTP_SERVER_PORT); |
wiznetw7500 | 0:e35dac7e4c95 | 37 | int n = FTP.open("demo.wftpserver.com", 21,"demo-user","demo-user"); |
wiznetw7500 | 0:e35dac7e4c95 | 38 | pc.printf("%d\r\n",n); |
wiznetw7500 | 0:e35dac7e4c95 | 39 | wait(10); |
wiznetw7500 | 0:e35dac7e4c95 | 40 | printf("The Files and folders available in the server are :\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 41 | FTP.ls(); |
wiznetw7500 | 0:e35dac7e4c95 | 42 | printf("\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 43 | wait(10); |
wiznetw7500 | 0:e35dac7e4c95 | 44 | printf("The Files in upload folder are :\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 45 | FTP.cd("/upload"); |
wiznetw7500 | 0:e35dac7e4c95 | 46 | FTP.ls(); |
wiznetw7500 | 0:e35dac7e4c95 | 47 | wait(10); |
wiznetw7500 | 0:e35dac7e4c95 | 48 | printf("The Files in download folder are :\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 49 | FTP.cd("/download"); |
wiznetw7500 | 0:e35dac7e4c95 | 50 | FTP.ls(); |
wiznetw7500 | 0:e35dac7e4c95 | 51 | printf("\r\n"); |
wiznetw7500 | 0:e35dac7e4c95 | 52 | wait(10); |
wiznetw7500 | 0:e35dac7e4c95 | 53 | |
wiznetw7500 | 0:e35dac7e4c95 | 54 | } |
wiznetw7500 | 0:e35dac7e4c95 | 55 | |
wiznetw7500 | 0:e35dac7e4c95 | 56 | |
wiznetw7500 | 0:e35dac7e4c95 | 57 | } |
wiznetw7500 | 0:e35dac7e4c95 | 58 | |
wiznetw7500 | 0:e35dac7e4c95 | 59 | |
wiznetw7500 | 0:e35dac7e4c95 | 60 | } |