From ed2703c77ab1dde657b1e18fd7b31fe6805fa08d Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:16:15 -0500 Subject: [PATCH] fix: Correctly compare hopStart and hopLimit for received packets fixes: #1304 The calculation of `hopsAway` was using an incorrect comparison between `hopStart` and `hopLimit`. This commit fixes the logic to correctly determine the number of hops a packet has traveled. --- app/src/main/java/com/geeksville/mesh/service/MeshService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 47aa29927..231c5bf97 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -1101,7 +1101,7 @@ class MeshService : Service(), Logging { it.rssi = packet.rxRssi // Generate our own hopsAway, comparing hopStart to hopLimit. - it.hopsAway = if (packet.hopStart == 0 || packet.hopLimit < packet.hopStart) { + it.hopsAway = if (packet.hopStart == 0 || packet.hopLimit > packet.hopStart) { -1 } else { packet.hopStart - packet.hopLimit