diff --git a/FtpServer.cpp b/FtpServer.cpp index cd7a8d7..9d65877 100644 --- a/FtpServer.cpp +++ b/FtpServer.cpp @@ -79,18 +79,11 @@ void FtpServer::begin( const char * _user, const char * _pass, const char * _wel if( strlen( _user ) > 0 && strlen( _user ) < FTP_CRED_SIZE ) { //strcpy( user, _user ); this->user = _user; - }else{ -// strcpy( user, FTP_USER ); - this->user = FTP_USER; } if( strlen( _pass ) > 0 && strlen( _pass ) < FTP_CRED_SIZE ) { // strcpy( pass, _pass ); this->pass = _pass; - }else{ -// strcpy( pass, FTP_PASS ); - this->pass = FTP_PASS; } - // strcpy(_welcomeMessage, welcomeMessage); this->welcomeMessage = _welcomeMessage; @@ -124,6 +117,8 @@ void FtpServer::end() DEBUG_PRINTLN(F("Stop server!")); cmdStage = FTP_Init; + transferStage = FTP_Close; + dataConn = FTP_NoConn; } void FtpServer::setLocalIp(IPAddress localIp) { @@ -1328,16 +1323,44 @@ bool FtpServer::doList() #endif { - data.print( F("+r,s") ); - #if ESP8266 - data.print( long( dir.fileSize()) ); - data.print( F(",\t") ); - data.println( dir.fileName() ); - #else - data.print( long( fileDir.size()) ); - data.print( F(",\t") ); - data.println( fileDir.name() ); - #endif +// data.print( F("+r,s") ); +// #if ESP8266 +// data.print( long( dir.fileSize()) ); +// data.print( F(",\t") ); +// data.println( dir.fileName() ); +// #else +// data.print( long( fileDir.size()) ); +// data.print( F(",\t") ); +// data.println( fileDir.name() ); +// #endif + + + +#ifdef ESP8266 + String fn = dir.fileName(); + long fz = long( dir.fileSize()); + if (fn[0]=='/') { fn.remove(0, fn.lastIndexOf("/")+1); } + time_t time = dir.fileTime(); + generateFileLine(&data, false, fn.c_str(), fz, time, this->user); +#else + long fz = long( fileDir.size()); + const char* fnC = fileDir.name(); + const char* fn; + if ( fnC[0] == '/' ) { + fn = &fnC[1]; + }else{ + fn = fnC; + } + + time_t time = fileDir.getLastWrite(); + generateFileLine(&data, false, fn, fz, time, this->user); + +#endif + +#ifdef ESP8266 +#else +#endif + nbMatch ++; return true; } @@ -1407,9 +1430,13 @@ bool FtpServer::doList() // data.print( F(",\t") ); // data.println( dir.fileName() ); #elif STORAGE_TYPE == STORAGE_SEEED_SD - const char* fn = fileDir.name(); - fn.remove(0, strlen(dir.name())); - if (fn[0]=='/') { fn.remove(0, fn.lastIndexOf("/")+1); } + const char* fnC = fileDir.name(); + const char* fn; + if ( fnC[0] == '/' ) { + fn = &fnC[1]; + }else{ + fn = fnC; + } long fz = fileDir.size(); #else long fz = long( fileDir.size()); diff --git a/FtpServer.h b/FtpServer.h index a077e23..ebb00e2 100644 --- a/FtpServer.h +++ b/FtpServer.h @@ -398,9 +398,6 @@ #define DEBUG_PRINTLN(...) {} #endif -#define FTP_USER "arduino" // Default user'name -#define FTP_PASS "test" // Default password - #define FTP_CMD_PORT 21 // Command port on wich server is listening #define FTP_DATA_PORT_DFLT 20 // Default data port in active mode #define FTP_DATA_PORT_PASV 50009 // Data port in passive mode @@ -458,7 +455,7 @@ class FtpServer public: FtpServer( uint16_t _cmdPort = FTP_CMD_PORT, uint16_t _pasvPort = FTP_DATA_PORT_PASV ); - void begin( const char * _user = FTP_USER, const char * _pass = FTP_PASS, const char * welcomeMessage = "Welcome to Simply FTP server" ); + void begin( const char * _user, const char * _pass, const char * welcomeMessage = "Welcome to Simply FTP server" ); void begin( const char * welcomeMessage = "Welcome to Simply FTP server" ); void end(); diff --git a/FtpServerKey.h b/FtpServerKey.h index 452f412..567e6f4 100644 --- a/FtpServerKey.h +++ b/FtpServerKey.h @@ -18,7 +18,7 @@ #define FTP_SERVER_CONFIG_H // Uncomment to enable printing out nice debug messages. -// #define FTP_SERVER_DEBUG + #define FTP_SERVER_DEBUG // Define where debug output will be printed. #define DEBUG_PRINTER Serial @@ -46,11 +46,11 @@ #ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266 #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266 NETWORK_ESP8266 - #define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_LITTLEFS + #define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_SPIFFS #endif #ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32 #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32 NETWORK_ESP32 - #define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_LITTLEFS + #define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SPIFFS #endif #ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ARDUINO #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ARDUINO NETWORK_W5100 diff --git a/README.md b/README.md index f5455b6..e0fffe5 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ - Wio Terminal (SdFat 2, and native FAT) #### Changelog -- 2022-02-22 Add anonymous user and implement correct RFC (#9 now work correctly with File Explorer) -- 2022-02-01 Add workaround to start FTP server before connection, add end and setLocalIP method. +- 2022-02-25 1.2.1 Fix anonymous user begin and fix SPIFFS wrong display +- 2022-02-22 1.2.0 Add anonymous user and implement correct RFC (#9 now work correctly with File Explorer) +- 2022-02-01 1.1.1 Add workaround to start FTP server before connection, add end and setLocalIP method.

When I develop a new solution I'd like to divide the application in layer, and so I'd like focus my attention in only one aspect at time.

diff --git a/library.properties b/library.properties index 799983f..2018c72 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SimpleFTPServer -version=1.2.0 +version=1.2.1 author=Renzo Mischianti maintainer=Renzo Mischianti sentence=Simple FTP server for esp8266, esp32 and Arduino