Fix ESP181

Add FTP to NetServices
This commit is contained in:
Luc 2019-10-23 20:49:24 +02:00
parent c684e69575
commit a733ed29e2
2 changed files with 32 additions and 8 deletions

View File

@ -49,10 +49,10 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
return false;
}
#endif //AUTHENTICATION_FEATURE
String s = get_param (cmd_params, "ctrl=");
parameter = get_param (cmd_params, "ctrl=");
uint ibuf;
bool done = false;
if (s.length() > 0) {
if (parameter.length() > 0) {
ibuf = parameter.toInt();
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_FTP_CTRL_PORT)) || (ibuf < Settings_ESP3D::get_min_int32_value(ESP_FTP_CTRL_PORT))) {
output->printERROR ("Incorrect port!");
@ -65,8 +65,8 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
done = true;
}
}
s = get_param (cmd_params, "active=");
if (s.length() > 0) {
parameter = get_param (cmd_params, "active=");
if (parameter.length() > 0) {
ibuf = parameter.toInt();
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_FTP_DATA_ACTIVE_PORT)) || (ibuf < Settings_ESP3D::get_min_int32_value(ESP_FTP_DATA_ACTIVE_PORT))) {
output->printERROR ("Incorrect port!");
@ -79,8 +79,8 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
done = true;
}
}
s = get_param (cmd_params, "passive=");
if (s.length() > 0) {
parameter = get_param (cmd_params, "passive=");
if (parameter.length() > 0) {
ibuf = parameter.toInt();
if ((ibuf > Settings_ESP3D::get_max_int32_value(ESP_FTP_DATA_PASSIVE_PORT)) || (ibuf < Settings_ESP3D::get_min_int32_value(ESP_FTP_DATA_PASSIVE_PORT))) {
output->printERROR ("Incorrect port!");
@ -95,8 +95,13 @@ bool Commands::ESP181(const char* cmd_params, level_authenticate_type auth_type,
}
if (response && done) {
output->printMSG("ok");
} else {
if (response && !done) {
output->printERROR ("Only ctrl, active and passive settings are supported!");
response = false;
}
}
}
return response;
}

View File

@ -49,6 +49,9 @@
#ifdef TELNET_FEATURE
#include "../telnet/telnet_server.h"
#endif //TELNET_FEATURE
#ifdef FTP_FEATURE
#include "../ftp/ftp_server.h"
#endif //FP_FEATURE
#ifdef HTTP_FEATURE
#include "../http/http_server.h"
#endif //HTTP_FEATURE
@ -209,6 +212,17 @@ bool NetServices::begin()
}
}
#endif //TELNET_FEATURE
#ifdef FTP_FEATURE
if (!ftp_server.begin()) {
res= false;
output.printERROR("Ftp server failed");
} else {
if(ftp_server.started()) {
String stmp = "Ftp server started ports: " + String(ftp_server.ctrlport()) + ","+ String(ftp_server.dataactiveport()) + ","+ String(ftp_server.datapassiveport());
output.printMSG(stmp.c_str());
}
}
#endif //FTP_FEATURE
#ifdef WS_DATA_FEATURE
if (!websocket_data_server.begin(Settings_ESP3D::read_uint32(ESP_WEBSOCKET_PORT))) {
output.printMSG("Failed start Terminal Web Socket");
@ -318,7 +332,9 @@ void NetServices::end()
#ifdef TELNET_FEATURE
telnet_server.end();
#endif //TELNET_FEATURE
#ifdef FTP_FEATURE
ftp_server.end();
#endif //FTP_FEATURE
}
void NetServices::handle()
@ -349,6 +365,9 @@ void NetServices::handle()
#ifdef TELNET_FEATURE
telnet_server.handle();
#endif //TELNET_FEATURE
#ifdef FTP_FEATURE
ftp_server.handle();
#endif //FTP_FEATURE
#ifdef NOTIFICATION_FEATURE
notificationsservice.handle();
#endif //NOTIFICATION_FEATURE