Adds support for known 0 hopsAway (#1295)

pull/1298/head
James Rich 2024-10-09 15:04:05 -05:00 zatwierdzone przez GitHub
rodzic 9cce785556
commit ebe0aeec14
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 30 dodań i 10 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ data class NodeEntity(
var viaMqtt: Boolean = false,
@ColumnInfo(name = "hops_away")
var hopsAway: Int = 0,
var hopsAway: Int = -1,
@ColumnInfo(name = "is_favorite")
var isFavorite: Boolean = false,

Wyświetl plik

@ -1101,8 +1101,10 @@ class MeshService : Service(), Logging {
it.rssi = packet.rxRssi
// Generate our own hopsAway, comparing hopStart to hopLimit.
if (packet.hopStart != 0 && packet.hopLimit <= packet.hopStart) {
it.hopsAway = packet.hopStart - packet.hopLimit
it.hopsAway = if (packet.hopStart == 0 || packet.hopLimit < packet.hopStart) {
-1
} else {
packet.hopStart - packet.hopLimit
}
}
handleReceivedData(packet)
@ -1407,7 +1409,13 @@ class MeshService : Service(), Logging {
it.channel = info.channel
it.viaMqtt = info.viaMqtt
it.hopsAway = info.hopsAway
// hopsAway should be nullable/optional from the proto, but explicitly checking it's existence first
it.hopsAway = if (info.hasHopsAway()) {
info.hopsAway
} else {
-1
}
it.isFavorite = info.isFavorite
}
}

Wyświetl plik

@ -13,6 +13,9 @@ import com.geeksville.mesh.database.entity.NodeEntity
import com.geeksville.mesh.ui.preview.NodeEntityPreviewParameterProvider
import com.geeksville.mesh.ui.theme.AppTheme
const val MAX_VALID_SNR = 100F
const val MAX_VALID_RSSI = 0
@Composable
fun signalInfo(
modifier: Modifier = Modifier,
@ -26,15 +29,24 @@ fun signalInfo(
)
} else {
buildList {
if (node.channel > 0) add("ch:${node.channel}")
if (node.hopsAway == 0) {
if (node.snr < 100F && node.rssi < 0) {
val hopsString = "%s: %s".format(
stringResource(R.string.hops_away),
if (node.hopsAway == -1) {
stringResource(R.string.unknown)
} else {
node.hopsAway.toString()
}
)
if (node.channel > 0) {
add("ch:${node.channel}")
}
if (node.hopsAway <= 0) {
if (node.snr < MAX_VALID_SNR && node.rssi < MAX_VALID_RSSI) {
add("RSSI: %d SNR: %.1f".format(node.rssi, node.snr))
}
} else {
add("%s: %d".format(stringResource(R.string.hops_away), node.hopsAway))
}
}.joinToString(" ")
add(hopsString)
}.joinToString(" | ")
}
return if (text.isNotEmpty()) {
Text(