Arduino TinyFTP
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tinyftp::FTPSession< ClientType > Class Template Reference

FTPSession An FTPBasicAPI which owns its command and data connections. More...

#include <FTPSession.h>

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

Public Member Functions

bool begin (IPAddress &address, int port, const char *username, const char *password)
 Opens the command connection and logs in.
 
void end ()
 Closes the command and data connections.
 
bool connected ()
 Returns true if logged in and the command connection is still alive.
 
 operator bool ()
 
bool begin (Client *cmdPar, Client *dataPar, IPAddress &address, int port, const char *username, const char *password)
 
bool quit ()
 
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

ClientType command_client
 
ClientType data_client
 
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

template<class ClientType>
class tinyftp::FTPSession< ClientType >

FTPSession An FTPBasicAPI which owns its command and data connections.

Note
The class is designed to be used in an Arduino environment, where the Client interface is typically implemented by network libraries such as WiFi or Ethernet.
Template Parameters
ClientTypeThe type of client to use for command and data connections. It should be a class that implements the Client interface.
Author
Phil Schatzmann

Member Function Documentation

◆ addHandle()

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

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

◆ dataConnected()

bool tinyftp::FTPBasicAPI::dataConnected ( )
inlineinherited

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

◆ endTransfer()

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

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[] 
)
inlineprotectedinherited

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 
)
inlineprotectedinherited

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 
)
inlineprotectedinherited

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: