Added new classes to develop the FTP server

This commit is contained in:
anschrammh 2019-10-11 12:39:33 +02:00
parent 1317644b3d
commit a01a151943
5 changed files with 54 additions and 7 deletions

View File

@ -0,0 +1 @@
#include "FTPClient.h"

View File

@ -0,0 +1,13 @@
#ifndef FTPCLIENT_H
#define FTPCLIENT_H
#include "TCPClient.h"
class FTPClient
{
public:
protected:
private:
};
#endif //FTPCLIENT_H

View File

@ -0,0 +1,32 @@
#ifndef FTPSERVER_H
#define FTPSERVER_H
#include "TCPServer.h"
template <typename T>
class FTPServer : public TCPServer<T>
{
public:
FTPServer(unsigned int port = 22, const char login = "", const char password = "", uint8_t maxClient = MAX_CLIENT, uint16_t clientCommandDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientCommandDataBufferSize), _login(NULL), _password(NULL)
{
_login = (char *)malloc((sizeof(char) * strlen(login)) + 1);
if(_login != NULL)
strcpy(_login, login);
_password = (char *)malloc((sizeof(char) * strlen(password)) + 1);
if(_password != NULL)
strcpy(_password, password);
}
virtual ~FTPServer()
{
free(_login);free(_password);
}
protected:
private:
char *_login;
char *_password;
};
#endif //FTPSERVER_H

View File

@ -3,7 +3,6 @@
#include "WEBServer.h"
#include "TCPClient.h"
#include "Dictionary.h"
class WEBClient : public TCPClient
{

View File

@ -7,12 +7,14 @@
#include "TCPServer.h"
#include "WEBServer.h"
#include "WEBClient.h"
#include "FTPServer.h"
#include "FTPClient.h"
uint32_t lastFreeMem(0);
uint16_t lastClientCount(0);
TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
WEBServer<WEBClient> webServer(8080);
//TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
//WEBServer<WEBClient> webServer(8080);
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
@ -39,17 +41,17 @@ void debugInfo()
Serial.print("Heap Frag : ");Serial.println(frag);
lastFreeMem = freeMem;
}
if(lastClientCount != server.getConnectedClientsCount())
/*if(lastClientCount != server.getConnectedClientsCount())
{
lastClientCount = server.getConnectedClientsCount();
Serial.print("Connected client(s) : ");Serial.println(lastClientCount);
}
}*/
}
void loop() {
// put your main code here, to run repeatedly:
server.runServer();
webServer.runServer();
//server.runServer();
//webServer.runServer();
debugInfo();
}