Merge branch 'dash' into avereha/merge
This commit is contained in:
commit
080e990e13
4 changed files with 15 additions and 9 deletions
|
@ -1013,7 +1013,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
return Completable.concat(
|
return Completable.concat(
|
||||||
listOf(
|
listOf(
|
||||||
pre,
|
pre,
|
||||||
podStateManager.observeNoActiveCommand(checkNoActiveCommand).ignoreElements(),
|
if (checkNoActiveCommand)
|
||||||
|
podStateManager.observeNoActiveCommand()
|
||||||
|
else
|
||||||
|
Completable.complete(),
|
||||||
historyEntry
|
historyEntry
|
||||||
.flatMap { activeCommandEntry(it) }
|
.flatMap { activeCommandEntry(it) }
|
||||||
.ignoreElement(),
|
.ignoreElement(),
|
||||||
|
|
|
@ -125,7 +125,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
||||||
for (i in 1..MAX_NUMBER_OF_CONNECTION_ATTEMPTS) {
|
for (i in 1..MAX_NUMBER_OF_CONNECTION_ATTEMPTS) {
|
||||||
try {
|
try {
|
||||||
// wait i * CONNECTION_TIMEOUT
|
// wait i * CONNECTION_TIMEOUT
|
||||||
conn.connect(4)
|
conn.connect(CONNECT_TIMEOUT_MULTIPLIER)
|
||||||
break
|
break
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "connect error=$e")
|
aapsLogger.warn(LTag.PUMPBTCOMM, "connect error=$e")
|
||||||
|
@ -242,5 +242,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
||||||
companion object {
|
companion object {
|
||||||
const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 2
|
const val MAX_NUMBER_OF_CONNECTION_ATTEMPTS = 2
|
||||||
const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else.
|
const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else.
|
||||||
|
private const val CONNECT_TIMEOUT_MULTIPLIER = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
|
||||||
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
|
@ -91,7 +92,7 @@ interface OmnipodDashPodStateManager {
|
||||||
requestedBolus: Double? = null
|
requestedBolus: Double? = null
|
||||||
): Single<ActiveCommand>
|
): Single<ActiveCommand>
|
||||||
fun updateActiveCommand(): Maybe<CommandConfirmed>
|
fun updateActiveCommand(): Maybe<CommandConfirmed>
|
||||||
fun observeNoActiveCommand(check: Boolean): Observable<PodEvent>
|
fun observeNoActiveCommand(): Completable
|
||||||
fun getCommandConfirmationFromState(): CommandConfirmationFromState
|
fun getCommandConfirmationFromState(): CommandConfirmationFromState
|
||||||
|
|
||||||
fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType)
|
fun createLastBolus(requestedUnits: Double, historyId: String, bolusType: DetailedBolusInfo.BolusType)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.SetUniqueIdResponse
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import io.reactivex.Completable
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
|
@ -307,13 +308,13 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun observeNoActiveCommand(check: Boolean): Observable<PodEvent> {
|
override fun observeNoActiveCommand(): Completable {
|
||||||
return Observable.defer {
|
return Completable.defer {
|
||||||
if (activeCommand == null || !check) {
|
if (activeCommand == null) {
|
||||||
Observable.empty()
|
Completable.complete()
|
||||||
} else {
|
} else {
|
||||||
logger.warn(LTag.PUMP, "Active command already existing: $activeCommand")
|
logger.warn(LTag.PUMP, "Active command already existing: $activeCommand")
|
||||||
Observable.error(
|
Completable.error(
|
||||||
java.lang.IllegalStateException(
|
java.lang.IllegalStateException(
|
||||||
"Trying to send a command " +
|
"Trying to send a command " +
|
||||||
"and the last command was not confirmed"
|
"and the last command was not confirmed"
|
||||||
|
@ -468,7 +469,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
podState.lastStatusResponseReceived = SystemClock.elapsedRealtime()
|
podState.lastStatusResponseReceived = SystemClock.elapsedRealtime()
|
||||||
updateLastBolusFromResponse(response.bolusPulsesRemaining)
|
updateLastBolusFromResponse(response.bolusPulsesRemaining)
|
||||||
if (podState.activationTime == null) {
|
if (podState.activationTime == null) {
|
||||||
podState.activationTime = System.currentTimeMillis() - (response.minutesSinceActivation * 60000)
|
podState.activationTime = System.currentTimeMillis() - (response.minutesSinceActivation * 60_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
store()
|
store()
|
||||||
|
|
Loading…
Reference in a new issue