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) { override fun connect(reason: String) {
aapsLogger.info(LTag.PUMP, "connect reason=$reason") aapsLogger.info(LTag.PUMP, "connect reason=$reason")
podStateManager.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING podStateManager.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
synchronized(this) {
stopConnecting?.let {
aapsLogger.warn(LTag.PUMP, "Already connecting: $stopConnecting")
return
}
val stop = CountDownLatch(1)
stopConnecting = stop
}
thread( thread(
start = true, start = true,
name = "ConnectionThread", name = "ConnectionThread",
) { ) {
try { try {
val stop = CountDownLatch(1) stopConnecting?.let{
stopConnecting = stop val error = omnipodManager.connect(it).ignoreElements().blockingGet()
val error = omnipodManager.connect(stop).ignoreElements().blockingGet() aapsLogger.info(LTag.PUMPCOMM, "connect error=${error}")
aapsLogger.info(LTag.PUMPCOMM, "connect error=$error") }
} finally { } finally {
stopConnecting = null synchronized(this) {
stopConnecting = null
}
} }
} }
} }