diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index cdaf088247..d56796b68c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -99,7 +99,8 @@ class OmnipodDashPumpPlugin @Inject constructor( statusChecker = Runnable { refreshStatusOnUnacknowledgedCommands() updatePodWarnings() - createFakeTBRWhenNoActivePod() + // createFakeTBRWhenNoActivePod() + // TODO: this is called from the main thread handler.postDelayed(statusChecker, STATUS_CHECK_INTERVAL_MS) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt index 7565be0acd..1c873bd8ab 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt @@ -186,7 +186,6 @@ class OmnipodDashBleManagerImpl @Inject constructor( throw BusyException() } try { - if (podState.ltk != null) { emitter.onNext(PodEvent.AlreadyPaired) emitter.onComplete() @@ -222,7 +221,6 @@ class OmnipodDashBleManagerImpl @Inject constructor( if (BuildConfig.DEBUG) { aapsLogger.info(LTag.PUMPCOMM, "Got LTK: ${pairResult.ltk.toHex()}") } - emitter.onNext(PodEvent.EstablishingSession) establishSession(pairResult.msgSeq) emitter.onNext(PodEvent.Connected) @@ -241,8 +239,6 @@ class OmnipodDashBleManagerImpl @Inject constructor( } companion object { - const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 2 const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else. - private const val CONNECT_TIMEOUT_MULTIPLIER = 4 } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt index 1d1e24ba42..3bc367d47c 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt @@ -32,7 +32,7 @@ class ServiceDiscoverer( bleCallbacks.waitForServiceDiscovery(it) } connectionWaitCond.stopConnection?.let { - while (!bleCallbacks.waitForConnection(STOP_CONNECTING_CHECK_INTERVAL_MS)) { + while (!bleCallbacks.waitForServiceDiscovery(STOP_CONNECTING_CHECK_INTERVAL_MS)) { if (it.count == 0L) { throw ConnectException("stopConnecting called") } 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 2a668065f0..7f8b907ec8 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 @@ -66,12 +66,13 @@ class BleCommCallbacks( serviceDiscoveryComplete = CountDownLatch(1) } - fun waitForServiceDiscovery(timeoutMs: Long) { + fun waitForServiceDiscovery(timeoutMs: Long): Boolean { try { serviceDiscoveryComplete.await(timeoutMs, TimeUnit.MILLISECONDS) } catch (e: InterruptedException) { aapsLogger.warn(LTag.PUMPBTCOMM, "Interrupted while waiting for ServiceDiscovery") } + return serviceDiscoveryComplete.count == 0L } fun confirmWrite(expectedPayload: ByteArray, expectedUUID: String, timeoutMs: Long): WriteConfirmation {