From db2b334ee86c55e95b16fd3444615ed141a0e8bf Mon Sep 17 00:00:00 2001 From: vidplace7 Date: Tue, 9 Jun 2026 19:34:24 -0400 Subject: [PATCH] Short circuit invalid nodenum check in ham mode. Until signing is implemented, this will prevent the nodenum from being regenerated upon each reboot. --- src/mesh/NodeDB.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index b047a14a6..23df4df63 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1542,6 +1542,8 @@ void NodeDB::pickNewNodeNum() // Identity check via public key (or "empty slot?" when no keys yet); // macaddr no longer lives on the slim header. + // This check does not work when is_licensed=true since we don't store a public key. + // Revisit with XEdDSA signing. auto isOurOwnEntry = [&](const meshtastic_NodeInfoLite *n) -> bool { if (!n) return false; @@ -1550,13 +1552,16 @@ void NodeDB::pickNewNodeNum() return !nodeInfoLiteHasUser(n); }; - meshtastic_NodeInfoLite *found; - while (((found = getMeshNode(nodeNum)) && !isOurOwnEntry(found)) || - (nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) { - NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice - if (found) - LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, picking 0x%x", nodeNum, candidate); - nodeNum = candidate; + // Short circuit the check for licensed devices since they do not have public keys to compare against the nodeDB. + if (!owner.is_licensed) { + meshtastic_NodeInfoLite *found; + while (((found = getMeshNode(nodeNum)) && !isOurOwnEntry(found)) || + (nodeNum == NODENUM_BROADCAST || nodeNum < NUM_RESERVED)) { + NodeNum candidate = random(NUM_RESERVED, LONG_MAX); // try a new random choice + if (found) + LOG_WARN("NOTE! Our desired nodenum 0x%x is invalid or in use, picking 0x%x", nodeNum, candidate); + nodeNum = candidate; + } } LOG_DEBUG("Use nodenum 0x%x ", nodeNum);