diff options
author | nailbuster <david@nailbuster.com> | 2016-02-04 17:26:33 +0100 |
---|---|---|
committer | nailbuster <david@nailbuster.com> | 2016-02-04 17:26:33 +0100 |
commit | 0bf45c0bd5324d40c0d687101afd5f9b65f6892d (patch) | |
tree | 3d49fecf0c45a26a082e515b2c9438c6c43e17d5 /examples | |
parent | Initial commit (diff) | |
download | FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar.gz FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar.bz2 FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar.lz FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar.xz FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.tar.zst FTPCLientServer-0bf45c0bd5324d40c0d687101afd5f9b65f6892d.zip |
Diffstat (limited to 'examples')
-rw-r--r-- | examples/FTPServerSample/FTPServerSample.ino | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/examples/FTPServerSample/FTPServerSample.ino b/examples/FTPServerSample/FTPServerSample.ino new file mode 100644 index 0000000..06223df --- /dev/null +++ b/examples/FTPServerSample/FTPServerSample.ino @@ -0,0 +1,70 @@ +#include <ESP8266WiFi.h> +#include <WiFiClient.h> +#include <ESP8266WebServer.h> +#include <ESP8266FtpServer.h> + +const char* ssid = "YOUR_SSID"; +const char* password = "YOUR_PASS"; + +ESP8266WebServer server(80); +FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial + + + +void handleRoot() { + server.send(200, "text/plain", "hello from esp8266!"); + +} + +void handleNotFound(){ + String message = "File Not Found\n\n"; + message += "URI: "; + message += server.uri(); + message += "\nMethod: "; + message += (server.method() == HTTP_GET)?"GET":"POST"; + message += "\nArguments: "; + message += server.args(); + message += "\n"; + for (uint8_t i=0; i<server.args(); i++){ + message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; + } + server.send(404, "text/plain", message); +} + +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()); + + + server.on("/", handleRoot); + + server.onNotFound(handleNotFound); + + server.begin(); + Serial.println("HTTP server started"); + + /////FTP Setup, ensure SPIFFS is started before ftp; ///////// + + if (SPIFFS.begin()) { + 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(); + +}
|