Arduino TinyFTP
Loading...
Searching...
No Matches
FTPSession.h
1#include "FTPBasicAPI.h"
2
3namespace ftp_client {
16template <class ClientType>
18 public:
19 FTPSession() { FTPLogger::writeLog(LOG_DEBUG, "FTPSession"); }
20
21 ~FTPSession() {
22 FTPLogger::writeLog(LOG_DEBUG, "~FTPSession");
23 end();
24 }
25
27 bool begin(IPAddress &address, int port, const char *username,
28 const char *password) {
29 if (!is_valid) return false;
30 return basic_api.begin(&command_client, &data_client, address, port,
31 username, password);
32 }
33
34 void end() {
35 if (!is_valid) return;
36 FTPLogger::writeLog(LOG_DEBUG, "FTPSession", "end");
37 closeCommand();
38 closeData();
39 }
40
42 FTPBasicAPI &api() { return basic_api; }
43
45 operator bool() { return is_valid && command_client.connected(); }
46
48 void setValid(bool valid) { is_valid = valid; }
49
50 protected:
51 ClientType command_client;
52 ClientType data_client;
53 FTPBasicAPI basic_api;
54 bool is_valid = true;
55
56 void closeCommand() {
57 FTPLogger::writeLog(LOG_DEBUG, "FTPSession", "endCommand");
58 command_client.stop();
59 }
60
61 void closeData() {
62 FTPLogger::writeLog(LOG_DEBUG, "FTPSession", "endData");
63 data_client.stop();
64 }
65
66};
67
68} // namespace ftp_client
FTPBasicAPI Implementation of Low Level FTP protocol. In order to simplify the logic we always use Pa...
Definition FTPBasicAPI.h:17
FTPSession This class manages the FTP session, including command and data connections....
Definition FTPSession.h:17
FTPBasicAPI & api()
Returns the access to the basic API.
Definition FTPSession.h:42
void setValid(bool valid)
Used to set as invalid for dummy error session.
Definition FTPSession.h:48
bool begin(IPAddress &address, int port, const char *username, const char *password)
Initializes the session with the command client.
Definition FTPSession.h:27