mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-02-06 07:14:34 +01:00
Update Gradle
This commit is contained in:
@@ -45,6 +45,6 @@ plugins {
|
||||
alias(libs.plugins.nordic.library.compose) apply false
|
||||
alias(libs.plugins.nordic.hilt) apply false
|
||||
alias(libs.plugins.nordic.feature) apply false
|
||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||
id("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||
alias(libs.plugins.google.services) apply false
|
||||
alias(libs.plugins.firebase.crashlytics) apply false
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import androidx.lifecycle.lifecycleScope
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -76,9 +75,11 @@ internal class CSCService : NotificationService() {
|
||||
private fun startGattClient(blinkyDevice: ServerDevice) = lifecycleScope.launch {
|
||||
val client = blinkyDevice.connect(this@CSCService)
|
||||
|
||||
client.connection
|
||||
.onEach { repository.onConnectionStateChanged(it.connectionState) }
|
||||
.map { it.services }
|
||||
client.connectionState
|
||||
.onEach { repository.onConnectionStateChanged(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
client.services
|
||||
.filterNotNull()
|
||||
.onEach { configureGatt(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
@@ -87,23 +88,19 @@ internal class CSCService : NotificationService() {
|
||||
private suspend fun configureGatt(services: BleGattServices) {
|
||||
val cscService = services.findService(CSC_SERVICE_UUID)!!
|
||||
val cscMeasurementCharacteristic = cscService.findCharacteristic(CSC_MEASUREMENT_CHARACTERISTIC_UUID)!!
|
||||
|
||||
cscMeasurementCharacteristic.enableNotifications()
|
||||
|
||||
val cscDataParser = CSCDataParser()
|
||||
cscMeasurementCharacteristic.notification
|
||||
.mapNotNull { cscDataParser.parse(it, repository.wheelSize.value) }
|
||||
.onEach { repository.onCSCDataChanged(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
val batteryService = services.findService(BATTERY_SERVICE_UUID)!!
|
||||
val batteryLevelCharacteristic = batteryService.findCharacteristic(BATTERY_LEVEL_CHARACTERISTIC_UUID)!!
|
||||
|
||||
// batteryLevelCharacteristic.enableNotifications()
|
||||
|
||||
batteryLevelCharacteristic.notification
|
||||
.mapNotNull { BatteryLevelParser.parse(it) }
|
||||
.onEach { repository.onBatteryLevelChanged(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
TODO("Second notification not working")
|
||||
val cscDataParser = CSCDataParser()
|
||||
cscMeasurementCharacteristic.notification
|
||||
.mapNotNull { cscDataParser.parse(it, repository.wheelSize.value) }
|
||||
.onEach { repository.onCSCDataChanged(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ include(":lib_utils")
|
||||
//if (file("../Android-Common-Libraries").exists()) {
|
||||
// includeBuild("../Android-Common-Libraries")
|
||||
//}
|
||||
//
|
||||
//if (file('../Android-BLE-Library').exists()) {
|
||||
// includeBuild('../Android-BLE-Library')
|
||||
//}
|
||||
|
||||
if (file("../Kotlin-BLE-Library").exists()) {
|
||||
includeBuild("../Kotlin-BLE-Library")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user