From 9ca82441bb1cf13202d635b6ca9f4ddcfdd36a17 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Mon, 21 Jun 2021 19:29:22 +0200 Subject: [PATCH] try different connection timeouts --- .../omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt | 4 ++-- .../driver/comm/session/ConnectionStateChangeHandler.kt | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/ConnectionStateChangeHandler.kt 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 a01a3b985b..f675065776 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 @@ -125,7 +125,7 @@ class OmnipodDashBleManagerImpl @Inject constructor( for (i in 1..MAX_NUMBER_OF_CONNECTION_ATTEMPTS) { try { // wait i * CONNECTION_TIMEOUT - conn.connect(i) + conn.connect(4) break } catch (e: Exception) { aapsLogger.warn(LTag.PUMPBTCOMM, "connect error=$e") @@ -240,7 +240,7 @@ class OmnipodDashBleManagerImpl @Inject constructor( } companion object { - const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 3 + const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 2 const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else. } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/ConnectionStateChangeHandler.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/ConnectionStateChangeHandler.kt new file mode 100644 index 0000000000..8396850d70 --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/ConnectionStateChangeHandler.kt @@ -0,0 +1,6 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session + +interface ConnectionStateChangeHandler { + + fun onConnectionStateChange(status: Int, newState: Int) +}