Page 1 of 1

switching Station mode to Soft AP on ftp server

Posted: Mon Feb 20, 2023 4:26 pm
by PRO_GRAMMAR
I was running this server in station mode but would like to switch it to a SoftAP instead. I edited as below but I'm only able to log in, can't access files.
Filezilla:
Command: PORT 192,168,4,2,205,59
Response: 200 PORT command successful
Command: MLSD
Response: 425 No data connection
Error: Failed to retrieve directory listing

Any help would bey greatly appreciated.

Code: Select all

#if defined(ESP32)
#include <SPIFFS.h>
#include <SD.h>
#include <WiFi.h>
#elif defined(ESP8266)
#include <FS.h>
#include <ESP8266WiFi.h>
#endif

#include "ESP-FTP-Server-Lib.h"
#include "FTPFilesystem.h"

#define WIFI_SSID "mywifi"
#define WIFI_PASSWORD "password"

const char *ssid = "esp32AP";
const char *password = "abc12345";

#define FTP_USER "admin"
#define FTP_PASSWORD "abc12345"

#ifndef UNIT_TEST
FTPServer ftp;

void setup()
{
  Serial.begin(115200);
 

    WiFi.mode(WIFI_AP);
    WiFi.softAP(ssid, password);
    delay(1000);
    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);

#if defined(ESP32)
  SPIFFS.begin(true);
  SPI.begin(18, 19, 23, 5);
  if(!SD.begin(5))
  {
    Serial.println("SD Card Mount Failed");
  }
#elif defined(ESP8266)
  SPIFFS.begin();
#endif


  delay(2000); 
 
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  

  ftp.addUser(FTP_USER, FTP_PASSWORD);
#if defined(ESP32)
  ftp.addFilesystem("SD", &SD);
#endif
  ftp.addFilesystem("SPIFFS", &SPIFFS);

  ftp.begin();

  Serial.println("Online");
}

void loop()
{
  ftp.handle();
}
#endif