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