From 41c1b29d70f463b4a0c33970c0f79d1358b0518a Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 20 May 2025 21:29:29 -0500 Subject: [PATCH] Add basic handling for is_manually_validated (#6856) --- src/mesh/NodeDB.cpp | 6 ++++-- src/mesh/NodeDB.h | 2 ++ src/mesh/TypeConversions.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 4b1a6d64d..12756abce 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1653,8 +1653,10 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n) int oldestIndex = -1; int oldestBoringIndex = -1; for (int i = 1; i < numMeshNodes; i++) { - // Simply the oldest non-favorite node - if (!meshNodes->at(i).is_favorite && !meshNodes->at(i).is_ignored && meshNodes->at(i).last_heard < oldest) { + // Simply the oldest non-favorite, non-ignored, non-verified node + if (!meshNodes->at(i).is_favorite && !meshNodes->at(i).is_ignored && + !(meshNodes->at(i).bitfield & NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK) && + meshNodes->at(i).last_heard < oldest) { oldest = meshNodes->at(i).last_heard; oldestIndex = i; } diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 4dbda6a9f..16159d380 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -274,6 +274,8 @@ extern meshtastic_CriticalErrorCode error_code; * A numeric error address (nonzero if available) */ extern uint32_t error_address; +#define NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_SHIFT 0 +#define NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK (1 << NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_SHIFT) #define Module_Config_size \ (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ diff --git a/src/mesh/TypeConversions.cpp b/src/mesh/TypeConversions.cpp index 5fc6b8a64..c47a67e68 100644 --- a/src/mesh/TypeConversions.cpp +++ b/src/mesh/TypeConversions.cpp @@ -13,6 +13,7 @@ meshtastic_NodeInfo TypeConversions::ConvertToNodeInfo(const meshtastic_NodeInfo info.via_mqtt = lite->via_mqtt; info.is_favorite = lite->is_favorite; info.is_ignored = lite->is_ignored; + info.is_key_manually_verified = lite->bitfield & NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK; if (lite->has_hops_away) { info.has_hops_away = true;