From ab4b3a50eec66e0706871abb7112963b208c9c20 Mon Sep 17 00:00:00 2001 From: Neil Hao Date: Thu, 29 Sep 2022 04:53:26 +0800 Subject: [PATCH 1/4] 'battery_gauge_fix' (#1731) --- src/Power.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index 45092fdc6..767c5ca0c 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -131,7 +131,7 @@ class AnalogBatteryLevel : public HasBatteryLevel #endif // DEBUG_MSG("battery gpio %d raw val=%u scaled=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled)); last_read_value = scaled; - return scaled * 1000; + return scaled; } else { return last_read_value; } From ac235bcabb86427368d95805504b9619fa503c5c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 28 Sep 2022 16:47:26 -0500 Subject: [PATCH 2/4] Reset nodedb wiring (#1724) --- src/mesh/NodeDB.cpp | 11 +++++++++-- src/mesh/NodeDB.h | 2 +- src/modules/AdminModule.cpp | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 4e06d263a..22ea77e93 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -225,13 +225,20 @@ void NodeDB::installDefaultChannels() channelFile.version = DEVICESTATE_CUR_VER; } +void NodeDB::resetNodes() +{ + devicestate.node_db_count = 0; + memset(devicestate.node_db, 0, sizeof(devicestate.node_db)); + saveDeviceStateToDisk(); +} + void NodeDB::installDefaultDeviceState() { DEBUG_MSG("Installing default DeviceState\n"); memset(&devicestate, 0, sizeof(DeviceState)); - *numNodes = 0; // Forget node DB - + *numNodes = 0; + // init our devicestate with valid flags so protobuf writing/reading will work devicestate.has_my_node = true; devicestate.has_owner = true; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 429e79fdc..47145fc34 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -115,7 +115,7 @@ class NodeDB /// Return the number of nodes we've heard from recently (within the last 2 hrs?) size_t getNumOnlineNodes(); - void initConfigIntervals(), initModuleConfigIntervals(); + void initConfigIntervals(), initModuleConfigIntervals(), resetNodes(); bool factoryReset(); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 9dcdcda9c..4dd9d57b5 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -120,6 +120,12 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) rebootAtMsec = millis() + (5 * 1000); break; } + case AdminMessage_nodedb_reset_tag: { + DEBUG_MSG("Initiating node-db reset\n"); + nodeDB.resetNodes(); + rebootAtMsec = millis() + (5 * 1000); + break; + } #ifdef ARCH_PORTDUINO case AdminMessage_exit_simulator_tag: DEBUG_MSG("Exiting simulator\n"); From d95ec7e6b9e0f6d06a61a7ee1a0f7f1814b7994d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 29 Sep 2022 13:21:48 +0200 Subject: [PATCH 3/4] fix TLORA-V2.1-1.6 --- variants/tlora_v2_1_16/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/tlora_v2_1_16/platformio.ini b/variants/tlora_v2_1_16/platformio.ini index 9974d0466..84ffc1ea8 100644 --- a/variants/tlora_v2_1_16/platformio.ini +++ b/variants/tlora_v2_1_16/platformio.ini @@ -1,5 +1,5 @@ [env:tlora-v2-1-1.6] extends = esp32_base -board = ttgo-lora32-v1 +board = ttgo-lora32-v21 build_flags = ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/tlora_v2_1_16 \ No newline at end of file From daf189bf4bf0f8228884a003ab68b69e0a786011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 29 Sep 2022 13:23:23 +0200 Subject: [PATCH 4/4] Check in variant.h change --- variants/tlora_v2_1_16/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/tlora_v2_1_16/variant.h b/variants/tlora_v2_1_16/variant.h index 16d02e150..a58b10b81 100644 --- a/variants/tlora_v2_1_16/variant.h +++ b/variants/tlora_v2_1_16/variant.h @@ -12,7 +12,7 @@ #define I2C_SDA 21 // I2C pins for this board #define I2C_SCL 22 -#define RESET_OLED 16 // If defined, this pin will be used to reset the display controller +// #define RESET_OLED 16 // If defined, this pin will be used to reset the display controller. Crashes on newer ESP-IDF and not needed per schematic #define VEXT_ENABLE 21 // active low, powers the oled display and the lora antenna boost #define LED_PIN 25 // If defined we will blink this LED