mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-20 07:54:20 +01:00
Add unlockUiIfDisconnected to BPS
This commit is contained in:
@@ -128,6 +128,7 @@ internal class BPSViewModel @Inject constructor(
|
|||||||
.onEach { onDataUpdate(it) }
|
.onEach { onDataUpdate(it) }
|
||||||
.onEach { stopIfDisconnected(it.state) }
|
.onEach { stopIfDisconnected(it.state) }
|
||||||
.onEach { logAnalytics(it.state) }
|
.onEach { logAnalytics(it.state) }
|
||||||
|
.onEach { unlockUiIfDisconnected(it, device) }
|
||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
|
|
||||||
if (!client.isConnected) {
|
if (!client.isConnected) {
|
||||||
@@ -141,6 +142,12 @@ internal class BPSViewModel @Inject constructor(
|
|||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun unlockUiIfDisconnected(connectionState: GattConnectionStateWithStatus, device: ServerDevice) {
|
||||||
|
if (connectionState.state == GattConnectionState.STATE_DISCONNECTED) {
|
||||||
|
_state.value = _state.value.copy(deviceName = device.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun configureGatt(services: BleGattServices) {
|
private suspend fun configureGatt(services: BleGattServices) {
|
||||||
val bpsService = services.findService(BPS_SERVICE_UUID)!!
|
val bpsService = services.findService(BPS_SERVICE_UUID)!!
|
||||||
val bpmCharacteristic = bpsService.findCharacteristic(BPM_CHARACTERISTIC_UUID)!!
|
val bpmCharacteristic = bpsService.findCharacteristic(BPM_CHARACTERISTIC_UUID)!!
|
||||||
|
|||||||
Reference in New Issue
Block a user