forked from xreef/SimpleFTPServer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fix to manage NAT and delayed start of Wifi xreef#8. Adding the…
… end and setLocalIP method
- Loading branch information
Showing
8 changed files
with
148 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
examples/FTPServer_esp8266_esp32_LittleFS/FTPServer_esp8266_esp32_LittleFS.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* FtpServer esp8266 and esp32 with LittleFS | ||
* | ||
* AUTHOR: Renzo Mischianti | ||
* | ||
* https://www.mischianti.org/2020/02/08/ftp-server-on-esp8266-and-esp32 | ||
* | ||
*/ | ||
|
||
#ifdef ESP8266 | ||
#include <ESP8266WiFi.h> | ||
#include <LittleFS.h> | ||
#elif defined ESP32 | ||
#include <WiFi.h> | ||
#include <FS.h> | ||
#include <LittleFS.h> | ||
#endif | ||
|
||
#include <SimpleFTPServer.h> | ||
|
||
const char* ssid = "<YOUR-SSID>"; | ||
const char* password = "<YOUR-PASSWD>"; | ||
|
||
|
||
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 (LittleFS.begin(true)) { | ||
#elif defined ESP8266 | ||
if (LittleFS.begin()) { | ||
#endif | ||
ftpSrv.setCallback(_callback); | ||
ftpSrv.setTransferCallback(_transferCallback); | ||
|
||
Serial.println("LittleFS opened!"); | ||
ftpSrv.begin("user","password"); //username, password for ftp. (default 21, 50009 for PASV) | ||
} | ||
} | ||
void loop(void){ | ||
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!! | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=SimpleFTPServer | ||
version=1.0.1 | ||
version=1.1.0 | ||
author=Renzo Mischianti <[email protected]> | ||
maintainer=Renzo Mischianti <[email protected]> | ||
sentence=Simple FTP server for esp8266, esp32 and Arduino | ||
|