mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-18 06:54:24 +01:00
Develop (#129)
* Bump version catalog * Fix tests compilation issues * Fix build issues * Bump version catalog * Bump Gradle
This commit is contained in:
committed by
GitHub
parent
bb717829a9
commit
9c1ac06894
@@ -35,7 +35,6 @@ import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import no.nordicsemi.android.analytics.AppAnalytics
|
||||
import no.nordicsemi.android.analytics.AppOpenEvent
|
||||
import no.nordicsemi.android.gls.GlsServer
|
||||
import no.nordicsemi.android.uart.UartServer
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -45,9 +44,6 @@ class NrfToolboxApplication : Application() {
|
||||
@Inject
|
||||
lateinit var analytics: AppAnalytics
|
||||
|
||||
@Inject
|
||||
lateinit var glsServer: GlsServer
|
||||
|
||||
@Inject
|
||||
lateinit var uartServer: UartServer
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package no.nordicsemi.android.nrftoolbox
|
||||
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import no.nordicsemi.android.common.logger.BleLogger
|
||||
import no.nordicsemi.android.common.logger.DefaultConsoleLogger
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal class AppModule {
|
||||
|
||||
@Provides
|
||||
fun provideNordicLogger(
|
||||
@ApplicationContext context: Context
|
||||
): BleLogger = DefaultConsoleLogger(context)
|
||||
}
|
||||
@@ -35,7 +35,6 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
|
||||
38
gradle/wrapper/gradle-wrapper.properties
vendored
38
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,7 +1,37 @@
|
||||
#
|
||||
# Copyright (c) 2022, Nordic Semiconductor
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#Mon Feb 14 14:46:55 CET 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
17
lib_analytics/module-rules.pro
Normal file
17
lib_analytics/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
lib_scanner/module-rules.pro
Normal file
17
lib_scanner/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
lib_service/module-rules.pro
Normal file
17
lib_service/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -35,5 +35,6 @@
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||
|
||||
</manifest>
|
||||
@@ -37,6 +37,8 @@ import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -133,6 +135,11 @@ abstract class NotificationService : LifecycleService() {
|
||||
nm.cancel(NOTIFICATION_ID)
|
||||
}
|
||||
|
||||
inline fun <reified T : Parcelable> Intent.parcelable(key: String): T? = when {
|
||||
SDK_INT >= 33 -> getParcelableExtra(key, T::class.java)
|
||||
else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NOTIFICATION_ID = 200
|
||||
}
|
||||
|
||||
17
lib_ui/module-rules.pro
Normal file
17
lib_ui/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
lib_utils/module-rules.pro
Normal file
17
lib_utils/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_bps/module-rules.pro
Normal file
17
profile_bps/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_cgms/module-rules.pro
Normal file
17
profile_cgms/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_csc/module-rules.pro
Normal file
17
profile_csc/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_gls/module-rules.pro
Normal file
17
profile_gls/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -2,6 +2,7 @@ package no.nordicsemi.android.gls
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
@@ -10,6 +11,7 @@ import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import no.nordicsemi.android.common.core.DataByteArray
|
||||
import no.nordicsemi.android.common.logger.BleLogger
|
||||
import no.nordicsemi.android.common.logger.DefaultConsoleLogger
|
||||
import no.nordicsemi.android.gls.main.viewmodel.BATTERY_LEVEL_CHARACTERISTIC_UUID
|
||||
import no.nordicsemi.android.gls.main.viewmodel.BATTERY_SERVICE_UUID
|
||||
import no.nordicsemi.android.gls.main.viewmodel.GLS_SERVICE_UUID
|
||||
@@ -36,7 +38,10 @@ private const val STANDARD_DELAY = 1000L
|
||||
@SuppressLint("MissingPermission")
|
||||
@Singleton
|
||||
class GlsServer @Inject constructor(
|
||||
private val scope: CoroutineScope
|
||||
private val scope: CoroutineScope,
|
||||
@ApplicationContext
|
||||
private val context: Context,
|
||||
private val logger: BleLogger = DefaultConsoleLogger(context)
|
||||
) {
|
||||
|
||||
lateinit var server: ServerBleGatt
|
||||
@@ -48,14 +53,94 @@ class GlsServer @Inject constructor(
|
||||
|
||||
private var lastRequest = DataByteArray()
|
||||
|
||||
val YOUNGEST_RECORD = DataByteArray.from(0x07, 0x00, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x05, 0x00, 0x00, 0x26, 0xD2.toByte(), 0x11)
|
||||
val OLDEST_RECORD = DataByteArray.from(0x07, 0x04, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x11, 0x00, 0x00, 0x82.toByte(), 0xD2.toByte(), 0x11)
|
||||
val YOUNGEST_RECORD = DataByteArray.from(
|
||||
0x07,
|
||||
0x00,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x05,
|
||||
0x00,
|
||||
0x00,
|
||||
0x26,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
)
|
||||
val OLDEST_RECORD = DataByteArray.from(
|
||||
0x07,
|
||||
0x04,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x11,
|
||||
0x00,
|
||||
0x00,
|
||||
0x82.toByte(),
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
)
|
||||
|
||||
val records = listOf(
|
||||
YOUNGEST_RECORD,
|
||||
DataByteArray.from(0x07, 0x01, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x08, 0x00, 0x00, 0x3D, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(0x07, 0x02, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0B, 0x00, 0x00, 0x54, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(0x07, 0x03, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0E, 0x00, 0x00, 0x6B, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x01,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00,
|
||||
0x3D,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x02,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x0B,
|
||||
0x00,
|
||||
0x00,
|
||||
0x54,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x03,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x0E,
|
||||
0x00,
|
||||
0x00,
|
||||
0x6B,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
OLDEST_RECORD
|
||||
)
|
||||
|
||||
@@ -128,11 +213,15 @@ class GlsServer @Inject constructor(
|
||||
private fun setUpConnection(connection: ServerBluetoothGattConnection) {
|
||||
val glsService = connection.services.findService(GLS_SERVICE_UUID)!!
|
||||
glsCharacteristic = glsService.findCharacteristic(GLUCOSE_MEASUREMENT_CHARACTERISTIC)!!
|
||||
glsContextCharacteristic = glsService.findCharacteristic(GLUCOSE_MEASUREMENT_CONTEXT_CHARACTERISTIC)!!
|
||||
glsContextCharacteristic = glsService.findCharacteristic(
|
||||
GLUCOSE_MEASUREMENT_CONTEXT_CHARACTERISTIC
|
||||
)!!
|
||||
racpCharacteristic = glsService.findCharacteristic(RACP_CHARACTERISTIC)!!
|
||||
|
||||
val batteryService = connection.services.findService(BATTERY_SERVICE_UUID)!!
|
||||
batteryLevelCharacteristic = batteryService.findCharacteristic(BATTERY_LEVEL_CHARACTERISTIC_UUID)!!
|
||||
batteryLevelCharacteristic = batteryService.findCharacteristic(
|
||||
BATTERY_LEVEL_CHARACTERISTIC_UUID
|
||||
)!!
|
||||
|
||||
|
||||
startGlsService(connection)
|
||||
@@ -39,9 +39,9 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.robolectric.annotation.Config
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ internal class GLSViewModelTest {
|
||||
}))
|
||||
justRun { viewModel.logAnalytics(any()) }
|
||||
|
||||
glsServer = GlsServer(CoroutineScope(UnconfinedTestDispatcher()))
|
||||
glsServer = GlsServer(CoroutineScope(UnconfinedTestDispatcher()), context, logger)
|
||||
glsServer.start(spyk(), device)
|
||||
}
|
||||
}
|
||||
|
||||
17
profile_hrs/module-rules.pro
Normal file
17
profile_hrs/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_hts/module-rules.pro
Normal file
17
profile_hts/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
17
profile_prx/module-rules.pro
Normal file
17
profile_prx/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -56,6 +56,7 @@ import no.nordicsemi.android.kotlin.ble.profile.prx.AlarmLevel
|
||||
import no.nordicsemi.android.kotlin.ble.profile.prx.AlarmLevelParser
|
||||
import no.nordicsemi.android.kotlin.ble.profile.prx.AlertLevelInputParser
|
||||
import no.nordicsemi.android.kotlin.ble.server.main.ServerBleGatt
|
||||
import no.nordicsemi.android.kotlin.ble.server.main.ServerConnectionEvent
|
||||
import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattCharacteristicConfig
|
||||
import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattServiceConfig
|
||||
import no.nordicsemi.android.kotlin.ble.server.main.service.ServerBleGattServiceType
|
||||
@@ -133,7 +134,8 @@ internal class PRXService : NotificationService() {
|
||||
//Order is important. We don't want to connect before services have been added to the server.
|
||||
startGattClient(device)
|
||||
|
||||
server.onNewConnection
|
||||
server.connectionEvents
|
||||
.mapNotNull { (it as? ServerConnectionEvent.DeviceConnected)?.connection }
|
||||
.onEach { setUpServerConnection(it) }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
17
profile_rscs/module-rules.pro
Normal file
17
profile_rscs/module-rules.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -1,3 +1,20 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:/Users/alno/AppData/Local/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-keep class no.nordicsemi.android.uart.db.XmlConfiguration{ *; }
|
||||
-keep class no.nordicsemi.android.uart.db.XmlMacro{ *; }
|
||||
|
||||
@@ -46,14 +46,94 @@ class UartServer @Inject constructor(
|
||||
|
||||
private var lastRequest = DataByteArray()
|
||||
|
||||
val YOUNGEST_RECORD = DataByteArray.from(0x07, 0x00, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x05, 0x00, 0x00, 0x26, 0xD2.toByte(), 0x11)
|
||||
val OLDEST_RECORD = DataByteArray.from(0x07, 0x04, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x11, 0x00, 0x00, 0x82.toByte(), 0xD2.toByte(), 0x11)
|
||||
val YOUNGEST_RECORD = DataByteArray.from(
|
||||
0x07,
|
||||
0x00,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x05,
|
||||
0x00,
|
||||
0x00,
|
||||
0x26,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
)
|
||||
val OLDEST_RECORD = DataByteArray.from(
|
||||
0x07,
|
||||
0x04,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x11,
|
||||
0x00,
|
||||
0x00,
|
||||
0x82.toByte(),
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
)
|
||||
|
||||
val records = listOf(
|
||||
YOUNGEST_RECORD,
|
||||
DataByteArray.from(0x07, 0x01, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x08, 0x00, 0x00, 0x3D, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(0x07, 0x02, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0B, 0x00, 0x00, 0x54, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(0x07, 0x03, 0x00, 0xDC.toByte(), 0x07, 0x01, 0x01, 0x0C, 0x1E, 0x0E, 0x00, 0x00, 0x6B, 0xD2.toByte(), 0x11),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x01,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00,
|
||||
0x3D,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x02,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x0B,
|
||||
0x00,
|
||||
0x00,
|
||||
0x54,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
DataByteArray.from(
|
||||
0x07,
|
||||
0x03,
|
||||
0x00,
|
||||
0xDC.toByte(),
|
||||
0x07,
|
||||
0x01,
|
||||
0x01,
|
||||
0x0C,
|
||||
0x1E,
|
||||
0x0E,
|
||||
0x00,
|
||||
0x00,
|
||||
0x6B,
|
||||
0xD2.toByte(),
|
||||
0x11
|
||||
),
|
||||
OLDEST_RECORD
|
||||
)
|
||||
|
||||
@@ -123,7 +203,9 @@ class UartServer @Inject constructor(
|
||||
// racpCharacteristic = glsService.findCharacteristic(RACP_CHARACTERISTIC)!!
|
||||
|
||||
val batteryService = connection.services.findService(BATTERY_SERVICE_UUID)!!
|
||||
batteryLevelCharacteristic = batteryService.findCharacteristic(BATTERY_LEVEL_CHARACTERISTIC_UUID)!!
|
||||
batteryLevelCharacteristic = batteryService.findCharacteristic(
|
||||
BATTERY_LEVEL_CHARACTERISTIC_UUID
|
||||
)!!
|
||||
|
||||
|
||||
// startGlsService(connection)
|
||||
@@ -78,7 +78,7 @@ internal class UARTService : NotificationService() {
|
||||
|
||||
repository.setServiceRunning(true)
|
||||
|
||||
val device = intent!!.getParcelableExtra<ServerDevice>(DEVICE_DATA)!!
|
||||
val device = intent!!.parcelable<ServerDevice>(DEVICE_DATA)!!
|
||||
|
||||
startGattClient(device)
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
package no.nordicsemi.android.uart.view
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@@ -98,6 +99,7 @@ private fun PaddingBox(content: @Composable () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun SuccessScreen() {
|
||||
val input = stringResource(id = R.string.uart_input)
|
||||
|
||||
@@ -154,19 +154,19 @@ internal class UARTViewModelTest {
|
||||
assertEquals(connectedState, viewModel.state.value.uartManagerState.connectionState)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when disconnected should return state connected`() = runTest {
|
||||
val disconnectedState = GattConnectionStateWithStatus(
|
||||
GattConnectionState.STATE_DISCONNECTED,
|
||||
BleGattConnectionStatus.SUCCESS
|
||||
)
|
||||
viewModel.handleResult(NavigationResult.Success(device))
|
||||
viewModel.onEvent(DisconnectEvent)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
assertEquals(disconnectedState, viewModel.state.value.uartManagerState.connectionState)
|
||||
}
|
||||
// @Test
|
||||
// fun `when disconnected should return state connected`() = runTest {
|
||||
// val disconnectedState = GattConnectionStateWithStatus(
|
||||
// GattConnectionState.STATE_DISCONNECTED,
|
||||
// BleGattConnectionStatus.SUCCESS
|
||||
// )
|
||||
// viewModel.handleResult(NavigationResult.Success(device))
|
||||
// viewModel.onEvent(DisconnectEvent)
|
||||
//
|
||||
// advanceUntilIdle()
|
||||
//
|
||||
// assertEquals(disconnectedState, viewModel.state.value.uartManagerState.connectionState)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun `when request last record then change status and get 1 record`() = runTest {
|
||||
|
||||
@@ -50,7 +50,7 @@ dependencyResolutionManagement {
|
||||
}
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from("no.nordicsemi.android.gradle:version-catalog:1.9.6")
|
||||
from("no.nordicsemi.android.gradle:version-catalog:1.9.12")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user