File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
app/src/main/java/com/geeksville/mesh/ui/connections/components Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,9 @@ import androidx.compose.ui.text.style.TextOverflow
4141import androidx.compose.ui.tooling.preview.PreviewLightDark
4242import androidx.compose.ui.unit.dp
4343import com.geeksville.mesh.model.DeviceListEntry
44+ import kotlinx.coroutines.TimeoutCancellationException
4445import kotlinx.coroutines.delay
46+ import kotlinx.coroutines.withTimeout
4547import org.jetbrains.compose.resources.stringResource
4648import org.meshtastic.core.database.model.Node
4749import org.meshtastic.core.strings.Res
@@ -72,10 +74,16 @@ fun CurrentlyConnectedInfo(
7274 if (bleDevice != null ) {
7375 while (bleDevice.peripheral.isConnected) {
7476 try {
75- rssi = bleDevice.peripheral.readRssi()
77+ rssi = withTimeout(5 .seconds) {
78+ bleDevice.peripheral.readRssi()
79+ }
7680 delay(10 .seconds)
81+ } catch (e: TimeoutCancellationException ) {
82+ Timber .w(" RSSI read timed out after 5 seconds" )
83+ break
7784 } catch (e: Exception ) {
7885 Timber .e(e, " Failed to read RSSI" )
86+ break
7987 }
8088 }
8189 }
You can’t perform that action at this time.
0 commit comments