Pipe rssi to the view

pull/265/head
Vadim Furman 2021-03-22 21:10:58 -07:00
rodzic b5c5cf0153
commit 0d9f31f7fb
4 zmienionych plików z 28 dodań i 17 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)

Wyświetl plik

@ -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
}
}

Wyświetl plik

@ -60,7 +60,7 @@
android:layout_marginBottom="8dp"
android:text="@string/sample_coords"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/distance_view"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:layout_constraintVertical_bias="0.0" />
@ -85,16 +85,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/batteryIcon" />
<TextView
android:id="@+id/snrView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="-8.0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/lastCommIcon" />
<ImageView
android:id="@+id/lastCommIcon"
android:layout_width="wrap_content"
@ -102,7 +92,8 @@
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/batteryIcon"
app:layout_constraintBottom_toTopOf="@id/signalView"
app:layout_constraintEnd_toStartOf="@+id/lastConnectionView"
app:srcCompat="@drawable/ic_antenna_24" />
@ -116,6 +107,17 @@
app:layout_constraintBottom_toBottomOf="@+id/lastCommIcon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/lastCommIcon" />
<TextView
android:id="@+id/signalView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="rssi:-40 snr:-8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/lastConnectionView"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>