From 47168d50637c24f52d7259e940706ae5935b8e9f Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Tue, 20 Jun 2023 23:29:25 +0200 Subject: [PATCH 1/2] Always assign NodeNum based on MAC address (#2567) * Always assign NodeNum based on MAC address Step one of trying to fix infinite loop * Store our mac.addr again to ignore an already existing NodeNum if it's us --- src/mesh/NodeDB.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 0d95d2cbf..307a5d85b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -299,6 +299,7 @@ void NodeDB::installDefaultDeviceState() snprintf(owner.short_name, sizeof(owner.short_name), "%02x%02x", ourMacAddr[4], ourMacAddr[5]); snprintf(owner.id, sizeof(owner.id), "!%08x", getNodeNum()); // Default node ID now based on nodenum + memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr)); } void NodeDB::init() @@ -377,17 +378,17 @@ void NodeDB::pickNewNodeNum() { NodeNum r = myNodeInfo.my_node_num; - // If we don't have a nodenum at app - pick an initial nodenum based on the macaddr - if (r == 0) - r = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5]; + // Pick an initial nodenum based on the macaddr + r = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5]; if (r == NODENUM_BROADCAST || r < NUM_RESERVED) r = NUM_RESERVED; // don't pick a reserved node number meshtastic_NodeInfoLite *found; while ((found = getMeshNode(r)) && memcmp(found->user.macaddr, owner.macaddr, sizeof(owner.macaddr))) { + // FIXME: input for random() is int, so NODENUM_BROADCAST becomes -1 NodeNum n = random(NUM_RESERVED, NODENUM_BROADCAST); // try a new random choice - LOG_DEBUG("NOTE! Our desired nodenum 0x%x is in use, so trying for 0x%x\n", r, n); + LOG_WARN("NOTE! Our desired nodenum 0x%x is in use, so trying for 0x%x\n", r, n); r = n; } From e677a0227396108926d9a15c58c0a5e9ca00f67a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 21 Jun 2023 12:11:42 -0500 Subject: [PATCH 2/2] Map built-in LED on RAK-11310 (#2568) --- variants/rak11310/variant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/rak11310/variant.h b/variants/rak11310/variant.h index a2bef0730..1d1577cfd 100644 --- a/variants/rak11310/variant.h +++ b/variants/rak11310/variant.h @@ -14,6 +14,7 @@ #undef GPS_SERIAL_NUM #define LED_CONN PIN_LED2 +#define LED_PIN LED_BUILTIN #define BUTTON_PIN 9 #define BUTTON_NEED_PULLUP