Arduino TinyFTP
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tinyftp::FTPBasicAPI Class Reference

FTPBasicAPI Implementation of Low Level FTP protocol. In order to simplify the logic we always use Passive FTP where it is our responsibility to open the data conection. More...

#include <FTPBasicAPI.h>

Inheritance diagram for tinyftp::FTPBasicAPI:
tinyftp::FTPSession< ClientType >

Public Member Functions

bool begin (Client *cmdPar, Client *dataPar, IPAddress &address, int port, const char *username, const char *password)
 
bool quit ()
 
bool connected ()
 
 operator bool ()
 
bool passv ()
 
bool del (const char *file)
 
bool mkdir (const char *dir)
 
bool rmd (const char *dir)
 
size_t size (const char *file)
 
ObjectType objectType (const char *file)
 
bool abort ()
 
bool binary ()
 
bool ascii ()
 
bool type (const char *txt)
 
Client * read (const char *file_name)
 Starts the download (if necessary): returns nullptr if it failed.
 
Client * write (const char *file_name, FileMode mode)
 Starts the upload (if necessary): returns nullptr if it failed.
 
Client * ls (const char *file_name)
 Starts the directory listing: returns nullptr if it failed.
 
bool dataConnected ()
 
void closeData ()
 
bool endTransfer (const char *tag)
 
uint32_t reserve ()
 Reserves the session for a new transfer: returns its id.
 
uint32_t transferId ()
 Id of the current (or last) transfer.
 
bool isTransfer (uint32_t id)
 Returns true if the transfer with the indicated id is still active.
 
void addHandle (uint32_t id)
 
void releaseHandle (uint32_t id)
 Unregisters a handle: the transfer ends when the last handle is gone.
 
void setCurrentOperation (CurrentOperation op)
 
CurrentOperation currentOperation ()
 
void flush ()
 
bool checkResult (const char *expected[], const char *command, bool wait_for_data=true)
 
bool cmd (const char *command, const char *par, const char *expected, bool wait_for_data=true)
 
bool cmd (const char *command_str, const char *par, const char *expected[], bool wait_for_data=true)
 
void setUseTypeCommand (bool useType)
 

Protected Member Functions

void resetTransfer ()
 Forgets the current transfer: e.g. when the connection was closed.
 
void skipReplies (unsigned long ms)
 Consumes all replies which arrive within the indicated time.
 
bool connect (IPAddress adr, int port, Client *client_ptr, bool doCheckResult=false)
 
bool isExpected (const char *reply, const char *expected[])
 
bool readReply (char *reply, int maxLen)
 
bool readReplyLine (char *str, int maxLen)
 

Protected Attributes

CurrentOperation current_operation = NOP
 
Client * command_ptr = nullptr
 
Client * data_ptr = nullptr
 
IPAddress remote_address
 
bool is_open = false
 
bool use_type = false
 
char result_reply [100] = {0}
 
uint32_t transfer_id = 0
 
int handles = 0
 

Detailed Description

FTPBasicAPI Implementation of Low Level FTP protocol. In order to simplify the logic we always use Passive FTP where it is our responsibility to open the data conection.

Author
Phil Schatzmann

Member Function Documentation

◆ addHandle()

void tinyftp::FTPBasicAPI::addHandle ( uint32_t  id)
inline

Registers an additional handle (FTPFile or FTPFileIterator copy) of the transfer

◆ dataConnected()

bool tinyftp::FTPBasicAPI::dataConnected ( )
inline

Returns true while the server keeps the data connection open (or there is still unread data)

◆ endTransfer()

bool tinyftp::FTPBasicAPI::endTransfer ( const char *  tag)
inline

Ends the current transfer: closes the data connection, consumes the final status of the transfer (if one was started) and releases the session

◆ isExpected()

bool tinyftp::FTPBasicAPI::isExpected ( const char *  reply,
const char *  expected[] 
)
inlineprotected

Returns true if the reply starts with one of the expected codes (or if no codes are expected)

◆ readReply()

bool tinyftp::FTPBasicAPI::readReply ( char *  reply,
int  maxLen 
)
inlineprotected

Reads a complete (potentially multi-line) reply from the command connection. The first line (which contains the reply code) is returned.

◆ readReplyLine()

bool tinyftp::FTPBasicAPI::readReplyLine ( char *  str,
int  maxLen 
)
inlineprotected

Reads a single line (w/o trailing \r
) from the command connection with timeout. Lines longer then the buffer are truncated.


The documentation for this class was generated from the following file: