This is FTPClient Program.

Dependencies:   SDFileSystem WIZnetInterface_Ricky mbed-src

Files at this revision

API Documentation at this revision

Comitter:
Ricky_Kwon
Date:
Thu Jul 23 00:57:19 2015 +0000
Parent:
1:89ba8e4c5f2a
Commit message:
optimization

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 89ba8e4c5f2a -r 3aa502df9b3b main.cpp
--- a/main.cpp	Tue Jul 21 15:48:01 2015 +0000
+++ b/main.cpp	Thu Jul 23 00:57:19 2015 +0000
@@ -75,10 +75,13 @@
     
     pc.printf("Hello FTPClient World!\r\n"); 
       
+    //Module IP, Please set according to your network environment.
     uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x12, 0x34, 0x45};
     const char ip_addr[] = "192.168.0.123"; 
     const char mask_addr[] = "255.255.255.0"; 
     const char gateway_addr[] = "192.168.0.1"; 
+    
+    //FTPServer IP, Please set according to your network environment.
     const char ftpServer_control_ip_addr[] = "192.168.0.230";
     
     
@@ -116,44 +119,42 @@
                 pc.printf("4> Get File from Server\r\n");
                 pc.printf("----------------------------------------\r\n");
                 //while 4
-                while(true){
-                    Msg_c = pc.getc();
-                    // Msg_c if
-                    if(Msg_c=='1'){
-                        FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
-                        FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
-                        FTPCommand.First = f_dir;
-                        break;                         
+                Msg_c = pc.getc();
+                // Msg_c if
+                if(Msg_c=='1'){
+                    FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
+                    FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
+                    FTPCommand.First = f_dir;
+                    break;                         
+                }
+                else if(Msg_c=='2'){
+                    pc.printf("Open directory on /sd/FTPClient\r\n");    
+                    DIR *d = opendir("/sd/FTPClient");              
+                    struct dirent *p;
+                    while((p = readdir(d)) != NULL) {         
+                      pc.printf("%s\r\n", p->d_name);            
                     }
-                    else if(Msg_c=='2'){
-                        pc.printf("Open directory on /sd/FTPClient\r\n");    
-                        DIR *d = opendir("/sd/FTPClient");              
-                        struct dirent *p;
-                        while((p = readdir(d)) != NULL) {         
-                          pc.printf("%s\r\n", p->d_name);            
-                        }
-                        closedir(d);
-                        gMenuStart = true;
-                        break;
-                    }
-                    else if(Msg_c=='3'){
-                        FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
-                        FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
-                        FTPCommand.First = f_put;
-                        break;
-                    }
-                    else if(Msg_c=='4'){
-                        FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
-                        FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
-                        FTPCommand.First = f_get;
-                        break;                          
-                    }
-                    else{
-                        pc.printf("Retry...\r\n");
-                        gMenuStart = true;
-                        break;  
-                    }//end of Msg_c if                                       
-                }//end of while 4
+                    closedir(d);
+                    gMenuStart = true;
+                    break;
+                }
+                else if(Msg_c=='3'){
+                    FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
+                    FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
+                    FTPCommand.First = f_put;
+                    break;
+                }
+                else if(Msg_c=='4'){
+                    FTP_CONTROL_SOCK.send(PASV, sizeof(PASV)-1);
+                    FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
+                    FTPCommand.First = f_get;
+                    break;                          
+                }
+                else{
+                    pc.printf("Retry...\r\n");
+                    gMenuStart = true;
+                    break;  
+                }//end of Msg_c if                                       
             }//end of gMenuStart if
             
             //gDataSockReady if
@@ -184,7 +185,7 @@
                         break;
                 }//end of FTPCommand.First switch case
             }//end of gDataSockReady if          
-            /* received from FTPServer */
+            /* received from FTPServer ControlSock*/
             int n = FTP_CONTROL_SOCK.receive(buf, sizeof(buf));
             if (n <= 0) break;
             buf[n] = '\0';