mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 03:36:38 +00:00
Better FTP transfer debug messages #283
This commit is contained in:
parent
f2b7a722ee
commit
bbd4ba8d40
@ -141,15 +141,22 @@ void filesystemUnzip(const char*, const char* filename, uint8_t source)
|
||||
|
||||
void filesystemInfo()
|
||||
{ // Get all information of your SPIFFS
|
||||
char used[16] = "";
|
||||
char total[16] = "";
|
||||
|
||||
#ifdef ESP8266
|
||||
FSInfo fs_info;
|
||||
HASP_FS.info(fs_info);
|
||||
Log.verbose(TAG_FILE, "Partition size: total: %d, used: %d", fs_info.totalBytes, fs_info.usedBytes);
|
||||
Parser::format_bytes(fs_info.usedBytes(), used, sizeof(used));
|
||||
Parser::format_bytes(fs_info.totalBytes(), total, sizeof(total));
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
Log.verbose(TAG_FILE, "Partition size: total: %d, used: %d", HASP_FS.totalBytes(), HASP_FS.usedBytes());
|
||||
Parser::format_bytes(HASP_FS.usedBytes(), used, sizeof(used));
|
||||
Parser::format_bytes(HASP_FS.totalBytes(), total, sizeof(total));
|
||||
#endif
|
||||
|
||||
Log.verbose(TAG_FILE, "Partition size: used: %s / total: %s", total, used);
|
||||
}
|
||||
|
||||
void filesystemList()
|
||||
|
@ -98,9 +98,9 @@ void setup()
|
||||
httpSetup();
|
||||
#endif
|
||||
|
||||
// #if HASP_USE_CONSOLE > 0
|
||||
// consoleSetup(); // the consoleSetup is called in debugSetup
|
||||
// #endif
|
||||
// #if HASP_USE_CONSOLE > 0
|
||||
// consoleSetup(); // the consoleSetup is called in debugSetup
|
||||
// #endif
|
||||
|
||||
#if HASP_USE_TELNET > 0
|
||||
telnetSetup();
|
||||
@ -164,6 +164,10 @@ IRAM_ATTR void loop()
|
||||
/* Runs Every Second */
|
||||
haspEverySecond(); // sleep timer & statusupdate
|
||||
|
||||
#if HASP_USE_FTP > 0
|
||||
ftpEverySecond();
|
||||
#endif
|
||||
|
||||
#if HASP_USE_TELNET > 0
|
||||
telnetEverySecond();
|
||||
#endif
|
||||
|
@ -22,8 +22,10 @@ extern hasp_http_config_t http_config;
|
||||
|
||||
FtpServer ftpSrv; // set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
|
||||
|
||||
uint16_t ftpPort = 23;
|
||||
uint8_t ftpEnabled = true; // Enable telnet debug output
|
||||
uint16_t ftpPort = 23;
|
||||
uint8_t ftpEnabled = true; // Enable telnet debug output
|
||||
size_t transferSize = 0;
|
||||
const char* transferName = NULL;
|
||||
|
||||
void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace)
|
||||
{
|
||||
@ -35,7 +37,7 @@ void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int t
|
||||
LOG_VERBOSE(TAG_FTP, F(D_SERVICE_DISCONNECTED));
|
||||
break;
|
||||
case FTP_FREE_SPACE_CHANGE:
|
||||
LOG_VERBOSE(TAG_FTP, "Free space change, free %u of %u!\n", freeSpace, totalSpace);
|
||||
filesystemInfo();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -43,16 +45,31 @@ void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int t
|
||||
};
|
||||
void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize)
|
||||
{
|
||||
transferName = name;
|
||||
transferSize = transferredSize;
|
||||
|
||||
switch(ftpOperation) {
|
||||
case FTP_UPLOAD_START:
|
||||
LOG_VERBOSE(TAG_FTP, "Start upload of file %s byte %u\n", name, transferredSize);
|
||||
break;
|
||||
case FTP_UPLOAD_START: {
|
||||
char size[16];
|
||||
Parser::format_bytes(transferredSize, size, sizeof(size));
|
||||
LOG_VERBOSE(TAG_FTP, "Start upload of file %s (%s)", name, size);
|
||||
return;
|
||||
}
|
||||
case FTP_DOWNLOAD_START: {
|
||||
char size[16];
|
||||
Parser::format_bytes(transferredSize, size, sizeof(size));
|
||||
LOG_VERBOSE(TAG_FTP, "Start download of file %s (%s)", name, size);
|
||||
return;
|
||||
}
|
||||
case FTP_UPLOAD:
|
||||
LOG_VERBOSE(TAG_FTP, "Upload of file %s byte %u\n", name, transferredSize);
|
||||
break;
|
||||
case FTP_TRANSFER_STOP:
|
||||
LOG_VERBOSE(TAG_FTP, "Completed upload of file %s byte %u\n", name, transferredSize);
|
||||
case FTP_DOWNLOAD:
|
||||
return;
|
||||
case FTP_TRANSFER_STOP: {
|
||||
char size[16];
|
||||
Parser::format_bytes(transferredSize, size, sizeof(size));
|
||||
LOG_VERBOSE(TAG_FTP, "Completed transfer of file %s (%s)", name, size);
|
||||
break;
|
||||
}
|
||||
case FTP_TRANSFER_ERROR:
|
||||
LOG_VERBOSE(TAG_FTP, ("Transfer error!"));
|
||||
break;
|
||||
@ -60,6 +77,9 @@ void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsi
|
||||
break;
|
||||
}
|
||||
|
||||
transferName = NULL;
|
||||
transferSize = 0;
|
||||
|
||||
/* FTP_UPLOAD_START = 0,
|
||||
* FTP_UPLOAD = 1,
|
||||
*
|
||||
@ -95,6 +115,7 @@ void ftpStart()
|
||||
ftpSrv.begin("ftpuser", "haspadmin"); // username, password for ftp. (default 21, 50009 for PASV)
|
||||
#endif
|
||||
|
||||
LOG_VERBOSE(TAG_FTP, F(FTP_SERVER_VERSION));
|
||||
LOG_INFO(TAG_FTP, F(D_SERVICE_STARTED));
|
||||
}
|
||||
|
||||
@ -111,7 +132,13 @@ IRAM_ATTR void ftpLoop()
|
||||
}
|
||||
|
||||
void ftpEverySecond(void)
|
||||
{}
|
||||
{
|
||||
if(!transferSize || !transferName) return;
|
||||
|
||||
char size[16];
|
||||
Parser::format_bytes(transferSize, size, sizeof(size));
|
||||
LOG_VERBOSE(TAG_FTP, D_BULLET "%s (%s)", transferName, size);
|
||||
}
|
||||
|
||||
#if HASP_USE_CONFIG > 0
|
||||
bool ftpGetConfig(const JsonObject& settings)
|
||||
|
Loading…
x
Reference in New Issue
Block a user