Good morning, in my project with the ESP32 CYD (GNSS NTRIP MANAGER), I couldn't use simpleFtpServer. Since I'm not an expert programmer, after countless attempts, I asked Claude AI for help, and finally everything worked.
After completing my tests, I had ClaudeAI write this issue:
DEFAULT_STORAGE_TYPE_ESP32 cannot be overridden from sketch — must edit FtpServerKey.h directly
Environment
- Library: SimpleFTPServer 3.0.2
- Platform: ESP32 (esp32 Arduino core 3.3.6, ESP-IDF 5.5.2)
- Storage: SdFat2 (
SdFat object)
- Network: WiFi AP mode
Problem
The documentation and header comments suggest that DEFAULT_STORAGE_TYPE_ESP32 can be overridden before including the library:
#undef DEFAULT_STORAGE_TYPE_ESP32
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SDFAT2
#include <FtpServer.h>
This compiles without errors, but at runtime the FTP server fails with:
FTP: Connected!
[E][vfs_api.cpp:26] open(): File system is not mounted
The root cause is that Arduino IDE compiles libraries as separate translation units. Any #define placed in the sketch (.ino) is not visible to FtpServer.cpp during its compilation. As a result, FtpServer.cpp always sees the default value (STORAGE_FFAT) defined in FtpServerKey.h, regardless of what the sketch defines.
The only working solution is to edit FtpServerKey.h directly:
#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32
#define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP32 NETWORK_ESP32
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SDFAT2 // changed from STORAGE_FFAT
#endif
Suggested fix
Consider supporting a project-level configuration file (e.g. FtpServerUser.h) that is included by FtpServerKey.h when present, following the same pattern used by libraries like TFT_eSPI (User_Setup.h). This would allow per-project configuration without modifying library files.
Alternatively, document clearly that sketch-level overrides do not work for this library and that FtpServerKey.h must be edited directly.
Good morning, in my project with the ESP32 CYD (GNSS NTRIP MANAGER), I couldn't use simpleFtpServer. Since I'm not an expert programmer, after countless attempts, I asked Claude AI for help, and finally everything worked.
After completing my tests, I had ClaudeAI write this issue:
DEFAULT_STORAGE_TYPE_ESP32cannot be overridden from sketch — must editFtpServerKey.hdirectlyEnvironment
SdFatobject)Problem
The documentation and header comments suggest that
DEFAULT_STORAGE_TYPE_ESP32can be overridden before including the library:This compiles without errors, but at runtime the FTP server fails with:
The root cause is that Arduino IDE compiles libraries as separate translation units. Any
#defineplaced in the sketch (.ino) is not visible toFtpServer.cppduring its compilation. As a result,FtpServer.cppalways sees the default value (STORAGE_FFAT) defined inFtpServerKey.h, regardless of what the sketch defines.The only working solution is to edit
FtpServerKey.hdirectly:Suggested fix
Consider supporting a project-level configuration file (e.g.
FtpServerUser.h) that is included byFtpServerKey.hwhen present, following the same pattern used by libraries like TFT_eSPI (User_Setup.h). This would allow per-project configuration without modifying library files.Alternatively, document clearly that sketch-level overrides do not work for this library and that
FtpServerKey.hmust be edited directly.