fix command sending failure

This commit is contained in:
Andrei Vereha 2021-06-19 16:12:41 +02:00
parent 100f2b9e69
commit 665444ea9e
3 changed files with 14 additions and 15 deletions

View file

@ -189,7 +189,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
if (!podStateManager.isActivationCompleted) {
return PumpEnactResult(injector).success(true).enacted(false)
return PumpEnactResult(injector).success(true).enacted(true)
}
val basalProgram = mapProfileToBasalProgram(profile)
return executeProgrammingCommand(
@ -773,10 +773,14 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
private fun deactivatePod(): PumpEnactResult {
return executeProgrammingCommand(
val ret = executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD),
command = omnipodManager.deactivatePod().ignoreElements()
).toPumpEnactResult()
if (podStateManager.activeCommand != null) {
ret.success(false)
}
return ret
}
private fun handleTimeChange(): PumpEnactResult {

View file

@ -166,7 +166,7 @@ class OmnipodDashManagerImpl @Inject constructor(
.setUniqueId(podStateManager.uniqueId!!.toInt())
.setSequenceNumber(podStateManager.messageSequenceNumber)
.setNonce(NONCE)
.setProgramReminder(ProgramReminder(atStart = hasBasalBeepEnabled, atEnd = hasBasalBeepEnabled, atInterval = 0))
.setProgramReminder(ProgramReminder(atStart = hasBasalBeepEnabled, atEnd = false, atInterval = 0))
.setBasalProgram(basalProgram)
.setCurrentTime(currentTime)
.build(),
@ -436,18 +436,11 @@ class OmnipodDashManagerImpl @Inject constructor(
beepEnabled: Boolean
): Observable<PodEvent> {
return Observable.defer {
val beepType = if (!beepEnabled) {
val beepType = if (!beepEnabled)
BeepType.SILENT
} else {
when (deliveryType) {
StopDeliveryCommand.DeliveryType.ALL, StopDeliveryCommand.DeliveryType.BASAL ->
BeepType.FOUR_TIMES_BIP_BEEP
StopDeliveryCommand.DeliveryType.TEMP_BASAL ->
BeepType.LONG_SINGLE_BEEP
StopDeliveryCommand.DeliveryType.BOLUS ->
BeepType.LONG_SINGLE_BEEP
}
}
else
BeepType.LONG_SINGLE_BEEP
bleManager.sendCommand(
StopDeliveryCommand.Builder()
.setSequenceNumber(podStateManager.messageSequenceNumber)

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
import info.nightscout.androidaps.plugins.pump.omnipod.dash.databinding.OmnipodDashPodManagementBinding
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activation.DashPodActivationWizardActivity
import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.deactivation.DashPodDeactivationWizardActivity
@ -124,7 +125,8 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() {
binding.buttonActivatePod.isEnabled = podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED)
binding.buttonDeactivatePod.isEnabled =
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)
podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) ||
podStateManager.podStatus == PodStatus.ALARM
if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)) {
if (commandQueue.isCustomCommandInQueue(CommandPlayTestBeep::class.java)) {