kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat: improve handleReceivedPosition validation
rodzic
e147c0e0c5
commit
24e5454fae
|
@ -737,11 +737,10 @@ class MeshService : Service(), Logging {
|
||||||
p: MeshProtos.Position,
|
p: MeshProtos.Position,
|
||||||
defaultTime: Long = System.currentTimeMillis()
|
defaultTime: Long = System.currentTimeMillis()
|
||||||
) {
|
) {
|
||||||
// Nodes periodically send out position updates, but those updates might not contain a lat & lon (because no GPS lock)
|
// Nodes periodically send out position updates, but those updates might not contain valid data so
|
||||||
// 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)
|
|
||||||
// we don't record these nop position updates
|
// we don't record these nop position updates
|
||||||
if (myNodeNum == fromNum && p.latitudeI == 0 && p.longitudeI == 0)
|
if (!Position(p).isValid() && currentSecond() - p.time > 2592000) // 30 days in seconds
|
||||||
debug("Ignoring nop position update for the local node")
|
debug("Ignoring nop position update for node $fromNum")
|
||||||
else
|
else
|
||||||
updateNodeInfo(fromNum) {
|
updateNodeInfo(fromNum) {
|
||||||
debug("update position: ${it.user?.longName?.toPIIString()} with ${p.toPIIString()}")
|
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) =
|
override fun requestPosition(idNum: Int, lat: Double, lon: Double, alt: Int) =
|
||||||
toRemoteExceptions {
|
toRemoteExceptions {
|
||||||
// request position
|
// 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
|
// set local node's fixed position
|
||||||
else sendPosition(time = 0, destNum = null, lat = lat, lon = lon, alt = alt)
|
else sendPosition(time = 0, destNum = null, lat = lat, lon = lon, alt = alt)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue