From 27a492adf866f52c54a5595e6109cc58af562312 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 14 Oct 2023 17:18:05 +0200 Subject: [PATCH] If packet traveled 1 hop, set `relay_node` as `next_hop` for the original transmitter --- src/mesh/NodeDB.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 198abdd7c..1eb01e9ea 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -795,6 +795,9 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp) // If this packet didn't travel any hops, then it was sent directly to us, so we know what to use as next hop to this node if (mp.original_hop_limit == mp.hop_limit) { info->next_hop = (uint8_t)(mp.from & 0xFF); + } else if (mp.relay_node && (mp.original_hop_limit - mp.hop_limit == 1)) { + // This packet traveled one hop, so we can use the relay_node as next_hop + info->next_hop = (uint8_t)(mp.relay_node & 0xFF); } } }