Omnipod Dash: improve logging and fix prime timeouts
This commit is contained in:
parent
ebdc2aebe0
commit
653deff0b6
5 changed files with 68 additions and 12 deletions
|
@ -135,6 +135,7 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
|
||||
private fun observeProgramBasalCommand(basalProgram: BasalProgram): Observable<PodEvent> {
|
||||
return Observable.defer {
|
||||
logger.debug(LTag.PUMPCOMM, "Programming basal. basalProgram={}", basalProgram)
|
||||
bleManager.sendCommand(
|
||||
ProgramBasalCommand.Builder()
|
||||
.setUniqueId(podStateManager.uniqueId!!.toInt())
|
||||
|
@ -219,7 +220,10 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
}
|
||||
if (podStateManager.activationProgress.isBefore(ActivationProgress.PRIMING)) {
|
||||
observables.add(
|
||||
Observable.timer(PRIME_BOLUS_DURATION_SECONDS, TimeUnit.SECONDS).flatMap { Observable.empty() })
|
||||
Observable.defer {
|
||||
Observable.timer(podStateManager.firstPrimeBolusVolume!!.toLong(), TimeUnit.SECONDS)
|
||||
.flatMap { Observable.empty() }
|
||||
})
|
||||
observables.add(
|
||||
Observable.defer {
|
||||
bleManager.sendCommand(
|
||||
|
@ -317,8 +321,10 @@ class OmnipodDashManagerImpl @Inject constructor(
|
|||
}
|
||||
if (podStateManager.activationProgress.isBefore(ActivationProgress.INSERTING_CANNULA)) {
|
||||
observables.add(
|
||||
Observable.timer(CANNULA_INSERTION_BOLUS_DURATION_SECONDS, TimeUnit.SECONDS)
|
||||
.flatMap { Observable.empty() })
|
||||
Observable.defer {
|
||||
Observable.timer(podStateManager.secondPrimeBolusVolume!!.toLong(), TimeUnit.SECONDS)
|
||||
.flatMap { Observable.empty() }
|
||||
})
|
||||
observables.add(
|
||||
observeSendProgramBolusCommand(
|
||||
podStateManager.secondPrimeBolusVolume!! * 0.05,
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
|
||||
import java.util.*
|
||||
|
||||
class PodAlarmException(val response: AlarmStatusResponse) : Exception("Pod is in alarm: ${response.alarmType.value} ${response.alarmType.name}")
|
||||
class PodAlarmException(val response: AlarmStatusResponse) : Exception(
|
||||
String.format(
|
||||
Locale.getDefault(),
|
||||
"Pod is in alarm: %03d %s",
|
||||
response.alarmType.value.toInt() and 0xff,
|
||||
response.alarmType.name
|
||||
)
|
||||
)
|
|
@ -7,18 +7,53 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
|
|||
sealed class PodEvent {
|
||||
|
||||
/* BT connection events */
|
||||
class AlreadyConnected(val bluetoothAddress: String) : PodEvent()
|
||||
class AlreadyConnected(val bluetoothAddress: String) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "AlreadyConnected(bluetoothAddress='$bluetoothAddress')"
|
||||
}
|
||||
}
|
||||
|
||||
object AlreadyPaired : PodEvent()
|
||||
object Scanning : PodEvent()
|
||||
object BluetoothConnecting : PodEvent()
|
||||
class BluetoothConnected(val bluetoothAddress: String) : PodEvent()
|
||||
class BluetoothConnected(val bluetoothAddress: String) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "BluetoothConnected(bluetoothAddress='$bluetoothAddress')"
|
||||
}
|
||||
}
|
||||
|
||||
object Pairing : PodEvent()
|
||||
class Paired(val uniqueId: Id) : PodEvent()
|
||||
class Paired(val uniqueId: Id) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "Paired(uniqueId=$uniqueId)"
|
||||
}
|
||||
}
|
||||
|
||||
object EstablishingSession : PodEvent()
|
||||
object Connected : PodEvent()
|
||||
|
||||
/* Message exchange events */
|
||||
class CommandSending(val command: Command) : PodEvent()
|
||||
class CommandSent(val command: Command) : PodEvent()
|
||||
class ResponseReceived(val response: Response) : PodEvent()
|
||||
class CommandSending(val command: Command) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "CommandSending(command=$command)"
|
||||
}
|
||||
}
|
||||
|
||||
class CommandSent(val command: Command) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "CommandSent(command=$command)"
|
||||
}
|
||||
}
|
||||
|
||||
class ResponseReceived(val response: Response) : PodEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "ResponseReceived(response=$response)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,14 @@ class DashInsertCannulaViewModel @Inject constructor(
|
|||
if (profile == null) {
|
||||
source.onError(IllegalStateException("No profile set"))
|
||||
} else {
|
||||
val disposable = omnipodManager.activatePodPart2(mapProfileToBasalProgram(profile)).subscribeBy(
|
||||
val basalProgram = mapProfileToBasalProgram(profile)
|
||||
logger.debug(
|
||||
LTag.PUMPCOMM,
|
||||
"Mapped profile to basal program. profile={}, basalProgram={}",
|
||||
profile,
|
||||
basalProgram
|
||||
)
|
||||
val disposable = omnipodManager.activatePodPart2(basalProgram).subscribeBy(
|
||||
onNext = { podEvent ->
|
||||
logger.debug(
|
||||
LTag.PUMP,
|
||||
|
|
|
@ -41,7 +41,7 @@ fun mapProfileToBasalProgram(profile: Profile): BasalProgram {
|
|||
}
|
||||
|
||||
if (entries.size == 0 && basalValue.timeAsSeconds != 0) {
|
||||
throw java.lang.IllegalArgumentException("First basal segment start time should be 0")
|
||||
throw IllegalArgumentException("First basal segment start time should be 0")
|
||||
}
|
||||
|
||||
if (entries.size > 0 && entries[entries.size - 1].endSlotIndex != startSlotIndex) {
|
||||
|
|
Loading…
Reference in a new issue