From aead7a23f9ee47c30ea0c6bbcd1c45f3ecb2bbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 22 Jun 2022 09:52:08 +0200 Subject: [PATCH 1/3] - Put Modemconfig in logical order and fix typo - non-zero config.lora.bandwidth means a custom radio config, not 'Unknown' - Enable 'this is a new device, set region' screen again now we can actually set region. --- src/configuration.h | 4 ++-- src/graphics/Screen.cpp | 4 ++-- src/mesh/Channels.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index f0d44a3e..f932d301 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -142,10 +142,10 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- // Disable use of the NTP library and related features -//#define DISABLE_NTP +// #define DISABLE_NTP // Disable the welcome screen and allow -#define DISABLE_WELCOME_UNSET +// #define DISABLE_WELCOME_UNSET // ----------------------------------------------------------------------------- // OLED & Input diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index c5e06c85..b8eb7917 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1531,10 +1531,10 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat case Config_LoRaConfig_ModemPreset_MedFast: mode = "MedF"; break; - case Config_LoRaConfig_ModemPreset_LongFast: + case Config_LoRaConfig_ModemPreset_LongSlow: mode = "LongS"; break; - case Config_LoRaConfig_ModemPreset_LongSlow: + case Config_LoRaConfig_ModemPreset_LongFast: mode = "LongF"; break; case Config_LoRaConfig_ModemPreset_VLongSlow: diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 01e7e0f4..2385da77 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -211,7 +211,7 @@ const char *Channels::getName(size_t chIndex) // the app fucked up and forgot to set channelSettings.name if (config.lora.bandwidth != 0) - channelName = "Unset"; + channelName = "Custom"; else switch (config.lora.modem_preset) { case Config_LoRaConfig_ModemPreset_ShortSlow: @@ -226,10 +226,10 @@ const char *Channels::getName(size_t chIndex) case Config_LoRaConfig_ModemPreset_MedFast: channelName = "MedF"; break; - case Config_LoRaConfig_ModemPreset_LongFast: + case Config_LoRaConfig_ModemPreset_LongSlow: channelName = "LongS"; break; - case Config_LoRaConfig_ModemPreset_LongSlow: + case Config_LoRaConfig_ModemPreset_LongFast: channelName = "LongF"; break; case Config_LoRaConfig_ModemPreset_VLongSlow: From bc47dd574b4551f9a831e4a1ae18f025706ca693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 22 Jun 2022 14:26:33 +0200 Subject: [PATCH 2/3] avoid BLE device names like a123_a123 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5efbb841..ffa2c647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -105,7 +105,7 @@ const char *getDeviceName() static char name[20]; sprintf(name, "%02x%02x", dmac[4], dmac[5]); // if the shortname exists and is NOT the new default of ab3c, use it for BLE name. - if ((owner.short_name != NULL) && (owner.short_name != name)) { + if ((owner.short_name != NULL) && (strcmp(owner.short_name, name) != 0)) { sprintf(name, "%s_%02x%02x", owner.short_name, dmac[4], dmac[5]); } else { sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]); From e7dfd14917f2d4cc2c42b6a00a715035c0c0c740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 22 Jun 2022 15:33:53 +0200 Subject: [PATCH 3/3] Change recursive delete to be recursive --- src/FSCommon.cpp | 44 ++++++++++++++++++++++++++++---------------- src/mesh/NodeDB.cpp | 16 ++++++++-------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 5293c401..b0ba44f2 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -2,8 +2,8 @@ #include "FSCommon.h" void listDir(const char * dirname, uint8_t levels) -#ifdef FSCom { +#ifdef FSCom File root = FSCom.open(dirname); if(!root){ return; @@ -29,29 +29,41 @@ void listDir(const char * dirname, uint8_t levels) } void rmDir(const char * dirname) -#ifdef FSCom { - File root = FSCom.open(dirname); - if(!root){ +#ifdef FSCom + File file = FSCom.open(dirname); + if(!file){ return; } - if(!root.isDirectory()){ + if(!file.isDirectory()){ + file.close(); + FSCom.remove(file.name()); + // DEBUG_MSG("Remove FILE %s\n", file.name()); return; } - File file = root.openNextFile(); - while(file){ - if(file.isDirectory() && !String(file.name()).endsWith(".")) { - file.close(); - rmDir(file.name()); - FSCom.rmdir(file.name()); - } else { - file.close(); - FSCom.remove(file.name()); + 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()); } - file.close(); - file = root.openNextFile(); } + FSCom.rmdir(dirname); + // DEBUG_MSG("Remove DIR %s\n", dirname); file.close(); #endif } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 4d9e27cf..a6e61734 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -337,16 +337,16 @@ void NodeDB::loadFromDisk() DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version); installDefaultDeviceState(); #ifndef NO_ESP32 - // This will erase what's in NVS including ssl keys, persistant variables and ble pairing - nvs_flash_erase(); + // This will erase what's in NVS including ssl keys, persistant variables and ble pairing + nvs_flash_erase(); #endif #ifdef NRF52_SERIES - Bluefruit.begin(); - DEBUG_MSG("Clearing bluetooth bonds!\n"); - bond_print_list(BLE_GAP_ROLE_PERIPH); - bond_print_list(BLE_GAP_ROLE_CENTRAL); - Bluefruit.Periph.clearBonds(); - Bluefruit.Central.clearBonds(); + Bluefruit.begin(); + DEBUG_MSG("Clearing bluetooth bonds!\n"); + bond_print_list(BLE_GAP_ROLE_PERIPH); + bond_print_list(BLE_GAP_ROLE_CENTRAL); + Bluefruit.Periph.clearBonds(); + Bluefruit.Central.clearBonds(); #endif } else { DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);