ghtfgtr

Dependencies:   FTPClient SDFileSystem WIZnetInterface_Ricky mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003 #include "EthernetInterface.h"
00004 #include "FTPClient.h"
00005 #include <string.h>
00006 #include <stdio.h>
00007 #define FTP_SERVER_PORT     21
00008  static char buf[256];
00009 static char ID[]={"user"};                   //Set FTPServer Login ID
00010 static char PASSWORD[]={"1234"};             //Set FTPServer Login Password
00011 FTPClient FTP(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500 
00012 Serial pc(USBTX, USBRX);
00013 int main() {
00014      pc.baud(9600);
00015     
00016     pc.printf("------------------------------FTP Client Example-------------------------------------------!\r\n"); 
00017       
00018   
00019     char ftpServer_control_ip_addr[] = "demo.wftpserver.com"; // FTP Server location
00020     char* userid = "demo-user"; //FTP Server User ID
00021     char* password = "demo-user"; //FTP Server Password
00022       EthernetInterface eth;
00023       uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x12, 0x34, 0x45};
00024       char IP_Addr[] = "192.168.0.100";
00025 char IP_Subnet[] = "255.255.255.0";
00026 char IP_Gateway[] = "192.168.0.1";
00027     eth.init(mac_addr, IP_Addr, IP_Subnet, IP_Gateway); //Use Static
00028     eth.connect();
00029     pc.printf("The IP address of the client is %s\r\n",eth.getIPAddress());
00030     
00031     while(1) {
00032        char Msg_c = pc.getc();
00033             
00034     if(Msg_c==0x31){
00035                
00036                     pc.printf("Connecting...FTPServer\r\nIP:%s, PORT:%d\r\n", ftpServer_control_ip_addr, FTP_SERVER_PORT);
00037                    int n  = FTP.open("demo.wftpserver.com", 21,"demo-user","demo-user");
00038                     pc.printf("%d\r\n",n);
00039                      wait(10);
00040                     printf("The Files and folders available in the server are :\r\n");
00041                     FTP.ls();
00042                     printf("\r\n");
00043                      wait(10);
00044                     printf("The Files in upload folder are :\r\n");
00045                     FTP.cd("/upload");
00046                     FTP.ls();
00047                     wait(10);
00048                     printf("The Files in download folder are :\r\n");
00049                     FTP.cd("/download");
00050                     FTP.ls();
00051                     printf("\r\n");
00052                    wait(10);
00053                      
00054             }    
00055 
00056              
00057      }    
00058             
00059 
00060 }