mirror of
https://github.com/meshtastic/firmware.git
synced 2026-10-10 07:38:42 -04:00
Add configurable event mode hop limit (#11275)
* feat: resolve event mode hop limit * feat: bake event mode hop limit * fix: honor event mode hop cap in routing * docs: expose event mode hop limit preference * fix: enforce event hop defaults across routing * docs: clarify event hop override behavior * refactor: simplify event mode hop preference * fix: cap equal event hop limit
This commit is contained in:
1 parent
b4ff1df864
commit
0fef83d434
8 files changed
+126
-13
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "NextHopRouter.h"
|
||||
#include "Default.h"
|
||||
#include "MeshTypes.h"
|
||||
#include "meshUtils.h"
|
||||
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
||||
@@ -9,6 +10,18 @@
|
||||
#endif
|
||||
#include "NodeDB.h"
|
||||
|
||||
#if USERPREFS_EVENT_MODE
|
||||
static void capEventRelayHops(meshtastic_MeshPacket *packet)
|
||||
{
|
||||
if (packet->hop_limit <= Default::eventModeRelayHopLimit)
|
||||
return;
|
||||
|
||||
const uint8_t reduction = packet->hop_limit - Default::eventModeRelayHopLimit;
|
||||
packet->hop_start = reduction <= packet->hop_start ? packet->hop_start - reduction : 0;
|
||||
packet->hop_limit = Default::eventModeRelayHopLimit;
|
||||
}
|
||||
#endif
|
||||
|
||||
NextHopRouter::NextHopRouter() {}
|
||||
|
||||
bool NextHopRouter::relayOpaquePacket(const meshtastic_MeshPacket *p)
|
||||
@@ -26,6 +39,9 @@ bool NextHopRouter::relayOpaquePacket(const meshtastic_MeshPacket *p)
|
||||
if (!relay)
|
||||
return false;
|
||||
relay->hop_limit--;
|
||||
#if USERPREFS_EVENT_MODE
|
||||
capEventRelayHops(relay);
|
||||
#endif
|
||||
relay->relay_node = nodeDB->getLastByteOfNodeNum(getNodeNum());
|
||||
// The interface declines some packets (NODENUM_BROADCAST_NO_LORA) with ERRNO_SHOULD_RELEASE,
|
||||
// which leaves the copy ours to free. Dropping it here would leak a pool slot per opaque frame.
|
||||
@@ -211,11 +227,7 @@ bool NextHopRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
|
||||
LOG_INFO("favorite-ROUTER/CLIENT_BASE-to-ROUTER/CLIENT_BASE rebroadcast: preserving hop_limit");
|
||||
}
|
||||
#if USERPREFS_EVENT_MODE
|
||||
if (tosend->hop_limit > 2) {
|
||||
// if we are "correcting" the hop_limit, "correct" the hop_start by the same amount to preserve hops away.
|
||||
tosend->hop_start -= (tosend->hop_limit - 2);
|
||||
tosend->hop_limit = 2;
|
||||
}
|
||||
capEventRelayHops(tosend);
|
||||
#endif
|
||||
|
||||
ErrorCode res =
|
||||
|
||||
Reference in new issue
Block a user