ftp server and client using Wizfi310

Dependencies:   FTPClient SDFileSystem WizFi310Interface_Legacynew mbed

Fork of Manas_FTP_SD_card_wizwikiw7500 by Manas Deka

Committer:
Dxmanas
Date:
Thu Feb 01 08:01:47 2018 +0000
Revision:
5:13323caa45d6
Parent:
4:3ccf1cd64c84
commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wiznetw7500 0:e35dac7e4c95 1 #include "mbed.h"
wiznetw7500 0:e35dac7e4c95 2 #include "SDFileSystem.h"
Dxmanas 5:13323caa45d6 3 #include "WizFi310Interface.h"
wiznetw7500 0:e35dac7e4c95 4 #include "FTPClient.h"
wiznetw7500 0:e35dac7e4c95 5 #include <string.h>
wiznetw7500 0:e35dac7e4c95 6 #include <stdio.h>
Dxmanas 5:13323caa45d6 7
wiznetw7500 0:e35dac7e4c95 8 #define FTP_SERVER_PORT 21
Dxmanas 5:13323caa45d6 9 #define SECURE WizFi310::SEC_WPA2_MIXED
Dxmanas 5:13323caa45d6 10 #define SSID "cdi1"
Dxmanas 5:13323caa45d6 11 #define PASS "cdilab17"
Dxmanas 4:3ccf1cd64c84 12
wiznetw7500 0:e35dac7e4c95 13 FTPClient FTP(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500
Dxmanas 5:13323caa45d6 14 #if defined(TARGET_WIZwiki_W7500)
Dxmanas 5:13323caa45d6 15 WizFi310Interface wizfi310(D1, D0, D7, D6, D8, NC, 115200);
wiznetw7500 0:e35dac7e4c95 16 Serial pc(USBTX, USBRX);
Dxmanas 5:13323caa45d6 17 #endif
Dxmanas 5:13323caa45d6 18
wiznetw7500 0:e35dac7e4c95 19 int main() {
Dxmanas 5:13323caa45d6 20 pc.baud(115200);
wiznetw7500 0:e35dac7e4c95 21
wiznetw7500 0:e35dac7e4c95 22 pc.printf("------------------------------FTP Client Example-------------------------------------------!\r\n");
wiznetw7500 0:e35dac7e4c95 23
wiznetw7500 0:e35dac7e4c95 24
Dxmanas 5:13323caa45d6 25 // char ftpServer_control_ip_addr[] = "172.16.126.15"; // FTP Server location
Dxmanas 4:3ccf1cd64c84 26
wiznetw7500 0:e35dac7e4c95 27
Dxmanas 5:13323caa45d6 28 wizfi310.init();
Dxmanas 5:13323caa45d6 29 if ( wizfi310.connect(SECURE, SSID, PASS, WizFi310::WM_STATION)) return -1;
Dxmanas 5:13323caa45d6 30 printf("After Connect. \r\n");
Dxmanas 5:13323caa45d6 31 printf("IP Address of client is %s\r\n", wizfi310.getIPAddress());
Dxmanas 5:13323caa45d6 32 pc.printf("\nConnecting...FTPServer\r\n");
Dxmanas 4:3ccf1cd64c84 33
Dxmanas 5:13323caa45d6 34 //bool n = FTP.open("172.16.226.36", 21,"FTP","user");
Dxmanas 5:13323caa45d6 35 /*TO connect to online Server uncomment the below line*/
Dxmanas 5:13323caa45d6 36 bool n = FTP.open("demo.wftpserver.com", 21,"demo-user","demo-user");
Dxmanas 5:13323caa45d6 37
Dxmanas 5:13323caa45d6 38 printf("\nThe Files and folders available in the server are :\r\n");
Dxmanas 5:13323caa45d6 39 FTP.ls();
Dxmanas 5:13323caa45d6 40 printf("\r\n");
Dxmanas 5:13323caa45d6 41 wait(10);
Dxmanas 5:13323caa45d6 42 /*printf("\n the recieved file is:");
Dxmanas 5:13323caa45d6 43 FTP.getfile("/sd/mb.txt","m.txt");
Dxmanas 5:13323caa45d6 44 printf("\nFile recieved successful");*/
Dxmanas 5:13323caa45d6 45
Dxmanas 5:13323caa45d6 46 printf("The Files in upload folder are :\r\n");
Dxmanas 5:13323caa45d6 47 FTP.cd("/upload");
Dxmanas 5:13323caa45d6 48 FTP.ls();
Dxmanas 5:13323caa45d6 49 //FTP.getfile("/sd/dict.db","dict.db");
Dxmanas 5:13323caa45d6 50 wait(10);
Dxmanas 5:13323caa45d6 51 //FTP.putfile("/sd/vlcsnap-3279000.jpg","mpd.jpg");
Dxmanas 5:13323caa45d6 52
Dxmanas 5:13323caa45d6 53 printf("The Files in download folder are :\r\n");
Dxmanas 5:13323caa45d6 54 FTP.cd("/download");
Dxmanas 5:13323caa45d6 55 FTP.ls();
Dxmanas 5:13323caa45d6 56 printf("\r\n");
Dxmanas 5:13323caa45d6 57 wait(10);
Dxmanas 5:13323caa45d6 58
Dxmanas 5:13323caa45d6 59 //To disconnect the FTP connection
Dxmanas 5:13323caa45d6 60 printf("\nCompleted .. you may exit now.\n");
Dxmanas 5:13323caa45d6 61 FTP.quit();
wiznetw7500 0:e35dac7e4c95 62 }