From 9893d24c625b8e3a926031ddb19d60c73bafc63e Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 1 Mar 2025 13:57:44 +0100 Subject: [PATCH] Only request all NodeInfo/Position on fresh install (#6184) Co-authored-by: Ben Meadors --- src/mesh/NodeDB.cpp | 8 +++++--- src/mesh/NodeDB.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 6588ca46b..62ab675bc 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -400,11 +400,13 @@ bool isBroadcast(uint32_t dest) return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA; } -bool NodeDB::resetRadioConfig(bool factory_reset) +bool NodeDB::resetRadioConfig(bool factory_reset, bool is_fresh_install) { bool didFactoryReset = false; - radioGeneration++; + if (is_fresh_install) { + radioGeneration++; + } if (factory_reset) { didFactoryReset = factoryReset(); @@ -589,7 +591,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) config.device.node_info_broadcast_secs = default_node_info_broadcast_secs; config.security.serial_enabled = true; config.security.admin_channel_enabled = false; - resetRadioConfig(); + resetRadioConfig(false, true); // This also triggers NodeInfo/Position requests since we're fresh strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32); #if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR)) && \ diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 44e2ebcc8..25f1e9083 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -99,9 +99,11 @@ class NodeDB * a) sometimes a buggy android app might send us bogus settings or * b) the client set factory_reset * + * @param factory_reset if true, reset all settings to factory defaults + * @param is_fresh_install set to true after a fresh install, to trigger NodeInfo/Position requests * @return true if the config was completely reset, in that case, we should send it back to the client */ - bool resetRadioConfig(bool factory_reset = false); + bool resetRadioConfig(bool factory_reset = false, bool is_fresh_install = false); /// given a subpacket sniffed from the network, update our DB state /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw