mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-24 01:44:23 +01:00
Fix UI when device disconnects after bonding failure
This commit is contained in:
@@ -166,6 +166,7 @@ internal class GLSViewModel @Inject constructor(
|
||||
.filterNotNull()
|
||||
.onEach { _state.value = _state.value.copyWithNewConnectionState(it) }
|
||||
.onEach { logAnalytics(it) }
|
||||
.onEach { unlockUiIfDisconnected(it, device) }
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
if (!client.isConnected) {
|
||||
@@ -185,6 +186,12 @@ internal class GLSViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun unlockUiIfDisconnected(connectionState: GattConnectionStateWithStatus, device: ServerDevice) {
|
||||
if (connectionState.state == GattConnectionState.STATE_CONNECTED) {
|
||||
_state.value = _state.value.copy(deviceName = device.name)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun configureGatt(services: BleGattServices, device: ServerDevice) {
|
||||
val glsService = services.findService(GLS_SERVICE_UUID)!!
|
||||
glucoseMeasurementCharacteristic = glsService.findCharacteristic(GM_CHARACTERISTIC)!!
|
||||
|
||||
Reference in New Issue
Block a user