diff --git a/src/app/FTPServer.h b/src/app/FTPServer.h index 26e7489..7096ef6 100644 --- a/src/app/FTPServer.h +++ b/src/app/FTPServer.h @@ -39,12 +39,6 @@ class FTPServer : public TCPServer strcpy(_password, password); } } - _dataServer.begin(_dataPort); - } - - void setCustomDataPort(unsigned int port) - { - _dataPort = port; } virtual ~FTPServer() @@ -53,7 +47,16 @@ class FTPServer : public TCPServer free(_username); free(_password); free(_FTPDir); } - virtual void stop() + virtual void start(void) + { + if(!TCPServer::_serverStarted) + { + _dataServer.begin(_dataPort); + TCPServer::start(); + } + } + + virtual void stop(void) { if(TCPServer::_serverStarted) { @@ -62,6 +65,21 @@ class FTPServer : public TCPServer } } + virtual void setCustomDataPort(uint16_t port) + { + _dataPort = port; + if(TCPServer::_serverStarted) + { + _dataServer.stop(); + _dataServer.begin(_dataPort); + } + } + + virtual uint16_t getCustomDataPort(void) const + { + return _dataPort; + } + virtual void setFTPDir(const char *FTPDir) { if(FTPDir) @@ -80,6 +98,11 @@ class FTPServer : public TCPServer } } + virtual const char * getFTPDir(void) + { + return _FTPDir; + } + virtual void setUsername(const char *username) { if(username) @@ -98,6 +121,11 @@ class FTPServer : public TCPServer } } + virtual const char * getUsername(void) + { + return _username; + } + virtual void setPassword(const char *password) { if(password) @@ -116,6 +144,11 @@ class FTPServer : public TCPServer } } + virtual const char * getPassword(void) + { + return _password; + } + protected: virtual T* createNewClient(WiFiClient wc) { diff --git a/src/app/SAB.cpp b/src/app/SAB.cpp index 1b70f88..a310dfc 100644 --- a/src/app/SAB.cpp +++ b/src/app/SAB.cpp @@ -73,6 +73,8 @@ void SAB::initCommonConfig() _dbWSServer.begin(); _webServer.enableTCPKeepAlive(15,5,5); _ftpServer.enableTCPKeepAlive(15,5,5); + _webServer.start(); + _ftpServer.start(); } void SAB::initGPIO() diff --git a/src/app/TCPServer.h b/src/app/TCPServer.h index fcc2ba3..b592e62 100644 --- a/src/app/TCPServer.h +++ b/src/app/TCPServer.h @@ -15,7 +15,7 @@ class TCPServer public: TCPServer(uint16_t port = 80, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 256) : _maxClient(maxClient), _clientDataBufferSize(clientDataBufferSize), _wifiServer(port) { - _wifiServer.begin(); + } virtual ~TCPServer() @@ -44,11 +44,11 @@ class TCPServer getClientData(); } - virtual void start(uint16_t port = 0) + virtual void start(uint16_t port = 0, uint8_t backlog = 5) { if(!_serverStarted) { - !port ? _wifiServer.begin() : _wifiServer.begin(port) ; + !port ? _wifiServer.begin(getPort()) : _wifiServer.begin(port, backlog) ; _serverStarted = true; } } @@ -206,7 +206,7 @@ class TCPServer return freeId; } - boolean _serverStarted = true; + boolean _serverStarted = false; uint8_t _maxClient, _TKACount = 0; uint16_t _clientDataBufferSize, _TKAIdleSec = 0, _TKAIntvSec = 0; WiFiServer _wifiServer; diff --git a/src/app/WEBServer.h b/src/app/WEBServer.h index 5338efa..1e0a3a0 100644 --- a/src/app/WEBServer.h +++ b/src/app/WEBServer.h @@ -92,6 +92,11 @@ class WEBServer : public TCPServer, public HttpConstants _WWWDir = nullptr; } } + + const char * getWWWDir(void) const + { + return _WWWDir; + } protected: private: virtual T* createNewClient(WiFiClient wc)