@ -268,7 +268,7 @@ TaskHandle_t rfid;
// FTP
// FTP
# ifdef FTP_ENABLE
# ifdef FTP_ENABLE
FtpServer ftpSrv ;
FtpServer * ftpSrv ; // Heap-alloction takes place later (when needed)
bool ftpEnableLastStatus = false ;
bool ftpEnableLastStatus = false ;
bool ftpEnableCurrentStatus = false ;
bool ftpEnableCurrentStatus = false ;
# endif
# endif
@ -3076,11 +3076,17 @@ bool writeWifiStatusToNVS(bool wifiStatus) {
}
}
// Creates FTP-instance only when requested
# ifdef FTP_ENABLE
# ifdef FTP_ENABLE
void ftpManager ( void ) {
void ftpManager ( void ) {
if ( ftpEnableLastStatus & & ! ftpEnableCurrentStatus ) {
if ( ftpEnableLastStatus & & ! ftpEnableCurrentStatus ) {
snprintf ( logBuf , serialLoglength , " %s: %u " , ( char * ) FPSTR ( freeHeapWithoutFtp ) , ESP . getFreeHeap ( ) ) ;
loggerNl ( logBuf , LOGLEVEL_DEBUG ) ;
ftpEnableCurrentStatus = true ;
ftpEnableCurrentStatus = true ;
ftpSrv . begin ( FSystem , ftpUser , ftpPassword ) ;
ftpSrv = new FtpServer ( ) ;
ftpSrv - > begin ( FSystem , ftpUser , ftpPassword ) ;
snprintf ( logBuf , serialLoglength , " %s: %u " , ( char * ) FPSTR ( freeHeapWithFtp ) , ESP . getFreeHeap ( ) ) ;
loggerNl ( logBuf , LOGLEVEL_DEBUG ) ;
# if (LANGUAGE == 1)
# if (LANGUAGE == 1)
Serial . println ( F ( " FTP-Server gestartet " ) ) ;
Serial . println ( F ( " FTP-Server gestartet " ) ) ;
# else
# else
@ -3090,6 +3096,7 @@ bool writeWifiStatusToNVS(bool wifiStatus) {
}
}
# endif
# endif
// Provides management for WiFi
// Provides management for WiFi
wl_status_t wifiManager ( void ) {
wl_status_t wifiManager ( void ) {
// If wifi whould not be activated, return instantly
// If wifi whould not be activated, return instantly
@ -4046,17 +4053,15 @@ void setup() {
lastTimeActiveTimestamp = millis ( ) ; // initial set after boot
lastTimeActiveTimestamp = millis ( ) ; // initial set after boot
/**
* Create empty Index json file when no file exists .
*/
if ( ! fileExists ( FSystem , DIRECTORY_INDEX_FILE ) ) {
// Create empty index json-file when no file exists.
if ( ! fileExists ( FSystem , DIRECTORY_INDEX_FILE ) ) {
createFile ( FSystem , DIRECTORY_INDEX_FILE , " [] " ) ;
createFile ( FSystem , DIRECTORY_INDEX_FILE , " [] " ) ;
ESP . restart ( ) ;
ESP . restart ( ) ;
}
}
bootComplete = true ;
bootComplete = true ;
Serial . print ( F ( " Free heap: " ) ) ;
Serial . println ( ESP . getFreeHeap ( ) ) ;
snprintf ( logBuf , serialLoglength , " %s: %u " , ( char * ) FPSTR ( freeHeapAfterSetup ) , ESP . getFreeHeap ( ) ) ;
loggerNl ( logBuf , LOGLEVEL_DEBUG ) ;
}
}
@ -4085,13 +4090,13 @@ void loop() {
# endif
# endif
# ifdef FTP_ENABLE
# ifdef FTP_ENABLE
if ( ftpEnableLastStatus & & ftpEnableCurrentStatus ) {
if ( ftpEnableLastStatus & & ftpEnableCurrentStatus ) {
ftpSrv . handleFTP ( ) ;
ftpSrv - > handleFTP ( ) ;
}
}
# endif
# endif
}
}
# ifdef FTP_ENABLE
# ifdef FTP_ENABLE
if ( ftpEnableLastStatus & & ftpEnableCurrentStatus ) {
if ( ftpEnableLastStatus & & ftpEnableCurrentStatus ) {
if ( ftpSrv . isConnected ( ) ) {
if ( ftpSrv - > isConnected ( ) ) {
lastTimeActiveTimestamp = millis ( ) ; // Re-adjust timer while client is connected to avoid ESP falling asleep
lastTimeActiveTimestamp = millis ( ) ; // Re-adjust timer while client is connected to avoid ESP falling asleep
}
}
}
}