diff --git a/profile_gls/build.gradle.kts b/profile_gls/build.gradle.kts index d9f2fae5..af42e035 100644 --- a/profile_gls/build.gradle.kts +++ b/profile_gls/build.gradle.kts @@ -48,6 +48,7 @@ dependencies { implementation(libs.nordic.blek.client) implementation(libs.nordic.blek.profile) implementation(libs.nordic.blek.server) + implementation(libs.nordic.blek.advertiser) implementation(libs.chart) diff --git a/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt b/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt index f648779f..0b5610f6 100644 --- a/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt +++ b/profile_gls/src/debug/java/no/nordicsemi/android/gls/GlsServer.kt @@ -2,12 +2,10 @@ package no.nordicsemi.android.gls import android.annotation.SuppressLint import android.content.Context -import android.util.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch @@ -17,9 +15,11 @@ import no.nordicsemi.android.gls.main.viewmodel.GLS_SERVICE_UUID import no.nordicsemi.android.gls.main.viewmodel.GLUCOSE_MEASUREMENT_CHARACTERISTIC import no.nordicsemi.android.gls.main.viewmodel.GLUCOSE_MEASUREMENT_CONTEXT_CHARACTERISTIC import no.nordicsemi.android.gls.main.viewmodel.RACP_CHARACTERISTIC +import no.nordicsemi.android.kotlin.ble.advertiser.BleAdvertiser +import no.nordicsemi.android.kotlin.ble.core.advertiser.BleAdvertiseConfig +import no.nordicsemi.android.kotlin.ble.core.MockServerDevice import no.nordicsemi.android.kotlin.ble.core.data.BleGattPermission import no.nordicsemi.android.kotlin.ble.core.data.BleGattProperty -import no.nordicsemi.android.kotlin.ble.core.ext.toDisplayString import no.nordicsemi.android.kotlin.ble.profile.gls.RecordAccessControlPointInputParser import no.nordicsemi.android.kotlin.ble.server.main.BleGattServer import no.nordicsemi.android.kotlin.ble.server.main.service.BleGattServerServiceType @@ -85,12 +85,20 @@ class GlsServer @Inject constructor( listOf(batteryLevelCharacteristic) ) + val device = MockServerDevice( + name = "GLS Server", + address = "55:44:33:22:11" + ) + val server = BleGattServer.create( context = context, config = arrayOf(serviceConfig, batteryService), - mock = true + mock = device ) + val advertiser = BleAdvertiser.create(context) + advertiser.advertise(config = BleAdvertiseConfig(), mock = device).launchIn(scope) + launch { server.connections .mapNotNull { it.values.firstOrNull() }