Changed port data type from unsigned int to uint16_t as well as removed a redundant port information

This commit is contained in:
anschrammh 2020-12-12 11:11:35 +01:00
parent 81cab29edc
commit 0ead1e5600
3 changed files with 8 additions and 9 deletions

View File

@ -18,7 +18,7 @@ class FTPServer : public TCPServer<T>
enum BinaryFlag {OFF = 0, ON}; enum BinaryFlag {OFF = 0, ON};
enum FtpMsgCode {_150, _200, _215, _220, _221, _230, _226, _227, _250, _257, _331, _350, _451, _5_502, _504, _530, _550 }; enum FtpMsgCode {_150, _200, _215, _220, _221, _230, _226, _227, _250, _257, _331, _350, _451, _5_502, _504, _530, _550 };
FTPServer(unsigned int port = 21, SDCardManager *sdCardManager = NULL, const char *login = NULL, const char *password = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientCommandDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientCommandDataBufferSize), FTPServer(uint16_t port = 21, SDCardManager *sdCardManager = NULL, const char *login = NULL, const char *password = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientCommandDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientCommandDataBufferSize),
_login(NULL), _login(NULL),
_password(NULL), _password(NULL),
_dataPort(1024), _dataPort(1024),
@ -991,7 +991,7 @@ class FTPServer : public TCPServer<T>
char *_login; char *_login;
char *_password; char *_password;
unsigned int _dataPort; uint16_t _dataPort;
WiFiServer _dataServer; //In passive mode, the FTP server opens two different ports (one for the commands and the other for the data stream) WiFiServer _dataServer; //In passive mode, the FTP server opens two different ports (one for the commands and the other for the data stream)
SDCardManager *_sdCardManager; SDCardManager *_sdCardManager;

View File

@ -13,7 +13,7 @@ template <typename T>
class TCPServer class TCPServer
{ {
public: public:
TCPServer(unsigned int port = 80, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : _wifiServer(port), _port(port), _serverStarted(true), _maxClient(maxClient), _clientDataBufferSize(clientDataBufferSize), _currentClient(NULL) TCPServer(uint16_t port = 80, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : _wifiServer(port), _serverStarted(true), _maxClient(maxClient), _clientDataBufferSize(clientDataBufferSize), _currentClient(NULL)
{ {
_wifiServer.begin(); _wifiServer.begin();
} }
@ -28,9 +28,9 @@ class TCPServer
return _maxClient; return _maxClient;
} }
unsigned int getPort() const uint16_t getPort() const
{ {
return _port; return _wifiServer.port();
} }
uint8_t getConnectedClientsCount() uint8_t getConnectedClientsCount()
@ -44,11 +44,11 @@ class TCPServer
getClientData(); getClientData();
} }
virtual void start() virtual void start(uint16_t port = 0)
{ {
if(!_serverStarted) if(!_serverStarted)
{ {
_wifiServer.begin(); !port ? _wifiServer.begin() : _wifiServer.begin(port) ;
_serverStarted = true; _serverStarted = true;
} }
} }
@ -185,7 +185,6 @@ class TCPServer
boolean _serverStarted; boolean _serverStarted;
uint8_t _maxClient; uint8_t _maxClient;
unsigned int _port;
uint16_t _clientDataBufferSize; uint16_t _clientDataBufferSize;
WiFiServer _wifiServer; WiFiServer _wifiServer;
T *_currentClient; //current client to be processed T *_currentClient; //current client to be processed

View File

@ -32,7 +32,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
uint16_t maxBodyBuffer; uint16_t maxBodyBuffer;
}; };
WEBServer(unsigned int port = 80, SDCardManager *sdCardManager = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientDataBufferSize), _sdCardManager(sdCardManager) {} WEBServer(uint16_t port = 80, SDCardManager *sdCardManager = NULL, uint8_t maxClient = MAX_CLIENT, uint16_t clientDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientDataBufferSize), _sdCardManager(sdCardManager) {}
boolean addApiRoutine(const char *uri, boolean (*apiRoutine)(HttpRequestData&, WiFiClient*, void*), void *pData, HttpRequestMethod HRM = UNDEFINED) boolean addApiRoutine(const char *uri, boolean (*apiRoutine)(HttpRequestData&, WiFiClient*, void*), void *pData, HttpRequestMethod HRM = UNDEFINED)
{ {