Fix ESP8266 unzip

This commit is contained in:
fvanroie 2021-06-25 23:50:55 +02:00
parent 37face7114
commit b520ae0253
3 changed files with 21 additions and 13 deletions

View File

@ -1082,8 +1082,10 @@ void dispatchSetup()
dispatch_add_command(PSTR("discovery"), dispatch_send_discovery);
dispatch_add_command(PSTR("factoryreset"), dispatch_factory_reset);
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32)
dispatch_add_command(PSTR("unzip"), filesystemUnzip);
#endif
#endif
#if HASP_USE_CONFIG > 0
dispatch_add_command(PSTR("setupap"), oobeFakeSetup);
#endif

View File

@ -11,21 +11,10 @@
#include "hasp_debug.h"
#include "hasp_filesystem.h"
#if defined(ARDUINO_ARCH_ESP32)
#include "rom/crc.h"
void filesystemInfo()
{ // Get all information of your SPIFFS
#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);
#endif
#ifdef ESP32
Log.verbose(TAG_FILE, "Partition size: total: %d, used: %d", HASP_FS.totalBytes(), HASP_FS.usedBytes());
#endif
}
void filesystemUnzip(const char*, const char* filename)
{
File zipfile = HASP_FS.open(filename, FILE_READ);
@ -137,6 +126,20 @@ void filesystemUnzip(const char*, const char* filename)
zipfile.close();
LOG_VERBOSE(TAG_FILE, F("extracting %s complete"), filename);
}
#endif
void filesystemInfo()
{ // Get all information of your SPIFFS
#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);
#endif
#ifdef ESP32
Log.verbose(TAG_FILE, "Partition size: total: %d, used: %d", HASP_FS.totalBytes(), HASP_FS.usedBytes());
#endif
}
void filesystemList()
{

View File

@ -10,7 +10,10 @@ bool filesystemSetup(void);
void filesystemList();
void filesystemInfo();
#if defined(ARDUINO_ARCH_ESP32)
void filesystemUnzip(const char*, const char* filename);
#endif
enum { ZIP_NO_COMPRESSION = 0, ZIP_DEFLTATE = 8 };
typedef uint16_t zip_compression_method_t;