This commit is contained in:
Andrei Vereha 2021-07-23 19:30:25 +02:00
parent eb33e89ea7
commit ba5529e868

View file

@ -216,17 +216,29 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun connect(reason: String) {
aapsLogger.info(LTag.PUMP, "connect reason=$reason")
podStateManager.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
synchronized(this) {
stopConnecting?.let {
aapsLogger.warn(LTag.PUMP, "Already connecting: $stopConnecting")
return
}
val stop = CountDownLatch(1)
stopConnecting = stop
}
thread(
start = true,
name = "ConnectionThread",
) {
try {
val stop = CountDownLatch(1)
stopConnecting = stop
val error = omnipodManager.connect(stop).ignoreElements().blockingGet()
aapsLogger.info(LTag.PUMPCOMM, "connect error=$error")
stopConnecting?.let{
val error = omnipodManager.connect(it).ignoreElements().blockingGet()
aapsLogger.info(LTag.PUMPCOMM, "connect error=${error}")
}
} finally {
stopConnecting = null
synchronized(this) {
stopConnecting = null
}
}
}
}