Skip to content

Commit

Permalink
Fix: Correctly calculate hopsAway for received packets
Browse files Browse the repository at this point in the history
fixes: meshtastic#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.
  • Loading branch information
jamesarich committed Oct 11, 2024
1 parent cf2315c commit e05e20f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e05e20f

Please sign in to comment.