From 17d4f3e8ce25283285f4a22760028e66c0953bca Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 31 May 2022 09:52:10 +0200 Subject: [PATCH] try to fix disconnects --- .../pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt | 2 +- .../plugins/pump/omnipod/dash/driver/comm/session/Connection.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt index 83ee2346b4..3724341c89 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt @@ -40,7 +40,7 @@ class BleCommCallbacks( if (newState == BluetoothProfile.STATE_CONNECTED && status == BluetoothGatt.GATT_SUCCESS) { connected.countDown() } - if (newState == BluetoothProfile.STATE_DISCONNECTED && status != BluetoothGatt.GATT_SUCCESS) { + if (newState == BluetoothProfile.STATE_DISCONNECTED) { // If status == SUCCESS, it means that we initiated the disconnect. disconnectHandler.onConnectionLost(status) } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt index b403cb7af2..3b934510ed 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt @@ -61,6 +61,7 @@ class Connection( @Volatile var msgIO: MessageIO? = null + @Synchronized fun connect(connectionWaitCond: ConnectionWaitCondition) { aapsLogger.debug("Connecting connectionWaitCond=$connectionWaitCond") podState.connectionAttempts++ @@ -117,6 +118,7 @@ class Connection( dataBleIO.readyToRead() } + @Synchronized fun disconnect(closeGatt: Boolean) { aapsLogger.debug(LTag.PUMPBTCOMM, "Disconnecting closeGatt=$closeGatt") podState.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED