mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Pipe rssi to the view
This commit is contained in:
parent
b5c5cf0153
commit
0d9f31f7fb
4 changed files with 28 additions and 17 deletions
|
|
@ -83,7 +83,8 @@ data class NodeInfo(
|
|||
val num: Int, // This is immutable, and used as a key
|
||||
var user: MeshUser? = null,
|
||||
var position: Position? = null,
|
||||
var snr: Float = 1000.0f
|
||||
var snr: Float = Float.MAX_VALUE,
|
||||
var rssi: Int = Int.MAX_VALUE
|
||||
) : Parcelable {
|
||||
|
||||
/// Return the last time we've seen this node in secs since 1970
|
||||
|
|
|
|||
|
|
@ -926,6 +926,7 @@ class MeshService : Service(), Logging {
|
|||
// Update our last seen based on any valid timestamps. If the device didn't provide a timestamp make one
|
||||
updateNodeInfoTime(it, rxTime)
|
||||
it.snr = packet.rxSnr
|
||||
it.rssi = packet.rxRssi
|
||||
}
|
||||
|
||||
handleReceivedData(packet)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.geeksville.mesh.databinding.NodelistFragmentBinding
|
|||
import com.geeksville.mesh.model.UIViewModel
|
||||
import com.geeksville.util.formatAgo
|
||||
import java.net.URLEncoder
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
class UsersFragment : ScreenFragment("Users"), Logging {
|
||||
|
|
@ -41,7 +42,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
val batteryPctView = itemView.batteryPercentageView
|
||||
val lastTime = itemView.lastConnectionView
|
||||
val powerIcon = itemView.batteryIcon
|
||||
val snrView = itemView.snrView
|
||||
val signalView = itemView.signalView
|
||||
}
|
||||
|
||||
private val nodesAdapter = object : RecyclerView.Adapter<ViewHolder>() {
|
||||
|
|
@ -143,10 +144,16 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
holder.lastTime.text = formatAgo(n.lastSeen);
|
||||
|
||||
if ((n.num == ourNodeInfo?.num) || (n.snr > 100f)) {
|
||||
holder.snrView.visibility = View.INVISIBLE
|
||||
holder.signalView.visibility = View.INVISIBLE
|
||||
} else {
|
||||
holder.snrView.visibility = View.VISIBLE
|
||||
holder.snrView.text = n.snr.toString()
|
||||
val text = if (n.rssi < 0) {
|
||||
"rssi:${n.rssi} snr:${n.snr.roundToInt()}"
|
||||
} else {
|
||||
// Older devices do not send rssi. Remove this branch once upgraded past 1.2.1
|
||||
"snr:${n.snr.roundToInt()}"
|
||||
}
|
||||
holder.signalView.text = text
|
||||
holder.signalView.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue