try different conn timeout. fix case when connection is established and session is null
This commit is contained in:
parent
898c1c7906
commit
16a2c8ea55
3 changed files with 9 additions and 24 deletions
|
@ -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(
|
override fun setTempBasalPercent(
|
||||||
percent: Int,
|
percent: Int,
|
||||||
durationInMinutes: Int,
|
durationInMinutes: Int,
|
||||||
|
@ -598,10 +584,15 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult {
|
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(
|
return executeProgrammingCommand(
|
||||||
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
|
historyEntry = history.createRecord(OmnipodCommandType.CANCEL_TEMPORARY_BASAL),
|
||||||
command = omnipodManager.stopTempBasal().ignoreElements(),
|
command = omnipodManager.stopTempBasal().ignoreElements(),
|
||||||
pre = observeActiveTempBasal(),
|
|
||||||
).toPumpEnactResult()
|
).toPumpEnactResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,14 +102,8 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
||||||
val conn = connection
|
val conn = connection
|
||||||
?: Connection(podDevice, aapsLogger, context, podState)
|
?: Connection(podDevice, aapsLogger, context, podState)
|
||||||
connection = conn
|
connection = conn
|
||||||
if (conn.connectionState() is Connected) {
|
if (conn.connectionState() is Connected && conn.session != null) {
|
||||||
if (conn.session == null) {
|
emitter.onNext(PodEvent.AlreadyConnected(podAddress))
|
||||||
emitter.onNext(PodEvent.EstablishingSession)
|
|
||||||
establishSession(1.toByte())
|
|
||||||
emitter.onNext(PodEvent.Connected)
|
|
||||||
} else {
|
|
||||||
emitter.onNext(PodEvent.AlreadyConnected(podAddress))
|
|
||||||
}
|
|
||||||
emitter.onComplete()
|
emitter.onComplete()
|
||||||
return@create
|
return@create
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,6 @@ class Connection(
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val BASE_CONNECT_TIMEOUT_MS = 6000
|
private const val BASE_CONNECT_TIMEOUT_MS = 10000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue