Handle disconnection job even if disconnect fails

This commit is contained in:
himalia416
2025-08-28 14:50:04 +02:00
committed by Himali Aryal
parent c4056420f6
commit b78283b486

View File

@@ -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