I have started writing the class below and, at this stage, I just want it to respond to an incoming ftp request and out put the data to arduino serial monitor.
However the incoming FTP requests are not making it through.
I have tried connecting with Filezilla on port 21 and also via ftp://10.0.0.133:21 in my web browser - I get nothing.
Can anyone tell me what I have done wrong?
Based on the standard WiFiEspServer class(instantiated with port 80) that comes with the library, doing the above should be quite trivial.
It seems that this library only works with port 80 - is that likely?
#ifndef __FTP_SERVER_H
#define __FTP_SERVER_H
#include "WifiEspServer.h"
#include "WifiEspClient.h"
#define SIZE 30
class CFTPServer
{
public:
// Construction, destruction and initialisation.
CFTPServer();
~CFTPServer();
void begin(const char* strUsername, const char* strPassword);
// Interface
bool processFTPRequest();
protected:
// Helper functions
// Implementation
static const uint8_t m_nCtrlPort, m_nDataPort;
// Servers for the control and data.
WiFiEspServer m_serverCtrl, m_serverData;
// FTP username and password
char m_strUsername[SIZE], m_strPassword[SIZE];
};
#endif
#include <Arduino.h>
#include "WiFiFTPServer.h"
const uint8_t CFTPServer::m_nCtrlPort = 21;
const uint8_t CFTPServer::m_nDataPort = 22;
CFTPServer::CFTPServer(): m_serverCtrl(m_nCtrlPort), m_serverData(m_nDataPort)
{
memset(m_strUsername, 0, SIZE);
memset(m_strPassword, 0, SIZE);
}
CFTPServer::~CFTPServer()
{
}
void CFTPServer::begin(const char* strUsername, const char* strPassword)
{
strcpy(m_strUsername, strUsername);
strcpy(m_strPassword, strPassword);
m_serverCtrl.begin();
m_serverData.begin();
}
bool CFTPServer::processFTPRequest()
{
bool bResult = false;
WiFiEspClient client = m_serverCtrl.available();
char cCh = 0;
if (client)
{
Serial.println(F("New HTTP request"));
while (client.connected())
{
if (client.available())
{
cCh = client.read();
Serial.print(cCh);
}
}
Serial.println(F(""));
}
return bResult;
}