kopia lustrzana https://github.com/meshtastic/firmware
Merge branch 'master' into ESPIDF-Rollup
commit
5775c390f3
|
@ -6,6 +6,7 @@ build_src_filter =
|
|||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040>
|
||||
upload_speed = 921600
|
||||
debug_init_break = tbreak setup
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||
|
|
|
@ -6,6 +6,7 @@ build_src_filter =
|
|||
upload_speed = 961200
|
||||
monitor_speed = 115200
|
||||
debug_init_break = tbreak setup
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||
|
|
117
src/FSCommon.cpp
117
src/FSCommon.cpp
|
@ -33,17 +33,25 @@ bool copyFile(const char* from, const char* to)
|
|||
bool renameFile(const char* pathFrom, const char* pathTo)
|
||||
{
|
||||
#ifdef FSCom
|
||||
#ifdef ARCH_ESP32
|
||||
// rename was fixed for ESP32 IDF LittleFS in April
|
||||
return FSCom.rename(pathFrom, pathTo);
|
||||
#else
|
||||
if (copyFile(pathFrom, pathTo) && FSCom.remove(pathFrom) ) {
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void listDir(const char * dirname, uint8_t levels)
|
||||
void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
||||
{
|
||||
#ifdef FSCom
|
||||
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||
char buffer[255];
|
||||
#endif
|
||||
File root = FSCom.open(dirname, FILE_O_READ);
|
||||
if(!root){
|
||||
return;
|
||||
|
@ -57,62 +65,91 @@ void listDir(const char * dirname, uint8_t levels)
|
|||
if(file.isDirectory() && !String(file.name()).endsWith(".")) {
|
||||
if(levels){
|
||||
#ifdef ARCH_ESP32
|
||||
listDir(file.path(), levels -1);
|
||||
listDir(file.path(), levels -1, del);
|
||||
if(del) {
|
||||
DEBUG_MSG("Removing %s\n", file.path());
|
||||
strcpy(buffer, file.path());
|
||||
file.close();
|
||||
FSCom.rmdir(buffer);
|
||||
} else {
|
||||
file.close();
|
||||
}
|
||||
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||
listDir(file.name(), levels -1, del);
|
||||
if(del) {
|
||||
DEBUG_MSG("Removing %s\n", file.name());
|
||||
strcpy(buffer, file.name());
|
||||
file.close();
|
||||
FSCom.rmdir(buffer);
|
||||
} else {
|
||||
file.close();
|
||||
}
|
||||
#else
|
||||
listDir(file.name(), levels -1);
|
||||
listDir(file.name(), levels -1, del);
|
||||
file.close();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#ifdef ARCH_ESP32
|
||||
if(del) {
|
||||
DEBUG_MSG("Deleting %s\n", file.path());
|
||||
strcpy(buffer, file.path());
|
||||
file.close();
|
||||
FSCom.remove(buffer);
|
||||
} else {
|
||||
DEBUG_MSG(" %s (%i Bytes)\n", file.path(), file.size());
|
||||
file.close();
|
||||
}
|
||||
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||
if(del) {
|
||||
DEBUG_MSG("Deleting %s\n", file.name());
|
||||
strcpy(buffer, file.name());
|
||||
file.close();
|
||||
FSCom.remove(buffer);
|
||||
} else {
|
||||
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||
file.close();
|
||||
}
|
||||
#else
|
||||
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||
file.close();
|
||||
#endif
|
||||
}
|
||||
file.close();
|
||||
file = root.openNextFile();
|
||||
}
|
||||
file.close();
|
||||
#ifdef ARCH_ESP32
|
||||
if(del) {
|
||||
DEBUG_MSG("Removing %s\n", root.path());
|
||||
strcpy(buffer, root.path());
|
||||
root.close();
|
||||
FSCom.rmdir(buffer);
|
||||
} else {
|
||||
root.close();
|
||||
}
|
||||
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||
if(del) {
|
||||
DEBUG_MSG("Removing %s\n", root.name());
|
||||
strcpy(buffer, root.name());
|
||||
root.close();
|
||||
FSCom.rmdir(buffer);
|
||||
} else {
|
||||
root.close();
|
||||
}
|
||||
#else
|
||||
root.close();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void rmDir(const char * dirname)
|
||||
{
|
||||
#ifdef FSCom
|
||||
File file = FSCom.open(dirname, FILE_O_READ);
|
||||
if(!file){
|
||||
return;
|
||||
}
|
||||
if(!file.isDirectory()){
|
||||
file.close();
|
||||
FSCom.remove(file.name());
|
||||
// DEBUG_MSG("Remove FILE %s\n", file.name());
|
||||
return;
|
||||
}
|
||||
|
||||
file.rewindDirectory();
|
||||
while (true) {
|
||||
File entry = file.openNextFile();
|
||||
if (!entry) {
|
||||
break;
|
||||
}
|
||||
char dirpath[100]; // array to hold the result.
|
||||
strcpy(dirpath, dirname); // copy string one into the result.
|
||||
strcat(dirpath,"/"); // append string two to the result.
|
||||
strcat(dirpath,entry.name()); // append string two to the result.
|
||||
if(entry.isDirectory() && !String(entry.name()).endsWith(".")) {
|
||||
entry.close();
|
||||
DEBUG_MSG("Descend DIR %s\n", dirpath);
|
||||
rmDir(dirpath);
|
||||
} else {
|
||||
entry.close();
|
||||
DEBUG_MSG("Remove FILE %s\n", entry.name());
|
||||
FSCom.remove(entry.name());
|
||||
}
|
||||
}
|
||||
FSCom.rmdir(dirname);
|
||||
DEBUG_MSG("Remove DIR %s\n", dirname);
|
||||
file.close();
|
||||
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||
listDir(dirname, 10, true);
|
||||
#elif defined(ARCH_NRF52)
|
||||
// nRF52 implementation of LittleFS has a recursive delete function
|
||||
FSCom.rmdir_r(dirname);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -125,7 +162,7 @@ void fsInit()
|
|||
assert(0); // FIXME - report failure to phone
|
||||
}
|
||||
#ifdef ARCH_ESP32
|
||||
DEBUG_MSG("Filesystem files (%d/%d total Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes());
|
||||
DEBUG_MSG("Filesystem files (%d/%d Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes());
|
||||
#else
|
||||
DEBUG_MSG("Filesystem files:\n");
|
||||
#endif
|
||||
|
|
|
@ -42,5 +42,5 @@ using namespace Adafruit_LittleFS_Namespace;
|
|||
void fsInit();
|
||||
bool copyFile(const char* from, const char* to);
|
||||
bool renameFile(const char* pathFrom, const char* pathTo);
|
||||
void listDir(const char * dirname, uint8_t levels);
|
||||
void listDir(const char * dirname, uint8_t levels, boolean del);
|
||||
void rmDir(const char * dirname);
|
||||
|
|
|
@ -86,7 +86,7 @@ static char ourId[5];
|
|||
GeoCoord geoCoord;
|
||||
|
||||
// OEM Config File
|
||||
static const char *oemConfigFile = "/prefs/oem.proto";
|
||||
static const char *oemConfigFile = "/oem/oem.proto";
|
||||
OEMStore oemStore;
|
||||
|
||||
#ifdef SHOW_REDRAWS
|
||||
|
|
Ładowanie…
Reference in New Issue