cleanup lastHeard in node info (instead of position.time)

This commit is contained in:
Kevin Hester 2021-03-27 10:53:39 +08:00
parent 3be55f8c7f
commit 3c457a118d
5 changed files with 13 additions and 21 deletions

View file

@ -84,11 +84,13 @@ data class NodeInfo(
var user: MeshUser? = null,
var position: Position? = null,
var snr: Float = Float.MAX_VALUE,
var rssi: Int = Int.MAX_VALUE
var rssi: Int = Int.MAX_VALUE,
var lastHeard: Int = 0 // the last time we've seen this node in secs since 1970
) : Parcelable {
/// Return the last time we've seen this node in secs since 1970
val lastSeen get() = position?.time ?: 0
/**
* Return the last time we've seen this node in secs since 1970
*/
val batteryPctLevel get() = position?.batteryPctLevel
@ -104,7 +106,7 @@ data class NodeInfo(
// FIXME - use correct timeout from the device settings
val timeout =
15 * 60 // Don't set this timeout too tight, or otherwise we will stop sending GPS helper positions to our device
return (now - lastSeen <= timeout) || lastSeen == 0
return (now - lastHeard <= timeout) || lastHeard == 0
}
/// return the position if it is valid, else null