From b78283b486dd41c987aafdf7bdf4d7de9ae0401b Mon Sep 17 00:00:00 2001 From: himalia416 Date: Thu, 28 Aug 2025 14:50:04 +0200 Subject: [PATCH] Handle disconnection job even if disconnect fails --- .../no/nordicsemi/android/service/profile/ProfileService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_service/src/main/java/no/nordicsemi/android/service/profile/ProfileService.kt b/lib_service/src/main/java/no/nordicsemi/android/service/profile/ProfileService.kt index c4b7bd23..7bdf7ee0 100644 --- a/lib_service/src/main/java/no/nordicsemi/android/service/profile/ProfileService.kt +++ b/lib_service/src/main/java/no/nordicsemi/android/service/profile/ProfileService.kt @@ -207,6 +207,7 @@ internal class ProfileService : NotificationService() { peripheral.disconnect() } catch (e: Exception) { Timber.e(e, "Failed to disconnect from $address") + handleDisconnection(address) } } } @@ -261,7 +262,7 @@ internal class ProfileService : NotificationService() { override suspend fun getMaxWriteValue(address: String, writeType: WriteType): Int? { val peripheral = getPeripheral(address) ?: return null - if (peripheral.state.value != ConnectionState.Connected) return null + if (!peripheral.isConnected) return null return try { peripheral.requestHighestValueLength() // Request highest possible MTU