kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
spotless
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>pull/3235/head
rodzic
2bdd08891d
commit
9adfe1bbcc
|
@ -142,6 +142,7 @@ constructor(
|
|||
// RSSI flow & polling job (null when unavailable / disconnected)
|
||||
private val _rssiFlow = MutableStateFlow<Int?>(null)
|
||||
val rssiFlow: StateFlow<Int?> = _rssiFlow
|
||||
|
||||
@Volatile private var rssiPollingJob: Job? = null
|
||||
|
||||
// Start polling RSSI every 5 seconds (immediate first read)
|
||||
|
@ -150,19 +151,20 @@ constructor(
|
|||
val s = safe ?: return
|
||||
// Immediate read for faster UI update
|
||||
s.asyncReadRemoteRssi { first -> first.getOrNull()?.let { _rssiFlow.value = it } }
|
||||
rssiPollingJob = service.serviceScope.handledLaunch {
|
||||
while (true) {
|
||||
try {
|
||||
delay(5000)
|
||||
if (safe == null) break
|
||||
safe?.asyncReadRemoteRssi { res -> res.getOrNull()?.let { _rssiFlow.value = it } }
|
||||
} catch (ex: CancellationException) {
|
||||
break
|
||||
} catch (ex: Exception) {
|
||||
debug("RSSI polling error: ${ex.message}")
|
||||
rssiPollingJob =
|
||||
service.serviceScope.handledLaunch {
|
||||
while (true) {
|
||||
try {
|
||||
delay(5000)
|
||||
if (safe == null) break
|
||||
safe?.asyncReadRemoteRssi { res -> res.getOrNull()?.let { _rssiFlow.value = it } }
|
||||
} catch (ex: CancellationException) {
|
||||
break
|
||||
} catch (ex: Exception) {
|
||||
debug("RSSI polling error: ${ex.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stop polling and clear current value
|
||||
|
|
|
@ -46,7 +46,7 @@ class ServiceRepository @Inject constructor() : Logging {
|
|||
val connectionState: StateFlow<ConnectionState>
|
||||
get() = _connectionState
|
||||
|
||||
fun setConnectionState(connectionState: ConnectionState){
|
||||
fun setConnectionState(connectionState: ConnectionState) {
|
||||
_connectionState.value = connectionState
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ import androidx.compose.foundation.selection.selectableGroup
|
|||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Language
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
|
|
|
@ -20,7 +20,6 @@ package com.geeksville.mesh.ui.connections.components
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
@ -28,7 +27,6 @@ import androidx.compose.material.icons.Icons
|
|||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
|
@ -101,8 +99,7 @@ fun CurrentlyConnectedInfo(
|
|||
if (bluetoothRssi != null) {
|
||||
HorizontalDivider()
|
||||
Text(
|
||||
text =
|
||||
stringResource(R.string.bluetooth_signal_strength_fmt, bluetoothRssi),
|
||||
text = stringResource(R.string.bluetooth_signal_strength_fmt, bluetoothRssi),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue