set temp basal beeps
This commit is contained in:
parent
3314df7bb7
commit
3b26068faf
|
@ -258,6 +258,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
enforceNew: Boolean,
|
enforceNew: Boolean,
|
||||||
tbrType: PumpSync.TemporaryBasalType
|
tbrType: PumpSync.TemporaryBasalType
|
||||||
): PumpEnactResult {
|
): PumpEnactResult {
|
||||||
|
val tempBasalBeeps = sp.getBoolean(R.string.key_omnipod_common_tbr_beeps_enabled, false)
|
||||||
|
|
||||||
return Completable.concat(
|
return Completable.concat(
|
||||||
listOf(
|
listOf(
|
||||||
observeNoActiveTempBasal(enforceNew),
|
observeNoActiveTempBasal(enforceNew),
|
||||||
|
@ -270,7 +272,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
|
||||||
.ignoreElement(),
|
.ignoreElement(),
|
||||||
omnipodManager.setTempBasal(
|
omnipodManager.setTempBasal(
|
||||||
absoluteRate,
|
absoluteRate,
|
||||||
durationInMinutes.toShort()
|
durationInMinutes.toShort(),
|
||||||
|
tempBasalBeeps,
|
||||||
).ignoreElements(),
|
).ignoreElements(),
|
||||||
history.updateFromState(podStateManager),
|
history.updateFromState(podStateManager),
|
||||||
podStateManager.updateActiveCommand()
|
podStateManager.updateActiveCommand()
|
||||||
|
|
|
@ -24,7 +24,7 @@ interface OmnipodDashManager {
|
||||||
|
|
||||||
fun setTime(): Observable<PodEvent>
|
fun setTime(): Observable<PodEvent>
|
||||||
|
|
||||||
fun setTempBasal(rate: Double, durationInMinutes: Short): Observable<PodEvent>
|
fun setTempBasal(rate: Double, durationInMinutes: Short, tempBasalBeeps: Boolean): Observable<PodEvent>
|
||||||
|
|
||||||
fun stopTempBasal(): Observable<PodEvent>
|
fun stopTempBasal(): Observable<PodEvent>
|
||||||
|
|
||||||
|
|
|
@ -460,14 +460,14 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
return Observable.empty()
|
return Observable.empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeSendProgramTempBasalCommand(rate: Double, durationInMinutes: Short): Observable<PodEvent> {
|
private fun observeSendProgramTempBasalCommand(rate: Double, durationInMinutes: Short, tempBasalBeeps: Boolean): Observable<PodEvent> {
|
||||||
return Observable.defer {
|
return Observable.defer {
|
||||||
// TODO cancel current temp basal (if active)
|
|
||||||
bleManager.sendCommand(
|
bleManager.sendCommand(
|
||||||
ProgramTempBasalCommand.Builder()
|
ProgramTempBasalCommand.Builder()
|
||||||
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
.setSequenceNumber(podStateManager.messageSequenceNumber)
|
||||||
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
||||||
.setNonce(NONCE)
|
.setNonce(NONCE)
|
||||||
|
.setProgramReminder(ProgramReminder(tempBasalBeeps, tempBasalBeeps, 0))
|
||||||
.setRateInUnitsPerHour(rate)
|
.setRateInUnitsPerHour(rate)
|
||||||
.setDurationInMinutes(durationInMinutes)
|
.setDurationInMinutes(durationInMinutes)
|
||||||
.build(),
|
.build(),
|
||||||
|
@ -476,11 +476,11 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setTempBasal(rate: Double, durationInMinutes: Short): Observable<PodEvent> {
|
override fun setTempBasal(rate: Double, durationInMinutes: Short, tempBasalBeeps: Boolean): Observable<PodEvent> {
|
||||||
return Observable.concat(
|
return Observable.concat(
|
||||||
observePodRunning,
|
observePodRunning,
|
||||||
observeConnectToPod,
|
observeConnectToPod,
|
||||||
observeSendProgramTempBasalCommand(rate, durationInMinutes)
|
observeSendProgramTempBasalCommand(rate, durationInMinutes, tempBasalBeeps)
|
||||||
)
|
)
|
||||||
// TODO these would be common for any observable returned in a public function in this class
|
// TODO these would be common for any observable returned in a public function in this class
|
||||||
.doOnNext(PodEventInterceptor())
|
.doOnNext(PodEventInterceptor())
|
||||||
|
@ -700,7 +700,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
||||||
inner class ErrorInterceptor : Consumer<Throwable> {
|
inner class ErrorInterceptor : Consumer<Throwable> {
|
||||||
|
|
||||||
override fun accept(throwable: Throwable) {
|
override fun accept(throwable: Throwable) {
|
||||||
logger.debug(LTag.PUMP, "Intercepted error in OmnipodDashManagerImpl: ${throwable.javaClass.simpleName}")
|
logger.debug(LTag.PUMP, "Intercepted error in OmnipodDashManagerImpl: ${throwable}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue