Add catch to discoverServices

This commit is contained in:
Sylwester Zielinski
2023-05-03 15:31:17 +02:00
parent d6f6abfbb4
commit 1c45bf09d1
8 changed files with 15 additions and 0 deletions

View File

@@ -139,6 +139,7 @@ internal class BPSViewModel @Inject constructor(
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(viewModelScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -155,6 +156,7 @@ internal class CGMService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -111,6 +112,7 @@ internal class CSCService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -115,6 +116,7 @@ internal class HRSService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -113,6 +114,7 @@ internal class HTSService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -184,6 +185,7 @@ internal class PRXService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
repository.remoteAlarmLevel

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -111,6 +112,7 @@ internal class RSCSService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}

View File

@@ -35,6 +35,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapNotNull
@@ -117,6 +118,7 @@ internal class UARTService : NotificationService() {
client.discoverServices()
.filterNotNull()
.onEach { configureGatt(it, logger) }
.catch { it.printStackTrace() }
.launchIn(lifecycleScope)
}