Gregor 520b853bf4 Small typo in ftp server fails compilation | 6 years ago | |
---|---|---|
.. | ||
README.md | 6 years ago | |
ftpserver.lua | 6 years ago |
This Lua module implementation provides a basic FTP server for the ESP8266. It has been tested against a number of Table, Windows and Linux FTP clients and browsers.
It provides a limited subset of FTP commands that enable such clients to tranfer files to and from the ESP’s file system. Only one server can be started at any one time, but this server can support multiple connected sessions (some FTP clients use multiple sessions and so require this feature).
net
module does not allow static allocation of outbound sockets.The coding style adopted here is more similar to best practice for normal (PC) module implementations, as using LFS permits a bias towards clarity of coding over brevity. It includes extra logic to handle some of the edge case issues more robustly. It also uses a standard forward reference coding pattern to allow the code to be laid out in main routine, subroutine order.
Most FTP clients are capable of higher transfer rates than the ESP SPIFFS write throughput, so the server uses TCP flow control to limit upload rates to the ESP.
aThe following FTP commands are supported:
This implementation is by Terry Ellison, but I wish to acknowledge the inspration and hard work by Neronix that made this possible.
Create the FTP server on the standard ports 20 and 21. The global variable FTP
is set to the server object.
FTP.createServer(user, pass[, dbgFlag])
user
- Username for access to the serverpass
- Password for access to the serverdbgFlag
- optional flag. If set true then internal debug output is printedrequire("ftpserver").createServer('user', 'password')
Wrapper to createServer() which also connects to the WiFi channel.
FTP.open(user, pass, ssid, wifipwd, dbgFlag)
user
- Username for access to the serverpass
- Password for access to the serverssid
- SSID for Wifi servicewifipwd
- password for Wifi servicedbgFlag
- optional flag. If set true then internal debug output is printedrequire("ftpserver").open('myWifi', 'wifiPassword', 'user', 'password')
Close down server including any sockets and return all resouces to Lua. Note that this include removing the FTP global variable and package references.
FTP.close()
FTP.close()