diff --git a/src/app/FTPServer.h b/src/app/FTPServer.h index e761f98..6153862 100644 --- a/src/app/FTPServer.h +++ b/src/app/FTPServer.h @@ -19,9 +19,6 @@ class FTPServer : public TCPServer enum FTPMsgCode {_150, _200, _215, _220, _221, _230, _226, _227, _250, _257, _331, _350, _451, _5_502, _504, _530, _550 }; FTPServer(uint16_t port = 21, SDClass *sdClass = NULL, const char *login = NULL, const char *password = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientCommandDataBufferSize = 255) : TCPServer(port, maxClient, clientCommandDataBufferSize), - _login(NULL), - _password(NULL), - _dataPort(1024), _dataServer(_dataPort), _sdClass(sdClass) { @@ -918,7 +915,7 @@ class FTPServer : public TCPServer if (fileToSend) { *fts = OK; - size_t readBytes(0); + size_t readBytes(0), sentBytes(0); fileToSend.seek(client->_fileSentBytes); if(fileToSend.available()) @@ -934,14 +931,14 @@ class FTPServer : public TCPServer } readBytes = fileToSend.read(sendBuffer, mallocAcceptedSize); - client->_dataClient.write(sendBuffer, readBytes); + sentBytes = client->_dataClient.write(sendBuffer, readBytes); free(sendBuffer); - client->_fileSentBytes += readBytes; + client->_fileSentBytes += sentBytes; #ifdef DEBUG_FTPS - Serial.printf("File : bytes sent : %u - free stack : %u\n", readBytes, ESP.getFreeContStack()); + Serial.printf("File : bytes read : %u, bytes sent : %u - free stack : %u\n", readBytes, sentBytes, ESP.getFreeContStack()); #endif } else //The whole file has been sent @@ -1031,10 +1028,10 @@ class FTPServer : public TCPServer } } - char *_login; - char *_password; + char *_login = nullptr; + char *_password = nullptr; char *_FTPDir = nullptr; - uint16_t _dataPort; + uint16_t _dataPort = 1024; WiFiServer _dataServer; //In passive mode, the FTP server opens two different ports (one for the commands and the other for the data stream) SDClass *_sdClass; diff --git a/src/app/WEBServer.h b/src/app/WEBServer.h index 13e66a5..544da1f 100644 --- a/src/app/WEBServer.h +++ b/src/app/WEBServer.h @@ -575,7 +575,7 @@ class WEBServer : public TCPServer, public HttpConstants { File pageToSend; char *filePath(NULL), *header(NULL); - size_t readBytes(0); + size_t readBytesFromFS(0), sentBytesFromSocket(0); //We check what kind of http verb it is switch(client->_httpRequestData.HRM) { @@ -715,16 +715,16 @@ class WEBServer : public TCPServer, public HttpConstants return false; //Not clean but what else can I do. Should never happen anyway. } - readBytes = pageToSend.read(sendBuffer,mallocAcceptedSize); - client->_client.write(sendBuffer, readBytes); + readBytesFromFS = pageToSend.read(sendBuffer,mallocAcceptedSize); + sentBytesFromSocket = client->_client.write(sendBuffer, readBytesFromFS); free(sendBuffer); #ifdef DEBUG_WEBS - Serial.printf("Bytes sent : %u, got allocated buffer size : %u - free stack : %u\n", readBytes, mallocAcceptedSize, ESP.getFreeContStack()); + Serial.printf("Bytes read from FS : %u, Bytes sent : %u, got allocated buffer size : %u - free stack : %u\n", readBytesFromFS, sentBytesFromSocket, mallocAcceptedSize, ESP.getFreeContStack()); #endif - client->_fileSentBytes += readBytes; //We save the number of bytes sent so that we can reopen the file to this position later on. + client->_fileSentBytes += sentBytesFromSocket; //We save the number of bytes sent so that we can reopen the file to this position later on. } else { diff --git a/src/app/webApi.cpp b/src/app/webApi.cpp index 2434b38..c2f5bb6 100644 --- a/src/app/webApi.cpp +++ b/src/app/webApi.cpp @@ -560,6 +560,8 @@ boolean ioSetModeApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc, boolean otaUpdateApi(WEBServer::HttpRequestData &HRD, WiFiClient *wc, void *pData) { + (void)HRD; + (void)pData; Serial.printf("OTA Update resquest\n"); char buffer[500];