adding userpref option for decoupling the auto discovery channel from auto position updates

This commit is contained in:
medentem 2024-12-15 15:26:38 -06:00
parent 69d01a8088
commit 2dc00eaa76
3 changed files with 15 additions and 0 deletions

View File

@ -53,6 +53,12 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha
LOG_DEBUG("Send ourNodeInfo to channel %d", channel);
p->channel = channel;
}
#ifdef USERPREFS_CONFIG_DISCOVERY_CHANNEL
// If this is a broadcast over the default channel, we can safely change this to the discovery channel if defined
if (dest === NODENUM_BROADCAST && channel === 0) {
p->channel = USERPREFS_CONFIG_DISCOVERY_CHANNEL;
}
#endif
prevPacketId = p->id;

View File

@ -1,5 +1,6 @@
#if !MESHTASTIC_EXCLUDE_GPS
#include "PositionModule.h"
#include "NodeInfoModule.h"
#include "Default.h"
#include "GPS.h"
#include "MeshService.h"
@ -315,6 +316,13 @@ void PositionModule::sendOurPosition()
// If we changed channels, ask everyone else for their latest info
LOG_INFO("Send pos@%x:6 to mesh (wantReplies=%d)", localPosition.timestamp, requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
#ifdef USERPREFS_CONFIG_DISCOVERY_CHANNEL
// If the user wants discovery on a different channel, send only nodeinfo to that channel
// sendOurNodeInfo() will automatically handle routing a nodeinfo packet to the correct channel
assert(nodeInfoModule);
nodeInfoModule->sendOurNodeInfo();
#endif
}
void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t channel)

View File

@ -34,4 +34,5 @@
// "USERPREFS_USE_ADMIN_KEY_0": "{ 0xcd, 0xc0, 0xb4, 0x3c, 0x53, 0x24, 0xdf, 0x13, 0xca, 0x5a, 0xa6, 0x0c, 0x0d, 0xec, 0x85, 0x5a, 0x4c, 0xf6, 0x1a, 0x96, 0x04, 0x1a, 0x3e, 0xfc, 0xbb, 0x8e, 0x33, 0x71, 0xe5, 0xfc, 0xff, 0x3c }",
// "USERPREFS_USE_ADMIN_KEY_1": "{}",
// "USERPREFS_USE_ADMIN_KEY_2": "{}"
// "USERPREFS_CONFIG_DISCOVERY_CHANNEL": "2"
}