Skip to content

Commit

Permalink
refactor: update signalMetrics filter for 0 hop packets
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Oct 23, 2024
1 parent bb345e7 commit fa24dd4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class MetricsViewModel @Inject constructor(
) : ViewModel() {
private val destNum = MutableStateFlow(0)

private fun MeshPacket.hasValidSignal(): Boolean =
rxTime > 0 && (rxSnr != 0f && rxRssi != 0) && (hopStart > 0 && hopStart - hopLimit == 0)

@OptIn(ExperimentalCoroutinesApi::class)
val state = destNum.flatMapLatest { destNum ->
combine(
Expand All @@ -49,7 +52,7 @@ class MetricsViewModel @Inject constructor(
environmentMetrics = telemetry.filter {
it.hasEnvironmentMetrics() && it.environmentMetrics.relativeHumidity >= 0f
},
signalMetrics = meshPackets.filter { it.rxTime > 0 },
signalMetrics = meshPackets.filter { it.hasValidSignal() },
environmentDisplayFahrenheit = config.telemetry.environmentDisplayFahrenheit,
)
}
Expand Down

0 comments on commit fa24dd4

Please sign in to comment.