summaryrefslogtreecommitdiffstats
path: root/FTPClient.cpp
diff options
context:
space:
mode:
authorDaniel Plasa <dplasa@gmail.com>2020-05-29 23:13:34 +0200
committerDaniel Plasa <dplasa@gmail.com>2020-05-29 23:13:34 +0200
commit66007803dae38961648aaa5c3cc745213b8e9545 (patch)
tree33b3721a0480bbd65e89ba9dd1e1c35668547b72 /FTPClient.cpp
parentexplicit name error codes as constexpr (diff)
downloadFTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar.gz
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar.bz2
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar.lz
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar.xz
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.tar.zst
FTPCLientServer-66007803dae38961648aaa5c3cc745213b8e9545.zip
Diffstat (limited to 'FTPClient.cpp')
-rw-r--r--FTPClient.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/FTPClient.cpp b/FTPClient.cpp
index e32af21..84c4fdb 100644
--- a/FTPClient.cpp
+++ b/FTPClient.cpp
@@ -10,6 +10,8 @@
FTPClient::FTPClient(FS &_FSImplementation) : FTPCommon(_FSImplementation)
{
+ // set aTimeout to never expire, will be used later by ::waitFor(...)
+ aTimeout.resetToNeverExpires();
}
void FTPClient::begin(const ServerInfo &theServer)
@@ -216,20 +218,20 @@ int8_t FTPClient::controlConnect()
return -1;
}
-bool FTPClient::waitFor(const uint16_t respCode, const __FlashStringHelper *errorString, uint16_t timeOut)
+bool FTPClient::waitFor(const int16_t respCode, const __FlashStringHelper *errorString, uint16_t timeOutMs)
{
// initalize waiting
- if (0 == waitUntil)
+ if (!aTimeout.canExpire())
{
- waitUntil = millis();
- waitUntil += timeOut;
+ aTimeout.reset(timeOutMs);
_serverStatus.desc.clear();
}
else
{
// timeout
- if ((int32_t)(millis() - waitUntil) >= 0)
+ if (aTimeout.expired())
{
+ aTimeout.resetToNeverExpires();
FTP_DEBUG_MSG("Waiting for code %u - timeout!", respCode);
_serverStatus.code = errorTimeout;
if (errorString)
@@ -241,7 +243,6 @@ bool FTPClient::waitFor(const uint16_t respCode, const __FlashStringHelper *erro
_serverStatus.desc = F("timeout");
}
ftpState = cTimeout;
- waitUntil = 0;
return false;
}
@@ -269,7 +270,7 @@ bool FTPClient::waitFor(const uint16_t respCode, const __FlashStringHelper *erro
FTP_DEBUG_MSG("Waiting for code %u success, SMTP server replies: %s", respCode, _serverStatus.desc.c_str());
}
- waitUntil = 0;
+ aTimeout.resetToNeverExpires();
return (respCode == _serverStatus.code);
}
else