try different conn timeout. fix case when connection is established and session is null

This commit is contained in:
Andrei Vereha 2021-06-12 12:16:45 +02:00
parent 898c1c7906
commit 16a2c8ea55
3 changed files with 9 additions and 24 deletions

View file

@ -565,20 +565,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
}
private fun observeActiveTempBasal(): Completable {
return Completable.defer {
if (podStateManager.tempBasalActive || pumpSync.expectedPumpState().temporaryBasal != null)
Completable.complete()
else
Completable.error(
java.lang.IllegalStateException(
"There is no active basal to cancel"
)
)
}
}
override fun setTempBasalPercent(
percent: Int,
durationInMinutes: Int,
@ -598,10 +584,15 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
if (!podStateManager.tempBasalActive &&
pumpSync.expectedPumpState().temporaryBasal == null) {
// nothing to cancel
return PumpEnactResult(injector).success(true).enacted(false)
}
return executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
command = omnipodManager.stopTempBasal().ignoreElements(),
pre = observeActiveTempBasal(),
).toPumpEnactResult()
}

View file

@ -102,14 +102,8 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val conn = connection
?: Connection(podDevice, aapsLogger, context, podState)
connection = conn
if (conn.connectionState() is Connected) {
if (conn.session == null) {
emitter.onNext(PodEvent.EstablishingSession)
establishSession(1.toByte())
emitter.onNext(PodEvent.Connected)
} else {
if (conn.connectionState() is Connected && conn.session != null) {
emitter.onNext(PodEvent.AlreadyConnected(podAddress))
}
emitter.onComplete()
return@create
}

View file

@ -181,6 +181,6 @@ class Connection(
}
companion object {
private const val BASE_CONNECT_TIMEOUT_MS = 6000
private const val BASE_CONNECT_TIMEOUT_MS = 10000
}
}