Use wait for bonding properly

This commit is contained in:
Sylwester Zielinski
2023-04-26 16:43:56 +02:00
parent 1155359dd5
commit 79cb9d8a1e
2 changed files with 4 additions and 2 deletions

View File

@@ -170,13 +170,13 @@ internal class GLSViewModel @Inject constructor(
.onEach { unlockUiIfDisconnected(it, device) }
.launchIn(viewModelScope)
client.waitForBonding()
if (!client.isConnected) {
_state.value = _state.value.copy(deviceName = device.name)
return@launch
}
client.waitForBonding()
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it, device) }

View File

@@ -107,6 +107,8 @@ internal class HRSService : NotificationService() {
.onEach { unlockUiIfDisconnected(it, device) }
.launchIn(lifecycleScope)
client.waitForBonding()
if (!client.isConnected) {
hasBeenInitialized = true
repository.onInitComplete(device)