Merge pull request #355 from meshtastic/channel_util

add channelUtilization & airUtilTx protos
This commit is contained in:
Andre Kirchhoff 2022-01-26 22:54:28 -03:00 committed by GitHub
commit 563bcd4236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 10 deletions

View file

@ -16,7 +16,9 @@ data class MyNodeInfo(
val currentPacketId: Long,
val messageTimeoutMsec: Int,
val minAppVersion: Int,
val maxChannels: Int
val maxChannels: Int,
val channelUtilization: Float,
val airUtilTx: Float
) : Parcelable {
/** A human readable description of the software/hardware version */
val firmwareString: String get() = "$model $firmwareVersion"
@ -31,8 +33,10 @@ data class MyNodeInfo(
parcel.readLong(),
parcel.readInt(),
parcel.readInt(),
parcel.readInt()
)
parcel.readInt(),
parcel.readFloat(),
parcel.readFloat()
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(myNodeNum)
@ -45,6 +49,8 @@ data class MyNodeInfo(
parcel.writeInt(messageTimeoutMsec)
parcel.writeInt(minAppVersion)
parcel.writeInt(maxChannels)
parcel.writeFloat(channelUtilization)
parcel.writeFloat(airUtilTx)
}
override fun describeContents(): Int {

View file

@ -1333,7 +1333,9 @@ class MeshService : Service(), Logging {
currentPacketId.toLong() and 0xffffffffL,
if (messageTimeoutMsec == 0) 5 * 60 * 1000 else messageTimeoutMsec, // constants from current device code
minAppVersion,
maxChannels
maxChannels,
channelUtilization,
airUtilTx
)
}

View file

@ -1,6 +1,5 @@
package com.geeksville.mesh.ui
import android.os.Bundle
import android.text.Html
import android.text.method.LinkMovementMethod
@ -23,7 +22,6 @@ import com.geeksville.util.formatAgo
import java.net.URLEncoder
import kotlin.math.roundToInt
class UsersFragment : ScreenFragment("Users"), Logging {
private var _binding: NodelistFragmentBinding? = null
@ -155,6 +153,17 @@ class UsersFragment : ScreenFragment("Users"), Logging {
holder.signalView.text = text
holder.signalView.visibility = View.VISIBLE
}
if (n.num == ourNodeInfo?.num) {
val info = model.myNodeInfo.value
if (info != null) {
val channelUtilizationText = String.format("%.1f", info.channelUtilization)
val airUtilTxText = String.format("%.1f", info.airUtilTx)
val combinedText = "ChUtil $channelUtilizationText% AirUtilTX $airUtilTxText%"
holder.signalView.text = combinedText
holder.signalView.visibility = View.VISIBLE
}
}
}
private var nodes = arrayOf<NodeInfo>()
@ -172,9 +181,9 @@ class UsersFragment : ScreenFragment("Users"), Logging {
) {
val (image, text) = when (battery) {
null -> Pair(R.drawable.ic_battery_full_24, "?")
in 1..100 -> Pair(R.drawable.ic_battery_full_24, "$battery%")
0 -> Pair(R.drawable.ic_power_plug_24, "")
else -> Pair(R.drawable.ic_battery_full_24, "$battery%")
else -> Pair(R.drawable.ic_battery_full_24, "?")
}
holder.batteryPctView.text = text
@ -200,7 +209,7 @@ class UsersFragment : ScreenFragment("Users"), Logging {
binding.nodeListView.adapter = nodesAdapter
binding.nodeListView.layoutManager = LinearLayoutManager(requireContext())
model.nodeDB.nodes.observe(viewLifecycleOwner, Observer { it ->
model.nodeDB.nodes.observe(viewLifecycleOwner, {
nodesAdapter.onNodesChanged(it.values)
})
}

View file

@ -62,7 +62,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toEndOf="@+id/distance_view"
app:layout_constraintTop_toBottomOf="@+id/imageView"
app:layout_constraintTop_toBottomOf="@+id/nodeNameView"
app:layout_constraintVertical_bias="0.0" />
<ImageView