From 24e5454faebbfa9aacd9a2bd1522a9848546e043 Mon Sep 17 00:00:00 2001 From: andrekir Date: Sun, 15 Jan 2023 17:49:59 -0300 Subject: [PATCH] feat: improve handleReceivedPosition validation --- .../main/java/com/geeksville/mesh/service/MeshService.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 48035871e..4bb0eb81a 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -737,11 +737,10 @@ class MeshService : Service(), Logging { p: MeshProtos.Position, defaultTime: Long = System.currentTimeMillis() ) { - // Nodes periodically send out position updates, but those updates might not contain a lat & lon (because no GPS lock) - // We like to look at the local node to see if it has been sending out valid lat/lon, so for the LOCAL node (only) + // Nodes periodically send out position updates, but those updates might not contain valid data so // we don't record these nop position updates - if (myNodeNum == fromNum && p.latitudeI == 0 && p.longitudeI == 0) - debug("Ignoring nop position update for the local node") + if (!Position(p).isValid() && currentSecond() - p.time > 2592000) // 30 days in seconds + debug("Ignoring nop position update for node $fromNum") else updateNodeInfo(fromNum) { debug("update position: ${it.user?.longName?.toPIIString()} with ${p.toPIIString()}") @@ -1661,7 +1660,7 @@ class MeshService : Service(), Logging { override fun requestPosition(idNum: Int, lat: Double, lon: Double, alt: Int) = toRemoteExceptions { // request position - if (idNum != 0) sendPosition(time = 0, destNum = idNum, wantResponse = true) + if (idNum != 0) sendPosition(time = 1, destNum = idNum, wantResponse = true) // set local node's fixed position else sendPosition(time = 0, destNum = null, lat = lat, lon = lon, alt = alt) }