+
+ #define STORAGE_MANAGER sdff
+ #define FTP_FILE FileFs
+ #define FTP_DIR DirFs
+ extern FatFsClass STORAGE_MANAGER;
+ #define O_READ FA_READ
+ #define O_WRITE FA_WRITE
+ #define O_RDWR FA_READ | FA_WRITE
+ #define O_CREAT FA_CREATE_ALWAYS
+ #define O_APPEND FA_OPEN_APPEND
+
+ #define FTP_FILE_READ O_READ
+ #define FTP_FILE_READ_ONLY O_RDONLY
+ #define FTP_FILE_READ_WRITE O_RDWR
+ #define FTP_FILE_WRITE_APPEND O_WRITE | O_APPEND
+ #define FTP_FILE_WRITE_CREATE O_WRITE | O_CREAT
+#endif
+
+//#ifdef FTP_CLIENT_NETWORK_SSL_CLASS
+//#define FTP_CLIENT_NETWORK_CLASS FTP_CLIENT_NETWORK_SSL_CLASS
+//#endif
+
+#define OPEN_CLOSE_SPIFFS
+#define OPEN_CLOSE_SD
+
+// Setup debug printing macros.
+#ifdef FTP_SERVER_DEBUG
+ #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
+ #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
+#else
+ #define DEBUG_PRINT(...) {}
+ #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
+
+#define FF_MAX_LFN 255 // max size of a long file name
+#define FTP_CMD_SIZE FF_MAX_LFN+8 // max size of a command
+#define FTP_CWD_SIZE FF_MAX_LFN+8 // max size of a directory name
+#define FTP_FIL_SIZE FF_MAX_LFN // max size of a file name
+#define FTP_CRED_SIZE 16 // max size of username and password
+#define FTP_NULLIP() IPAddress(0,0,0,0)
+
+enum ftpCmd { FTP_Stop = 0, // In this stage, stop any connection
+ FTP_Init, // initialize some variables
+ FTP_Client, // wait for client connection
+ FTP_User, // wait for user name
+ FTP_Pass, // wait for user password
+ FTP_Cmd }; // answers to commands
+
+enum ftpTransfer { FTP_Close = 0, // In this stage, close data channel
+ FTP_Retrieve, // retrieve file
+ FTP_Store, // store file
+ FTP_List, // list of files
+ FTP_Nlst, // list of name of files
+ FTP_Mlsd }; // listing for machine processing
+
+enum ftpDataConn { FTP_NoConn = 0,// No data connexion
+ FTP_Pasive, // Pasive type
+ FTP_Active }; // Active type
+
+enum FtpOperation {
+ FTP_CONNECT,
+ FTP_DISCONNECT,
+ FTP_FREE_SPACE_CHANGE
+};
+
+enum FtpTransferOperation {
+ FTP_UPLOAD_START = 0,
+ FTP_UPLOAD = 1,
+
+ FTP_DOWNLOAD_START = 2,
+ FTP_DOWNLOAD = 3,
+
+
+ FTP_TRANSFER_STOP = 4,
+ FTP_DOWNLOAD_STOP = 4,
+ FTP_UPLOAD_STOP = 4,
+
+ FTP_TRANSFER_ERROR = 5,
+ FTP_DOWNLOAD_ERROR = 5,
+ FTP_UPLOAD_ERROR = 5
+};
+
+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 credentials( const char * _user, const char * _pass );
+ uint8_t handleFTP();
+
+ void setCallback(void (*_callbackParam)(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace) )
+ {
+ _callback = _callbackParam;
+ }
+
+ void setTransferCallback(void (*_transferCallbackParam)(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize) )
+ {
+ _transferCallback = _transferCallbackParam;
+ }
+
+private:
+ void (*_callback)(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){};
+ void (*_transferCallback)(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){};
+
+ void iniVariables();
+ void clientConnected();
+ void disconnectClient();
+ bool processCommand();
+ bool haveParameter();
+ int dataConnect( bool out150 = true );
+ bool dataConnected();
+ bool doRetrieve();
+ bool doStore();
+ bool doList();
+ bool doMlsd();
+ void closeTransfer();
+ void abortTransfer();
+ bool makePath( char * fullName, char * param = NULL );
+ bool makeExistsPath( char * path, char * param = NULL );
+ bool openDir( FTP_DIR * pdir );
+ bool isDir( char * path );
+ uint8_t getDateTime( char * dt, uint16_t * pyear, uint8_t * pmonth, uint8_t * pday,
+ uint8_t * phour, uint8_t * pminute, uint8_t * second );
+ char * makeDateTimeStr( char * tstr, uint16_t date, uint16_t time );
+ bool timeStamp( char * path, uint16_t year, uint8_t month, uint8_t day,
+ uint8_t hour, uint8_t minute, uint8_t second );
+ bool getFileModTime( char * path, uint16_t * pdate, uint16_t * ptime );
+#if STORAGE_TYPE != STORAGE_FATFS
+ bool getFileModTime( uint16_t * pdate, uint16_t * ptime );
+#endif
+ int8_t readChar();
+
+ const char* getFileName(FTP_FILE *file){
+ #if STORAGE_TYPE <= STORAGE_SDFAT2
+ int max_characters = 100;
+ char f_name[max_characters];
+ file->getName(f_name, max_characters);
+ String filename = String(f_name);
+ return filename.c_str();
+ #elif STORAGE_TYPE == STORAGE_FATFS
+ return file->fileName();
+ #else
+ return file->path();
+ #endif
+ }
+ bool exists( const char * path ) {
+#if STORAGE_TYPE == STORAGE_SPIFFS || (STORAGE_TYPE == STORAGE_SD && FTP_SERVER_NETWORK_TYPE == NETWORK_ESP8266_242)
+ if (strcmp(path, "/") == 0) return true;
+#endif
+#if STORAGE_TYPE == STORAGE_FFAT || (STORAGE_TYPE == STORAGE_LITTLEFS && defined(ESP32))
+ FTP_DIR f = STORAGE_MANAGER.open(path, "r");
+ return (f == true);
+#else
+ return STORAGE_MANAGER.exists( path );
+#endif
+ };
+ bool remove( const char * path ) { return STORAGE_MANAGER.remove( path ); };
+#if STORAGE_TYPE == STORAGE_SPIFFS
+ bool makeDir( const char * path ) { return false; };
+ bool removeDir( const char * path ) { return false; };
+#else
+ bool makeDir( const char * path ) { return STORAGE_MANAGER.mkdir( path ); };
+ bool removeDir( const char * path ) { return STORAGE_MANAGER.rmdir( path ); };
+#endif
+
+#if STORAGE_TYPE == STORAGE_SD
+ bool rename( const char * path, const char * newpath );
+#else
+ bool rename( const char * path, const char * newpath ) { return STORAGE_MANAGER.rename( path, newpath ); };
+#endif
+#if (STORAGE_TYPE == STORAGE_SEEED_SD)
+ bool openFile( char path[ FTP_CWD_SIZE ], int readTypeInt );
+#elif (STORAGE_TYPE == STORAGE_SD && defined(ESP8266))// FTP_SERVER_NETWORK_TYPE_SELECTED == NETWORK_ESP8266_242)
+ bool openFile( char path[ FTP_CWD_SIZE ], int readTypeInt );
+#elif (STORAGE_TYPE == STORAGE_SPIFFS || STORAGE_TYPE == STORAGE_LITTLEFS || STORAGE_TYPE == STORAGE_FFAT )
+ bool openFile( const char * path, const char * readType );
+// bool openFile( char path[ FTP_CWD_SIZE ], int readTypeInt );
+#elif STORAGE_TYPE <= STORAGE_SDFAT2
+ bool openFile( char path[ FTP_CWD_SIZE ], int readTypeInt );
+#else
+ bool openFile( char path[ FTP_CWD_SIZE ], const char * readType );
+ bool openFile( const char * path, const char * readType );
+// bool openFile( char path[ FTP_CWD_SIZE ], int readTypeInt );
+#endif
+// bool openFile( char path[ FTP_CWD_SIZE ], const char * readType );
+// bool openFile( const char * path, const char * readType );
+ uint16_t fileSize( FTP_FILE file );
+
+#if STORAGE_TYPE == STORAGE_SPIFFS || STORAGE_TYPE == STORAGE_LITTLEFS
+#if ESP8266
+ uint32_t capacity() {
+ FSInfo fi;
+ STORAGE_MANAGER.info(fi);
+
+ return fi.totalBytes >> 1;
+ };
+ uint32_t free() {
+ FSInfo fi;
+ STORAGE_MANAGER.info(fi);
+
+ return fi.totalBytes -
+ fi.usedBytes >> 1;
+ };
+#else
+ uint32_t capacity() {
+ return STORAGE_MANAGER.totalBytes() >> 1;
+ };
+ uint32_t free() {
+ return (STORAGE_MANAGER.totalBytes() -
+ STORAGE_MANAGER.usedBytes()) >> 1;
+ };
+#endif
+#elif STORAGE_TYPE == STORAGE_SD
+ uint32_t capacity() { return true; };
+ uint32_t free() { return true; };
+#elif STORAGE_TYPE == STORAGE_SEEED_SD
+ uint32_t capacity() {
+ return STORAGE_MANAGER.totalBytes() >> 1;
+ };
+ uint32_t free() {
+ return (STORAGE_MANAGER.totalBytes() -
+ STORAGE_MANAGER.usedBytes()) >> 1;
+ };
+#elif STORAGE_TYPE == STORAGE_SDFAT1
+ uint32_t capacity() { return STORAGE_MANAGER.card()->cardSize() >> 1; };
+ uint32_t free() { return STORAGE_MANAGER.vol()->freeClusterCount() *
+ STORAGE_MANAGER.vol()->sectorsPerCluster() >> 1; };
+#elif STORAGE_TYPE == STORAGE_SDFAT2
+ uint32_t capacity() { return STORAGE_MANAGER.card()->sectorCount() >> 1; };
+ uint32_t free() { return STORAGE_MANAGER.vol()->freeClusterCount() *
+ STORAGE_MANAGER.vol()->sectorsPerCluster() >> 1; };
+#elif STORAGE_TYPE == STORAGE_SPIFM
+ uint32_t capacity() { return flash.size() >> 10; };
+ uint32_t free() { return 0; }; // TODO //
+#elif STORAGE_TYPE == STORAGE_FATFS
+ uint32_t capacity() { return STORAGE_MANAGER.capacity(); };
+ uint32_t free() { return STORAGE_MANAGER.free(); };
+#elif STORAGE_TYPE == STORAGE_FFAT
+ uint32_t capacity() { return STORAGE_MANAGER.totalBytes(); };
+ uint32_t free() { return STORAGE_MANAGER.freeBytes(); };
+#endif
+ bool legalChar( char c ) // Return true if char c is allowed in a long file name
+ {
+ if( c == '"' || c == '*' || c == '?' || c == ':' ||
+ c == '<' || c == '>' || c == '|' )
+ return false;
+#if STORAGE_TYPE == STORAGE_FATFS
+ return 0x1f < c && c < 0xff;
+#else
+ return 0x1f < c && c < 0x7f;
+#endif
+ }
+
+ IPAddress localIp; // IP address of server as seen by clients
+ IPAddress dataIp; // IP address of client for data
+ FTP_SERVER_NETWORK_SERVER_CLASS ftpServer;
+ FTP_SERVER_NETWORK_SERVER_CLASS dataServer;
+
+
+ FTP_CLIENT_NETWORK_CLASS client;
+ FTP_CLIENT_NETWORK_CLASS data;
+
+ FTP_FILE file;
+ FTP_DIR dir;
+
+ ftpCmd cmdStage; // stage of ftp command connexion
+ ftpTransfer transferStage; // stage of data connexion
+ ftpDataConn dataConn; // type of data connexion
+
+ uint8_t __attribute__((packed, aligned(4))) // need to be aligned to 32bit for Esp8266 SPIClass::transferBytes()
+ buf[ FTP_BUF_SIZE ]; // data buffer for transfers
+ char cmdLine[ FTP_CMD_SIZE ]; // where to store incoming char from client
+ char cwdName[ FTP_CWD_SIZE ]; // name of current directory
+ char rnfrName[ FTP_CWD_SIZE ]; // name of file for RNFR command
+ const char * user; // user name
+ const char * pass; // password
+ char command[ 5 ]; // command sent by client
+ bool rnfrCmd; // previous command was RNFR
+ char * parameter; // point to begin of parameters sent by client
+ const char * welcomeMessage;
+ uint16_t cmdPort,
+ pasvPort,
+ dataPort;
+ uint16_t iCL; // pointer to cmdLine next incoming char
+ uint16_t nbMatch;
+
+ uint32_t millisDelay, //
+ millisEndConnection, //
+ millisBeginTrans, // store time of beginning of a transaction
+ bytesTransfered; //
+};
+
+#endif // FTP_SERVER_H
diff --git a/lib/SimpleFTPServer/FtpServerKey.h b/lib/SimpleFTPServer/FtpServerKey.h
new file mode 100644
index 00000000..fef50767
--- /dev/null
+++ b/lib/SimpleFTPServer/FtpServerKey.h
@@ -0,0 +1,82 @@
+/*
+ * FtpServer Arduino, esp8266 and esp32 library for Ftp Server
+ * Derived form Jean-Michel Gallego version
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+/*******************************************************************************
+ ** **
+ ** SETTINGS FOR FTP SERVER **
+ ** **
+ *******************************************************************************/
+
+#ifndef FTP_SERVER_CONFIG_H
+#define FTP_SERVER_CONFIG_H
+
+// Uncomment to enable printing out nice debug messages.
+//#define FTP_SERVER_DEBUG
+
+// Define where debug output will be printed.
+#define DEBUG_PRINTER Serial
+
+#define STORAGE_SDFAT1 0 // Library SdFat version 1.4.x
+#define STORAGE_SDFAT2 1 // Library SdFat version >= 2.0.2
+#define STORAGE_SPIFM 2 // Libraries Adafruit_SPIFlash and SdFat-Adafruit-Fork
+#define STORAGE_FATFS 3 // Library FatFs
+#define STORAGE_SD 4 // Standard SD library (suitable for Arduino esp8266 and esp32
+#define STORAGE_SPIFFS 5 // SPIFFS
+#define STORAGE_LITTLEFS 6 // LITTLEFS
+#define STORAGE_SEEED_SD 7 // Seeed_SD library
+#define STORAGE_FFAT 8 // ESP32 FFAT
+
+#define NETWORK_ESP8266_ASYNC (0)
+#define NETWORK_ESP8266 (1)
+#define NETWORK_ESP8266_242 (6)
+#define NETWORK_W5100 (2)
+#define NETWORK_ENC28J60 (3)
+#define NETWORK_ESP32 (4)
+#define NETWORK_ESP32_ETH (5)
+#define NETWORK_WiFiNINA (7)
+#define NETWORK_SEEED_RTL8720DN (8)
+
+#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266
+ #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266 NETWORK_ESP8266
+ #define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_LITTLEFS
+#endif
+#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32
+ #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32 NETWORK_ESP32
+ #define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SPIFFS
+#endif
+#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ARDUINO
+ #define DEFAULT_FTP_SERVER_NETWORK_TYPE_ARDUINO NETWORK_W5100
+ #define DEFAULT_STORAGE_TYPE_ARDUINO STORAGE_SDFAT2
+#endif
+#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ARDUINO_SAMD
+// Wio Terminal
+// #define DEFAULT_FTP_SERVER_NETWORK_TYPE_SAMD NETWORK_SEEED_RTL8720DN
+// #define DEFAULT_STORAGE_TYPE_SAMD STORAGE_SEEED_SD
+// Arduino SAMD
+ #define DEFAULT_FTP_SERVER_NETWORK_TYPE_SAMD NETWORK_WiFiNINA // NETWORK_SEEED_RTL8720DN // NETWORK_WiFiNINA
+ #define DEFAULT_STORAGE_TYPE_SAMD STORAGE_SD // STORAGE_SDFAT2 // STORAGE_SD
+#endif
+
+//#define SD_CS_PIN 4
+// Disconnect client after 5 minutes of inactivity (expressed in seconds)
+#define FTP_TIME_OUT 5 * 60
+
+
+// Wait for authentication for 10 seconds (expressed in seconds)
+#define FTP_AUTH_TIME_OUT 10
+
+
+// Size of file buffer for read/write
+// Transfer speed depends of this value
+// Best value depends on many factors: SD card, client side OS, ...
+// But it can be reduced to 512 if memory usage is critical.
+#define FTP_BUF_SIZE 2048 //1024 // 512
+
+#endif // FTP_SERVER_CONFIG_H
diff --git a/lib/SimpleFTPServer/LICENSE.md b/lib/SimpleFTPServer/LICENSE.md
new file mode 100644
index 00000000..54153141
--- /dev/null
+++ b/lib/SimpleFTPServer/LICENSE.md
@@ -0,0 +1,24 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 Renzo Mischianti www.mischianti.org All right reserved.
+
+You may copy, alter and reuse this code in any way you like, but please leave
+reference to www.mischianti.org in your comments if you redistribute this code.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/lib/SimpleFTPServer/README.md b/lib/SimpleFTPServer/README.md
new file mode 100644
index 00000000..1a8130cd
--- /dev/null
+++ b/lib/SimpleFTPServer/README.md
@@ -0,0 +1,90 @@
+# SimpleFTPServer
+
+[Instruction on FTP server on esp8266 and esp32](https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32)
+[Simple FTP Server library now with support for Wio Terminal and SD](https://www.mischianti.org/2021/07/01/simple-ftp-server-library-now-with-support-for-wio-terminal-and-sd/)
+
+Simple FTP Server for
+ - esp8266 (Flash: SPIFFs, LittleFS. SD: SD, SdFat 2)
+ - esp32 (SPIFFS, LITTLEFS, FFAT, SdFat)
+ - Arduino (SD with 8.3 file format, SdFat 2)
+ - Wio Terminal (SdFat 2, and native FAT)
+
+
+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.
+
+
+
+ In detail I separate the REST layer (written inside the microcontroller) and the Front-End (written in Angular, React/Redux or vanilla JS), so I'd like to upload new web interface directly to the microcontroller via FTP.
+
+
+
+
+
+
+
+For static information (Web pages for examples), that not change frequently, esp8266 or esp32 have internal SPIFFS (SPI Flash File System) and you can upload data via Arduino IDE as explained in the article "WeMos D1 mini (esp8266), integrated SPIFFS Filesystem" for esp8266 or "ESP32: integrated SPIFFS FileSystem" for esp32 or with LittleFS "WeMos D1 mini (esp8266), integrated LittleFS Filesystem" but for fast operation and future support It's usefully use FTP.
+
+
+
+
+```cpp
+/*
+ * FtpServer esp8266 and esp32 with SPIFFS
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+#ifdef ESP8266
+#include
+#elif defined ESP32
+#include
+#include "SPIFFS.h"
+#endif
+
+#include
+
+const char* ssid = "YOUR_SSID";
+const char* password = "YOUR_PASS";
+
+
+FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
+
+
+void setup(void){
+ Serial.begin(115200);
+ WiFi.begin(ssid, password);
+ Serial.println("");
+
+ // Wait for connection
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+ }
+ Serial.println("");
+ Serial.print("Connected to ");
+ Serial.println(ssid);
+ Serial.print("IP address: ");
+ Serial.println(WiFi.localIP());
+
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+#ifdef ESP32 //esp32 we send true to format spiffs if cannot mount
+ if (SPIFFS.begin(true)) {
+#elif defined ESP8266
+ if (SPIFFS.begin()) {
+#endif
+ Serial.println("SPIFFS opened!");
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
+ }
+}
+void loop(void){
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+ // server.handleClient(); //example if running a webserver you still need to call .handleClient();
+
+}
+```
\ No newline at end of file
diff --git a/lib/SimpleFTPServer/SimpleFTPServer.h b/lib/SimpleFTPServer/SimpleFTPServer.h
new file mode 100644
index 00000000..894c359c
--- /dev/null
+++ b/lib/SimpleFTPServer/SimpleFTPServer.h
@@ -0,0 +1,18 @@
+/*
+ * FtpServer Arduino, esp8266 and esp32 library for Ftp Server
+ * Derived form https://github.com/nailbuster/esp8266FTPServer
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+#ifndef SIMPLE_FTP_SERVER_H
+#define SIMPLE_FTP_SERVER_H
+
+#include "FtpServer.h"
+
+#endif
+
+#pragma once
diff --git a/lib/SimpleFTPServer/examples/FTPServer_Arduino_Ethernet/FTPServer_Arduino_Ethernet.ino b/lib/SimpleFTPServer/examples/FTPServer_Arduino_Ethernet/FTPServer_Arduino_Ethernet.ino
new file mode 100644
index 00000000..af178521
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_Arduino_Ethernet/FTPServer_Arduino_Ethernet.ino
@@ -0,0 +1,62 @@
+/*
+ * FtpServer Arduino with Ethernet library and w5100 shield
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+#include
+#include
+#include "SD.h"
+
+#include
+
+// Enter a MAC address for your controller below.
+// Newer Ethernet shields have a MAC address printed on a sticker on the shield
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xE1 };
+
+// Set the static IP address to use if the DHCP fails to assign
+byte macAddr[] = {0x5e, 0xa4, 0x18, 0xf0, 0x8a, 0xf2};
+IPAddress arduinoIP(192, 168, 1, 177);
+IPAddress dnsIP(192, 168, 1, 1);
+IPAddress gatewayIP(192, 168, 1, 1);
+IPAddress subnetIP(255, 255, 255, 0);
+
+FtpServer ftpSrv;
+
+void setup(void){
+ Serial.begin(115200);
+ delay(2000);
+ // If other chips are connected to SPI bus, set to high the pin connected
+ // to their CS before initializing Flash memory
+ pinMode( 4, OUTPUT );
+ digitalWrite( 4, HIGH );
+ pinMode( 10, OUTPUT );
+ digitalWrite( 10, HIGH );
+
+ Serial.print("Starting SD.");
+ while (!SD.begin(4)) {
+ Serial.print(".");
+ }
+ Serial.println("finish!");
+
+ // start the Ethernet connection:
+ Serial.print("Starting ethernet.");
+ if (Ethernet.begin(mac) == 0) {
+ Serial.println("Failed to configure Ethernet using DHCP");
+ Ethernet.begin(macAddr, arduinoIP, dnsIP, gatewayIP, subnetIP);
+ }else{
+ Serial.println("ok to configure Ethernet using DHCP");
+ }
+
+ Serial.print("IP address ");
+ Serial.println(Ethernet.localIP());
+
+ Serial.println("SPIFFS opened!");
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp.
+}
+void loop(void){
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+}
diff --git a/lib/SimpleFTPServer/examples/FTPServer_Arduino_esp32_SD/FTPServer_Arduino_esp32_SD.ino b/lib/SimpleFTPServer/examples/FTPServer_Arduino_esp32_SD/FTPServer_Arduino_esp32_SD.ino
new file mode 100644
index 00000000..c28dcf0b
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_Arduino_esp32_SD/FTPServer_Arduino_esp32_SD.ino
@@ -0,0 +1,96 @@
+/*
+ * FtpServer esp8266 and esp32 with SD
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+#include
+#include "SD.h"
+
+#include
+
+const char* ssid = "";
+const char* password = "";
+
+
+FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
+
+void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){
+ Serial.print(">>>>>>>>>>>>>>> _callback " );
+ Serial.print(ftpOperation);
+ /* FTP_CONNECT,
+ * FTP_DISCONNECT,
+ * FTP_FREE_SPACE_CHANGE
+ */
+ Serial.print(" ");
+ Serial.print(freeSpace);
+ Serial.print(" ");
+ Serial.println(totalSpace);
+
+ // freeSpace : totalSpace = x : 360
+
+ if (ftpOperation == FTP_CONNECT) Serial.println(F("CONNECTED"));
+ if (ftpOperation == FTP_DISCONNECT) Serial.println(F("DISCONNECTED"));
+};
+void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){
+ Serial.print(">>>>>>>>>>>>>>> _transferCallback " );
+ Serial.print(ftpOperation);
+ /* FTP_UPLOAD_START = 0,
+ * FTP_UPLOAD = 1,
+ *
+ * FTP_DOWNLOAD_START = 2,
+ * FTP_DOWNLOAD = 3,
+ *
+ * FTP_TRANSFER_STOP = 4,
+ * FTP_DOWNLOAD_STOP = 4,
+ * FTP_UPLOAD_STOP = 4,
+ *
+ * FTP_TRANSFER_ERROR = 5,
+ * FTP_DOWNLOAD_ERROR = 5,
+ * FTP_UPLOAD_ERROR = 5
+ */
+ Serial.print(" ");
+ Serial.print(name);
+ Serial.print(" ");
+ Serial.println(transferredSize);
+};
+
+void setup(void){
+ Serial.begin(115200);
+ WiFi.begin(ssid, password);
+ Serial.println("");
+
+ // Wait for connection
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+ }
+ Serial.println("");
+ Serial.print("Connected to ");
+ Serial.println(ssid);
+ Serial.print("IP address: ");
+ Serial.println(WiFi.localIP());
+
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+ SPI.begin(14, 2, 15, 13); //SCK, MISO, MOSI,SS
+
+ if (SD.begin(13, SPI)) {
+ Serial.println("SD opened!");
+
+ ftpSrv.setCallback(_callback);
+ ftpSrv.setTransferCallback(_transferCallback);
+
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. (default 21, 50009 for PASV)
+ }
+}
+void loop(void){
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+ // server.handleClient(); //example if running a webserver you still need to call .handleClient();
+
+}
diff --git a/lib/SimpleFTPServer/examples/FTPServer_esp8266_esp32/FTPServer_esp8266_esp32.ino b/lib/SimpleFTPServer/examples/FTPServer_esp8266_esp32/FTPServer_esp8266_esp32.ino
new file mode 100644
index 00000000..c67a1ade
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_esp8266_esp32/FTPServer_esp8266_esp32.ino
@@ -0,0 +1,110 @@
+/*
+ * FtpServer esp8266 and esp32 with SPIFFS
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32
+ *
+ */
+
+#ifdef ESP8266
+#include
+#elif defined ESP32
+#include
+#include "SPIFFS.h"
+#endif
+
+#include
+
+const char* ssid = "YOUR_SSID";
+const char* password = "YOUR_PASS";
+
+
+FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
+
+void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){
+ switch (ftpOperation) {
+ case FTP_CONNECT:
+ Serial.println(F("FTP: Connected!"));
+ break;
+ case FTP_DISCONNECT:
+ Serial.println(F("FTP: Disconnected!"));
+ break;
+ case FTP_FREE_SPACE_CHANGE:
+ Serial.printf("FTP: Free space change, free %u of %u!\n", freeSpace, totalSpace);
+ break;
+ default:
+ break;
+ }
+};
+void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){
+ switch (ftpOperation) {
+ case FTP_UPLOAD_START:
+ Serial.println(F("FTP: Upload start!"));
+ break;
+ case FTP_UPLOAD:
+ Serial.printf("FTP: Upload of file %s byte %u\n", name, transferredSize);
+ break;
+ case FTP_TRANSFER_STOP:
+ Serial.println(F("FTP: Finish transfer!"));
+ break;
+ case FTP_TRANSFER_ERROR:
+ Serial.println(F("FTP: Transfer error!"));
+ break;
+ default:
+ break;
+ }
+
+ /* FTP_UPLOAD_START = 0,
+ * FTP_UPLOAD = 1,
+ *
+ * FTP_DOWNLOAD_START = 2,
+ * FTP_DOWNLOAD = 3,
+ *
+ * FTP_TRANSFER_STOP = 4,
+ * FTP_DOWNLOAD_STOP = 4,
+ * FTP_UPLOAD_STOP = 4,
+ *
+ * FTP_TRANSFER_ERROR = 5,
+ * FTP_DOWNLOAD_ERROR = 5,
+ * FTP_UPLOAD_ERROR = 5
+ */
+};
+
+void setup(void){
+ Serial.begin(115200);
+ WiFi.begin(ssid, password);
+ Serial.println("");
+
+ // Wait for connection
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+ }
+ Serial.println("");
+ Serial.print("Connected to ");
+ Serial.println(ssid);
+ Serial.print("IP address: ");
+ Serial.println(WiFi.localIP());
+
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+
+ /////FTP Setup, ensure SPIFFS is started before ftp; /////////
+#ifdef ESP32 //esp32 we send true to format spiffs if cannot mount
+ if (SPIFFS.begin(true)) {
+#elif defined ESP8266
+ if (SPIFFS.begin()) {
+#endif
+ ftpSrv.setCallback(_callback);
+ ftpSrv.setTransferCallback(_transferCallback);
+
+ Serial.println("SPIFFS opened!");
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. (default 21, 50009 for PASV)
+ }
+}
+void loop(void){
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+ // server.handleClient(); //example if running a webserver you still need to call .handleClient();
+
+}
diff --git a/lib/SimpleFTPServer/examples/FTPServer_wio_terminal/FTPServer_wio_terminal.ino b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal/FTPServer_wio_terminal.ino
new file mode 100644
index 00000000..c6620c64
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal/FTPServer_wio_terminal.ino
@@ -0,0 +1,102 @@
+/*
+ * This sketch sends data via HTTP GET requests to examle.com service.
+ */
+
+#include
+#include "SD/Seeed_SD.h"
+
+// #define DEFAULT_FTP_SERVER_NETWORK_TYPE_SAMD NETWORK_SEEED_RTL8720DN
+// #define DEFAULT_STORAGE_TYPE_SAMD STORAGE_SEEED_SD
+
+#include
+
+#include
+
+FtpServer ftpSrv;
+
+const char *ssid = "";
+const char *password = "";
+
+void listDir(const char* dirname, uint8_t levels) {
+ Serial.print("Listing directory: ");
+ Serial.println(dirname);
+
+ File root = SD.open(dirname);
+ if (!root) {
+ Serial.println("Failed to open directory");
+ return;
+ }
+ if (!root.isDirectory()) {
+ Serial.println("Not a directory");
+ return;
+ }
+
+ File file = root.openNextFile();
+ while (file) {
+ if (file.isDirectory()) {
+ Serial.print(" DIR : ");
+ Serial.println(file.name());
+ if (levels) {
+ listDir(file.name(), levels - 1);
+ }
+ } else {
+ Serial.print(" FILE: ");
+ Serial.print(file.name());
+ Serial.print(" SIZE: ");
+ Serial.println(file.size());
+ }
+ file = root.openNextFile();
+ }
+}
+
+
+void setup()
+{
+ Serial.begin(115200);
+ delay(1000);
+
+ pinMode(5, OUTPUT);
+ digitalWrite(5, HIGH);
+
+ while (!SD.begin(SDCARD_SS_PIN,SDCARD_SPI,4000000UL)) {
+ Serial.println("Card Mount Failed");
+ return;
+ }
+
+ // We start by connecting to a WiFi network
+ Serial.println();
+ Serial.println();
+ Serial.print("Connecting to ");
+ Serial.print(ssid);
+
+ WiFi.mode(WIFI_STA);
+
+ WiFi.begin(ssid, password);
+
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ Serial.print("Connecting to ");
+ Serial.println(ssid);
+ WiFi.begin(ssid, password);
+ Serial.print(".");
+ delay(500);
+ }
+
+ Serial.println("");
+ Serial.println("WiFi connected");
+ Serial.println("IP address: ");
+ Serial.println(WiFi.localIP());
+ delay(1000);
+
+ Serial.print("Starting SD.");
+
+ Serial.println("finish!");
+
+ listDir("/", 0);
+
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp.
+ }
+
+ void loop(void) {
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+ }
diff --git a/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat/FTPServer_wio_terminal_SdFat.ino b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat/FTPServer_wio_terminal_SdFat.ino
new file mode 100644
index 00000000..155f84de
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat/FTPServer_wio_terminal_SdFat.ino
@@ -0,0 +1,98 @@
+/*
+ * This sketch sends data via HTTP GET requests to examle.com service.
+ */
+
+#include "SdFat.h"
+
+#include
+
+#include
+
+// #define DEFAULT_FTP_SERVER_NETWORK_TYPE_SAMD NETWORK_SEEED_RTL8720DN
+// #define DEFAULT_STORAGE_TYPE_SAMD STORAGE_SDFAT2
+
+#define SD_CONFIG SdSpiConfig(SDCARD_SS_PIN, 2)
+SdFs sd;
+
+FtpServer ftpSrv;
+
+const char *ssid = "";
+const char *password = "";
+
+void setup()
+{
+ Serial.begin(115200);
+ delay(1000);
+
+ pinMode(5, OUTPUT);
+ digitalWrite(5, HIGH);
+
+ // Initialize the SD.
+ if (!sd.begin(SD_CONFIG)) {
+ sd.initErrorHalt(&Serial);
+ }
+ FsFile dir;
+ FsFile file;
+
+ // Open root directory
+ if (!dir.open("/")){
+ Serial.println("dir.open failed");
+ }
+
+ // We start by connecting to a WiFi network
+
+ Serial.println();
+ Serial.println();
+ Serial.print("Connecting to ");
+ Serial.print(ssid);
+
+ WiFi.mode(WIFI_STA);
+
+
+ WiFi.begin(ssid, password);
+
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ Serial.print("Connecting to ");
+ Serial.println(ssid);
+ WiFi.begin(ssid, password);
+ Serial.print(".");
+ delay(500);
+ }
+
+ Serial.println("");
+ Serial.println("WiFi connected");
+ Serial.println("IP address: ");
+ Serial.println(WiFi.localIP());
+ delay(1000);
+
+ Serial.print("Starting SD.");
+
+ Serial.println("finish!");
+
+ while (file.openNext(&dir, O_RDONLY)) {
+ file.printFileSize(&Serial);
+ Serial.write(' ');
+ file.printModifyDateTime(&Serial);
+ Serial.write(' ');
+ file.printName(&Serial);
+ if (file.isDir()) {
+ // Indicate a directory.
+ Serial.write('/');
+ }
+ Serial.println();
+ file.close();
+ }
+ if (dir.getError()) {
+ Serial.println("openNext failed");
+ } else {
+ Serial.println("Done!");
+ }
+
+
+ ftpSrv.begin("esp8266","esp8266"); //username, password for ftp.
+ }
+
+ void loop(void) {
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+ }
diff --git a/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat_TFT_monitor/FTPServer_wio_terminal_SdFat_TFT_monitor.ino b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat_TFT_monitor/FTPServer_wio_terminal_SdFat_TFT_monitor.ino
new file mode 100644
index 00000000..86d18b19
--- /dev/null
+++ b/lib/SimpleFTPServer/examples/FTPServer_wio_terminal_SdFat_TFT_monitor/FTPServer_wio_terminal_SdFat_TFT_monitor.ino
@@ -0,0 +1,367 @@
+/*
+ * FtpServer Wio Terminal with SdFat library
+ * and with callbacks to the main actions of FTP server
+ * and a monitor on TFT
+ *
+ * AUTHOR: Renzo Mischianti
+ *
+ * https://www.mischianti.org/
+ *
+ */
+
+#include "SdFat.h"
+
+#include
+
+
+#include // Hardware-specific library
+#include
+
+#include
+
+TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
+
+#define DEG2RAD 0.0174532925
+
+byte inc = 0;
+unsigned int col = 0;
+
+#define SD_CONFIG SdSpiConfig(SDCARD_SS_PIN, 2)
+SdFs sd;
+
+FtpServer ftpSrv;
+
+const char *ssid = "reef-casa-sopra";
+const char *password = "aabbccdd77";
+
+#define MAIN_TOP 110
+
+#define FREE_SPACE_PIE_X 80
+#define FREE_SPACE_PIE_Y MAIN_TOP+40
+#define FREE_SPACE_PIE_RADIUS 50
+
+void freeSpacePieData(unsigned int freeSpace, unsigned int totalSpace) {
+ int pieFree = 360 - (freeSpace * 360 / totalSpace);
+
+ fillSegment(FREE_SPACE_PIE_X, FREE_SPACE_PIE_Y, 0, pieFree, FREE_SPACE_PIE_RADIUS, TFT_RED);
+ fillSegment(FREE_SPACE_PIE_X, FREE_SPACE_PIE_Y, pieFree, 360 - pieFree, FREE_SPACE_PIE_RADIUS, TFT_BLUE);
+
+ // Set "cursor" at top left corner of display (0,0) and select font 2
+ // (cursor will move to next line automatically during printing with 'tft.println'
+ // or stay on the line is there is room for the text with tft.print)
+ tft.setCursor(FREE_SPACE_PIE_X + 80, MAIN_TOP, 2);
+ // Set the font colour to be white with a black background, set text size multiplier to 1
+ tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextSize(1);
+ // We can now plot text on screen using the "print" class
+ Serial.print(freeSpace/1000);Serial.print("Mb/");Serial.print(String(totalSpace/1000));Serial.println("Mb");
+ tft.print(freeSpace/1000);tft.print("Mb/");tft.print(String(totalSpace/1000));tft.println("Mb");
+}
+
+void connectedDisconnected(bool connected) {
+ tft.fillCircle(FREE_SPACE_PIE_X + 80 + 10, MAIN_TOP+25+7, 10, (connected)?TFT_GREEN:TFT_RED);
+
+ tft.setCursor(FREE_SPACE_PIE_X + 80 + 25, MAIN_TOP+25, 2);
+ tft.println(" ");
+
+ tft.setCursor(FREE_SPACE_PIE_X + 80 + 25, MAIN_TOP+25, 2);
+ (connected)?tft.println("Connected!"):tft.println("Disconnected!");
+}
+
+void transfer(bool transfer, bool upload) {
+ tft.fillCircle(FREE_SPACE_PIE_X + 80 + 10, MAIN_TOP+25+25+7, 10, (transfer)?(upload)?TFT_GREEN:TFT_BLUE:TFT_RED);
+
+ tft.setCursor(FREE_SPACE_PIE_X + 80 + 25, MAIN_TOP+25+25, 2);
+ tft.println(" ");
+
+ tft.setCursor(FREE_SPACE_PIE_X + 80 + 25, MAIN_TOP+25+25, 2);
+ (transfer)?tft.println((upload)?"Upload!":"Download!"):tft.println("Idle!");
+}
+
+//index - starting at, n- how many chars
+char* subString(const char *s, int index, int n){
+ char* b = (char*) malloc((strlen(s) + 1) * sizeof(char));
+ strcpy(b,s);
+
+ Serial.println("--------------------------------------");
+ Serial.println(s);
+ Serial.println(index);
+ Serial.println(n);
+ char *res = new char[n + 1];
+ Serial.println(res);
+ sprintf(res, "%.*s", n, b + index);
+ Serial.println(res);
+ free(b);
+ return res;
+}
+
+
+void fileTransfer(FtpTransferOperation ftpOperation, const char* filename, unsigned int transferredSize) {
+ int yoffset = 2;
+
+ tft.setCursor(20, MAIN_TOP+(FREE_SPACE_PIE_RADIUS*2)+yoffset, 2);
+ tft.println(F(" "));
+
+ tft.setCursor(20, MAIN_TOP+(FREE_SPACE_PIE_RADIUS*2)+yoffset, 2);
+ int lenfile = strlen(filename);
+ Serial.println(lenfile);
+ if (lenfile>22) {
+
+ tft.print(subString(filename, 0, 16));tft.print(F("~"));
+ tft.print( subString(filename, (lenfile-4), 4) );
+ } else {
+ tft.print(filename);
+ }
+ tft.setCursor(20+160, MAIN_TOP+(FREE_SPACE_PIE_RADIUS*2)+yoffset, 2);
+ tft.print(F(" "));
+ tft.setCursor(20+160, MAIN_TOP+(FREE_SPACE_PIE_RADIUS*2)+yoffset, 2);
+ tft.print(transferredSize);tft.print("Kb");
+
+ tft.setCursor(320-55, MAIN_TOP+(FREE_SPACE_PIE_RADIUS*2)+yoffset, 2);
+ switch (ftpOperation) {
+ case FTP_UPLOAD:
+ tft.setTextColor(TFT_GREEN, TFT_BLACK);
+ tft.print(F("Upload"));
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+ break;
+ case FTP_DOWNLOAD:
+ tft.setTextColor(TFT_BLUE, TFT_BLACK);
+ tft.print(F("Down"));
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+
+ break;
+ case FTP_TRANSFER_STOP:
+ tft.setTextColor(TFT_GREEN, TFT_BLACK);
+ tft.print(F("OK"));
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+
+ break;
+ case FTP_TRANSFER_ERROR:
+ tft.setTextColor(TFT_RED, TFT_BLACK);
+ tft.print(F("Error"));
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+void wifiStrenght (int8_t RSSI, bool connection = false) {
+ Serial.print("RSSI --> ");Serial.println(RSSI);
+ int marginX = 30;
+
+ int startX = 90;
+ int widthW = 320-(startX+marginX);
+
+ int startY = 60;
+ int heightY = 10;
+
+ tft.setCursor(marginX, startY - 5, 2);
+ tft.print(F(" "));
+ tft.setCursor(marginX, startY - 5, 2);
+
+ if (connection) {
+ tft.print(F("Connectint to: "));
+ tft.print(ssid);
+ }else{
+ tft.println("WiFi str: ");
+
+ // 120 : 120-RSSI = 300 : x
+
+ tft.drawRoundRect(startX, startY, widthW, heightY, 5, TFT_WHITE);
+
+ uint32_t colorRSSI = TFT_GREEN;
+ if (abs(RSSI)<55) {
+ colorRSSI = TFT_GREEN;
+ } else if (abs(RSSI)<75) {
+ colorRSSI = TFT_YELLOW;
+ } else if (abs(RSSI)<75) {
+ colorRSSI = TFT_RED;
+ }
+
+ tft.fillRoundRect(startX+1, startY+1, (120+RSSI)*widthW/120, heightY-2, 5, colorRSSI);
+
+ tft.setCursor(marginX, startY + 15, 2);
+
+ tft.print("IP: ");
+ tft.println(WiFi.localIP());
+ }
+}
+
+void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){
+ Serial.print(">>>>>>>>>>>>>>> _callback " );
+ Serial.print(ftpOperation);
+ /* FTP_CONNECT,
+ * FTP_DISCONNECT,
+ * FTP_FREE_SPACE_CHANGE
+ */
+ Serial.print(" ");
+ Serial.print(freeSpace);
+ Serial.print(" ");
+ Serial.println(totalSpace);
+
+ // freeSpace : totalSpace = x : 360
+
+ freeSpacePieData(freeSpace, totalSpace);
+
+ if (ftpOperation == FTP_CONNECT) connectedDisconnected(true);
+ if (ftpOperation == FTP_DISCONNECT) connectedDisconnected(false);
+};
+void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){
+ Serial.print(">>>>>>>>>>>>>>> _transferCallback " );
+ Serial.print(ftpOperation);
+ /* FTP_UPLOAD_START = 0,
+ * FTP_UPLOAD = 1,
+ *
+ * FTP_DOWNLOAD_START = 2,
+ * FTP_DOWNLOAD = 3,
+ *
+ * FTP_TRANSFER_STOP = 4,
+ * FTP_DOWNLOAD_STOP = 4,
+ * FTP_UPLOAD_STOP = 4,
+ *
+ * FTP_TRANSFER_ERROR = 5,
+ * FTP_DOWNLOAD_ERROR = 5,
+ * FTP_UPLOAD_ERROR = 5
+ */
+ Serial.print(" ");
+ Serial.print(name);
+ Serial.print(" ");
+ Serial.println(transferredSize);
+
+ (ftpOperation==FTP_UPLOAD || ftpOperation==FTP_DOWNLOAD)?transfer(true, ftpOperation==FTP_UPLOAD):transfer(false, false);
+
+ fileTransfer(ftpOperation, name, transferredSize);
+};
+
+
+void setup()
+{
+ ftpSrv.setCallback(_callback);
+ ftpSrv.setTransferCallback(_transferCallback);
+
+ Serial.begin(115200);
+ delay(1000);
+
+ tft.init();
+
+ tft.begin();
+
+ tft.setRotation(3);
+
+ tft.fillScreen(TFT_BLACK);
+
+ tft.setCursor(0, 0);
+
+ tft.setTextColor(TFT_BLACK, TFT_WHITE); tft.setTextSize(2);
+
+ tft.fillRoundRect(3, 3, 320-6, 40, 5, TFT_WHITE);
+
+ tft.drawCentreString("www.mischianti.org", 160, 14,1);
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+
+
+ freeSpacePieData(0, 0);
+ connectedDisconnected(false);
+ transfer(false, false);
+
+ wifiStrenght(0, true);
+
+ Serial.println();
+ Serial.println();
+ Serial.print("Connecting to ");
+ Serial.print(ssid);
+
+ WiFi.mode(WIFI_STA);
+
+
+ WiFi.begin(ssid, password);
+
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ Serial.print(".");
+ WiFi.begin(ssid, password);
+ Serial.print(".");
+ tft.print(F("."));
+ delay(500);
+ }
+
+ Serial.println("");
+ Serial.println("WiFi connected");
+ Serial.println("IP address: ");
+ Serial.println(WiFi.localIP());
+
+ wifiStrenght(WiFi.RSSI());
+
+ delay(1000);
+
+ if (!sd.begin(SD_CONFIG)) {
+ sd.initErrorHalt(&Serial);
+ }
+ FsFile dir;
+ FsFile file;
+
+ // Open root directory
+ if (!dir.open("/")){
+ Serial.println("dir.open failed");
+ }
+
+ ftpSrv.begin("wioterminal","wioterminal"); //username, password for ftp.
+
+}
+
+void loop() {
+ ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
+}
+
+
+// #########################################################################
+// Draw circle segments
+// #########################################################################
+
+// x,y == coords of centre of circle
+// start_angle = 0 - 359
+// sub_angle = 0 - 360 = subtended angle
+// r = radius
+// colour = 16 bit colour value
+
+int fillSegment(int x, int y, int start_angle, int sub_angle, int r, unsigned int colour) {
+ // Calculate first pair of coordinates for segment start
+ float sx = cos((start_angle - 90) * DEG2RAD);
+ float sy = sin((start_angle - 90) * DEG2RAD);
+ uint16_t x1 = sx * r + x;
+ uint16_t y1 = sy * r + y;
+
+ // Draw colour blocks every inc degrees
+ for (int i = start_angle; i < start_angle + sub_angle; i++) {
+
+ // Calculate pair of coordinates for segment end
+ int x2 = cos((i + 1 - 90) * DEG2RAD) * r + x;
+ int y2 = sin((i + 1 - 90) * DEG2RAD) * r + y;
+
+ tft.fillTriangle(x1, y1, x2, y2, x, y, colour);
+
+ // Copy segment end to sgement start for next segment
+ x1 = x2;
+ y1 = y2;
+ }
+}
+
+
+// #########################################################################
+// Return the 16 bit colour with brightness 0-100%
+// #########################################################################
+unsigned int brightness(unsigned int colour, int brightness) {
+ byte red = colour >> 11;
+ byte green = (colour & 0x7E0) >> 5;
+ byte blue = colour & 0x1F;
+
+ blue = (blue * brightness) / 100;
+ green = (green * brightness) / 100;
+ red = (red * brightness) / 100;
+
+ return (red << 11) + (green << 5) + blue;
+}
+
diff --git a/lib/SimpleFTPServer/keywords.txt b/lib/SimpleFTPServer/keywords.txt
new file mode 100644
index 00000000..e759b081
--- /dev/null
+++ b/lib/SimpleFTPServer/keywords.txt
@@ -0,0 +1,15 @@
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+SimpleFtpServer KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+begin KEYWORD2
+credentials KEYWORD2
+setCallback KEYWORD2
+setTransferCallback KEYWORD2
+handleFTP KEYWORD2
\ No newline at end of file
diff --git a/lib/SimpleFTPServer/library.json b/lib/SimpleFTPServer/library.json
new file mode 100644
index 00000000..f73a296b
--- /dev/null
+++ b/lib/SimpleFTPServer/library.json
@@ -0,0 +1,19 @@
+{
+ "name": "SimpleFTPServer",
+ "description": "Simple FTP Server for using esp8266 and esp32 SPIFFs",
+ "keywords": "esp8266, ftp, spiffs",
+ "authors":
+ {
+ "name": "Renzo Mischianti",
+ "email": "renzo.mischianti@gmail.com",
+ "url": "https://www.mischianti.org"
+ },
+ "repository":
+ {
+ "type": "git",
+ "url": "https://github.com/xreef/SimpleFTPServer"
+ },
+ "url": "https://www.mischianti.org",
+ "frameworks": "Arduino",
+ "platforms": "*"
+}
diff --git a/lib/SimpleFTPServer/library.properties b/lib/SimpleFTPServer/library.properties
new file mode 100644
index 00000000..44030841
--- /dev/null
+++ b/lib/SimpleFTPServer/library.properties
@@ -0,0 +1,11 @@
+name=SimpleFTPServer
+version=1.0.1
+author=Renzo Mischianti
+maintainer=Renzo Mischianti
+sentence=Simple FTP server for esp8266, esp32 and Arduino
+paragraph=Simple FTP server for esp8266 (SPIFFS and LittleFS), esp32 (SPIFFS, LittleFS ans FFAT) and Arduino (SD basic lib with 8.3 file format), Wio Terminal (SdFat 2), Arduino MKR (SdFat 2). With internal callback to chck the phase of communication.
+category=Communication
+url=https://www.mischianti.org/category/my-libraries/simple-ftp-server/
+repository=https://github.com/xreef/SimpleFTPServer.git
+architectures=*
+includes=SimpleFTPServer.h
\ No newline at end of file
diff --git a/src/hasp_debug.cpp b/src/hasp_debug.cpp
index 8c32100d..bd6e63f3 100644
--- a/src/hasp_debug.cpp
+++ b/src/hasp_debug.cpp
@@ -253,6 +253,9 @@ void debug_get_tag(uint8_t tag, char* buffer)
case TAG_DEBG:
memcpy_P(buffer, PSTR("DBUG"), 5);
break;
+ case TAG_FTP:
+ memcpy_P(buffer, PSTR("FTP "), 5);
+ break;
case TAG_TELN:
memcpy_P(buffer, PSTR("TELN"), 5);
break;
diff --git a/src/hasp_debug.h b/src/hasp_debug.h
index 9c8b59ac..c3d41c81 100644
--- a/src/hasp_debug.h
+++ b/src/hasp_debug.h
@@ -189,6 +189,7 @@ enum {
TAG_MQTT = 65,
TAG_MQTT_PUB = 66,
TAG_MQTT_RCV = 67,
+ TAG_FTP = 68,
TAG_LVGL = 90,
TAG_LVFS = 91,
diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp
index 8bf1fa23..ab759f69 100644
--- a/src/main_arduino.cpp
+++ b/src/main_arduino.cpp
@@ -106,6 +106,10 @@ void setup()
telnetSetup();
#endif
+#if HASP_USE_FTP > 0
+ ftpSetup();
+#endif
+
#if HASP_USE_TASMOTA_CLIENT > 0
slaveSetup();
#endif
diff --git a/src/sys/net/hasp_network.cpp b/src/sys/net/hasp_network.cpp
index d183955b..036cf592 100644
--- a/src/sys/net/hasp_network.cpp
+++ b/src/sys/net/hasp_network.cpp
@@ -92,9 +92,13 @@ IRAM_ATTR void networkLoop(void)
mdnsLoop();
#endif // MDNS
+#if HASP_USE_FTP > 0
+ ftpLoop();
+#endif // FTP
+
#if HASP_USE_TELNET > 0
- telnetLoop(); // Console
-#endif // TELNET
+ telnetLoop();
+#endif // TELNET
}
bool networkEvery5Seconds(void)
diff --git a/src/sys/svc/hasp_ftp.cpp b/src/sys/svc/hasp_ftp.cpp
new file mode 100644
index 00000000..88c17dba
--- /dev/null
+++ b/src/sys/svc/hasp_ftp.cpp
@@ -0,0 +1,137 @@
+/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
+ For full license information read the LICENSE file in the project folder */
+
+#include "hasplib.h"
+
+#if HASP_USE_FTP > 0
+
+#include "hasp_debug.h"
+#include "hasp_config.h"
+#include "hasp_ftp.h"
+#include "hasp_http.h"
+#include "hasp_filesystem.h"
+
+#include "../../hasp/hasp_dispatch.h"
+
+#include "FtpServerKey.h"
+#include "SimpleFTPServer.h"
+
+FtpServer ftpSrv; // set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
+
+uint16_t ftpPort = 23;
+uint8_t ftpEnabled = true; // Enable telnet debug output
+
+#if HASP_USE_HTTP > 0 || HASP_USE_HTTP_ASYNC > 0
+extern hasp_http_config_t http_config;
+static inline bool telnet_has_password()
+{
+ return (strlen(http_config.username) != 0) || (strlen(http_config.password) != 0);
+}
+#endif
+
+void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace)
+{
+ switch(ftpOperation) {
+ case FTP_CONNECT:
+ LOG_VERBOSE(TAG_FTP, F(D_SERVICE_CONNECTED));
+ break;
+ case FTP_DISCONNECT:
+ LOG_VERBOSE(TAG_FTP, F(D_SERVICE_DISCONNECTED));
+ break;
+ case FTP_FREE_SPACE_CHANGE:
+ LOG_VERBOSE(TAG_FTP, "Free space change, free %u of %u!\n", freeSpace, totalSpace);
+ break;
+ default:
+ break;
+ }
+};
+void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize)
+{
+ switch(ftpOperation) {
+ case FTP_UPLOAD_START:
+ LOG_VERBOSE(TAG_FTP, "Start upload of file %s byte %u\n", name, transferredSize);
+ break;
+ case FTP_UPLOAD:
+ LOG_VERBOSE(TAG_FTP, "Upload of file %s byte %u\n", name, transferredSize);
+ break;
+ case FTP_TRANSFER_STOP:
+ LOG_VERBOSE(TAG_FTP, "Completed upload of file %s byte %u\n", name, transferredSize);
+ break;
+ case FTP_TRANSFER_ERROR:
+ LOG_VERBOSE(TAG_FTP, ("Transfer error!"));
+ break;
+ default:
+ break;
+ }
+
+ /* FTP_UPLOAD_START = 0,
+ * FTP_UPLOAD = 1,
+ *
+ * FTP_DOWNLOAD_START = 2,
+ * FTP_DOWNLOAD = 3,
+ *
+ * FTP_TRANSFER_STOP = 4,
+ * FTP_DOWNLOAD_STOP = 4,
+ * FTP_UPLOAD_STOP = 4,
+ *
+ * FTP_TRANSFER_ERROR = 5,
+ * FTP_DOWNLOAD_ERROR = 5,
+ * FTP_UPLOAD_ERROR = 5
+ */
+};
+
+void ftpStop(void)
+{}
+
+void ftpStart()
+{
+ LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING));
+ ftpSrv.setCallback(_callback);
+ ftpSrv.setTransferCallback(_transferCallback);
+
+ ftpSrv.begin("esp8266", "esp8266"); // username, password for ftp. (default 21, 50009 for PASV)
+ LOG_INFO(TAG_TFT, F(D_SERVICE_STARTED));
+}
+
+void ftpSetup()
+{
+#if HASP_START_FTP
+ ftpStart();
+#endif
+}
+
+IRAM_ATTR void ftpLoop()
+{
+ ftpSrv.handleFTP(); // make sure in loop you call handleFTP()!!
+}
+
+void ftpEverySecond(void)
+{}
+
+#if HASP_USE_CONFIG > 0
+bool ftpGetConfig(const JsonObject& settings)
+{
+ bool changed = false;
+
+ if(changed) configOutput(settings, TAG_FTP);
+ return changed;
+}
+
+/** Set FTP Configuration.
+ *
+ * Read the settings from json and sets the application variables.
+ *
+ * @note: read config.json into memory
+ *
+ * @param[in] settings JsonObject with the config settings.
+ **/
+bool ftpSetConfig(const JsonObject& settings)
+{
+ configOutput(settings, TAG_FTP);
+ bool changed = false;
+
+ return changed;
+}
+#endif // HASP_USE_CONFIG
+
+#endif
\ No newline at end of file
diff --git a/src/sys/svc/hasp_ftp.h b/src/sys/svc/hasp_ftp.h
new file mode 100644
index 00000000..eb00f1c0
--- /dev/null
+++ b/src/sys/svc/hasp_ftp.h
@@ -0,0 +1,28 @@
+/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
+ For full license information read the LICENSE file in the project folder */
+
+#ifndef HASP_FTP_H
+#define HASP_FTP_H
+
+#if HASP_USE_FTP > 0
+
+/* ===== Default Event Processors ===== */
+void ftpSetup();
+IRAM_ATTR void ftpLoop(void);
+void ftpEvery5Seconds(void);
+void ftpEverySecond(void);
+void ftpStart(void);
+void ftpStop(void);
+
+/* ===== Special Event Processors ===== */
+
+/* ===== Getter and Setter Functions ===== */
+
+/* ===== Read/Write Configuration ===== */
+#if HASP_USE_CONFIG > 0
+bool ftpSetConfig(const JsonObject& settings);
+bool ftpGetConfig(const JsonObject& settings);
+#endif
+
+#endif
+#endif // HASP_FTP_H
diff --git a/user_setups/esp32/_esp32.ini b/user_setups/esp32/_esp32.ini
index 3160a471..8e68e5ec 100644
--- a/user_setups/esp32/_esp32.ini
+++ b/user_setups/esp32/_esp32.ini
@@ -43,7 +43,14 @@ build_flags =
-D USE_LVGL_FREETYPE_MAX_SIZES=4 ; max number of sizes in cache
-D USE_LVGL_FREETYPE_MAX_BYTES=16384 ; max bytes in cache
-D USE_LVGL_FREETYPE_MAX_BYTES_PSRAM=65536 ; max bytes in cache when using PSRAM
-
+; -- SimpleFTpServer build options -----------------
+ -D HASP_USE_FTP=1
+ ;-D FTP_SERVER_DEBUG
+ -D FTP_SERVER_NETWORK_TYPE=4 ;// NETWORK_ESP32
+ -D STORAGE_TYPE=6 ;// STORAGE_LITTLEFS
+ -D STORAGE_SD_FORCE_DISABLE
+ -D STORAGE_SPIFFS_FORCE_DISABLE
+
lib_ignore =
GxTFT
XPT2046_Touchscreen