mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2025-12-24 00:07:48 -05:00
refactor: Improve RSSI reading robustness in connection info (#3798)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
@@ -55,8 +55,10 @@ import org.meshtastic.core.ui.theme.StatusColors.StatusRed
|
||||
import org.meshtastic.proto.MeshProtos
|
||||
import org.meshtastic.proto.PaxcountProtos
|
||||
import org.meshtastic.proto.TelemetryProtos
|
||||
import timber.log.Timber
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@Composable
|
||||
fun CurrentlyConnectedInfo(
|
||||
node: Node,
|
||||
@@ -69,8 +71,12 @@ fun CurrentlyConnectedInfo(
|
||||
LaunchedEffect(bleDevice) {
|
||||
if (bleDevice != null) {
|
||||
while (bleDevice.peripheral.isConnected) {
|
||||
rssi = bleDevice.peripheral.readRssi()
|
||||
delay(10.seconds)
|
||||
try {
|
||||
rssi = bleDevice.peripheral.readRssi()
|
||||
delay(10.seconds)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Failed to read RSSI")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user