ftp server and client using Wizfi310

Dependencies:   FTPClient SDFileSystem WizFi310Interface_Legacynew mbed

Fork of Manas_FTP_SD_card_wizwikiw7500 by Manas Deka

Files at this revision

API Documentation at this revision

Comitter:
Dxmanas
Date:
Thu Feb 01 08:01:47 2018 +0000
Parent:
4:3ccf1cd64c84
Commit message:
commit

Changed in this revision

FTPClient.lib Show annotated file Show diff for this revision Revisions of this file
WIZnetInterface.lib Show diff for this revision Revisions of this file
WizFi310Interface_Legacynew.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3ccf1cd64c84 -r 13323caa45d6 FTPClient.lib
--- a/FTPClient.lib	Wed Jan 31 02:54:37 2018 +0000
+++ b/FTPClient.lib	Thu Feb 01 08:01:47 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/akshaytom/code/FTPClient/#8ecc32e7c69b
+https://os.mbed.com/users/Dxmanas/code/FTPClient/#087a3ccad604
diff -r 3ccf1cd64c84 -r 13323caa45d6 WIZnetInterface.lib
--- a/WIZnetInterface.lib	Wed Jan 31 02:54:37 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/akshaytom/code/WIZnetInterface/#584efa51ee60
diff -r 3ccf1cd64c84 -r 13323caa45d6 WizFi310Interface_Legacynew.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WizFi310Interface_Legacynew.lib	Thu Feb 01 08:01:47 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Dxmanas/code/WizFi310Interface_Legacynew/#4a014b170d40
diff -r 3ccf1cd64c84 -r 13323caa45d6 main.cpp
--- a/main.cpp	Wed Jan 31 02:54:37 2018 +0000
+++ b/main.cpp	Thu Feb 01 08:01:47 2018 +0000
@@ -1,82 +1,62 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
-#include "EthernetInterface.h"
+#include "WizFi310Interface.h"
 #include "FTPClient.h"
 #include <string.h>
 #include <stdio.h>
+
 #define FTP_SERVER_PORT     21
- static char buf[256];
+#define SECURE WizFi310::SEC_WPA2_MIXED
+#define SSID "cdi1"
+#define PASS "cdilab17"
  
 FTPClient FTP(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500 
+#if defined(TARGET_WIZwiki_W7500)
+WizFi310Interface wizfi310(D1, D0, D7, D6, D8, NC, 115200);
 Serial pc(USBTX, USBRX);
+#endif
+
 int main() {
-    pc.baud(9600);
+    pc.baud(115200);
     
     pc.printf("------------------------------FTP Client Example-------------------------------------------!\r\n"); 
       
   
-    char ftpServer_control_ip_addr[] = "172.16.126.15"; // FTP Server location
+   // char ftpServer_control_ip_addr[] = "172.16.126.15"; // FTP Server location
     
-    EthernetInterface eth;
-    uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x12, 0x34, 0x45};
-    char IP_Addr[] = "192.168.0.101";
-    char IP_Subnet[] = "255.255.255.0";
-    char IP_Gateway[] = "192.168.0.1";
-    eth.init(mac_addr, IP_Addr, IP_Subnet, IP_Gateway); //Use Static
-    eth.connect();
-    pc.printf("\nThe IP address of the client is %s\r\n",eth.getIPAddress());
     
-    //while(1) {     
-                    pc.printf("\nConnecting...FTPServer\r\nIP:%s, PORT:%d\r\n", ftpServer_control_ip_addr, FTP_SERVER_PORT);
-                   
-                   /*TO connect to online Server uncomment the below line*/ 
-                    //FTP.open("demo.wftpserver.com");
-                    
-                    //bool n  = FTP.open("192.168.0.100", 21,"FTP","user");
-                    bool n  = FTP.open("demo.wftpserver.com", 21,"demo-user","demo-user");
-                    printf("\nThe Files and folders available in the server are :\r\n");
-                    FTP.ls();
-                    printf("\r\n");
-                    wait(10);
-                    //FTP.getfile("/sd/mbl123.txt","m.txt");
-                    printf("The Files in upload folder are :\r\n");
-                    FTP.cd("/upload");
-                    FTP.ls();
-                    //FTP.getfile("/sd/bcdef.jpeg","Label.jpeg");
+    wizfi310.init();
+    if ( wizfi310.connect(SECURE, SSID, PASS, WizFi310::WM_STATION))      return -1;
+    printf("After Connect. \r\n");
+    printf("IP Address of client is %s\r\n", wizfi310.getIPAddress());
+    pc.printf("\nConnecting...FTPServer\r\n");
                     
-                    wait(10);
-                    //FTP.putfile("/sd/vlcsnap-3279000.jpg","manas2.jpg");
-                    printf("The Files in download folder are :\r\n");
-                    FTP.cd("/download");
-                    FTP.ls();
-                    printf("\r\n");
-                    wait(10);
-                   // FTP.cd("/image");
-                   // FTP.ls();
-                    /*
-                    To get file from server to client use command "getfile" and to upload file from client to server use command "putfile"
-                    //Example of uploading a image file from server to client 
-                    FTP.getfile("/ftp/vlcsnap-3279000.jpg","vlcsnap-3279000.jpg");
-                    printf("succesfull getting image from server");
-                    */
-                    //Uploading a text file from server named as m.txt
-                    
-                    //FTP.getfile("/ftp/upload/m.txt","m.txt");
-                    //FTP.dir();
-                    //wait(10);
-                    //FTP.cd("/download");*/
-                    //creating directory/folder 
-                    //FTP.mkdir("test1");
-                     //FTP.cd("test1");
-                     //Uploading image file from client that is "sd" card in this case to server
-                     //name of image is vlcsnap-3279000.jpg in sd card but will be stored as k.jpg in server
-                    //FTP.putfile("/sd/vlcsnap-3279000.jpg","kl.jpg");
-                    //FTP.dir();
-                    //wait(10);
-                    //To disconnect the FTP connection
-                    printf("Completed .. you may exit now.");
-                    FTP.quit();
-            
-
-//}
+    //bool n  = FTP.open("172.16.226.36", 21,"FTP","user");
+    /*TO connect to online Server uncomment the below line*/
+    bool n  = FTP.open("demo.wftpserver.com", 21,"demo-user","demo-user");
+    
+    printf("\nThe Files and folders available in the server are :\r\n");
+    FTP.ls();
+    printf("\r\n");
+    wait(10);
+    /*printf("\n the recieved file is:");
+    FTP.getfile("/sd/mb.txt","m.txt");
+    printf("\nFile recieved successful");*/
+    
+    printf("The Files in upload folder are :\r\n");
+    FTP.cd("/upload");
+    FTP.ls();
+    //FTP.getfile("/sd/dict.db","dict.db");
+    wait(10);
+    //FTP.putfile("/sd/vlcsnap-3279000.jpg","mpd.jpg");
+    
+    printf("The Files in download folder are :\r\n");
+    FTP.cd("/download");
+    FTP.ls();
+    printf("\r\n");
+    wait(10);
+    
+     //To disconnect the FTP connection
+    printf("\nCompleted .. you may exit now.\n");
+    FTP.quit();
 }
\ No newline at end of file