Merge branch 'master' into neighborinfo

This commit is contained in:
Ben Meadors 2023-06-21 21:11:06 -05:00 committed by GitHub
commit bbfd62c47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -303,6 +303,7 @@ void NodeDB::installDefaultDeviceState()
snprintf(owner.short_name, sizeof(owner.short_name), "%02x%02x", ourMacAddr[4], ourMacAddr[5]); 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 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() void NodeDB::init()
@ -381,8 +382,7 @@ void NodeDB::pickNewNodeNum()
{ {
NodeNum r = myNodeInfo.my_node_num; NodeNum r = myNodeInfo.my_node_num;
// If we don't have a nodenum at app - pick an initial nodenum based on the macaddr // Pick an initial nodenum based on the macaddr
if (r == 0)
r = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5]; r = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5];
if (r == NODENUM_BROADCAST || r < NUM_RESERVED) if (r == NODENUM_BROADCAST || r < NUM_RESERVED)
@ -390,8 +390,9 @@ void NodeDB::pickNewNodeNum()
meshtastic_NodeInfoLite *found; meshtastic_NodeInfoLite *found;
while ((found = getMeshNode(r)) && memcmp(found->user.macaddr, owner.macaddr, sizeof(owner.macaddr))) { 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 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; r = n;
} }

View File

@ -14,6 +14,7 @@
#undef GPS_SERIAL_NUM #undef GPS_SERIAL_NUM
#define LED_CONN PIN_LED2 #define LED_CONN PIN_LED2
#define LED_PIN LED_BUILTIN
#define BUTTON_PIN 9 #define BUTTON_PIN 9
#define BUTTON_NEED_PULLUP #define BUTTON_NEED_PULLUP