disconnect on force deactivation when pump in error state

This commit is contained in:
jbr7rr 2023-08-06 14:21:21 +02:00
parent 826b0f3d8c
commit 30c1c16cd0
2 changed files with 5 additions and 0 deletions

View file

@ -187,6 +187,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
if (medtrumPump.tempBasalInProgress) {
result = sendPacketAndGetResponse(CancelTempBasalPacket(injector))
}
// Make sure we have all events of this patch if possible
loadEvents()
if (result) result = sendPacketAndGetResponse(StopPatchPacket(injector))
return result
}

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.medtrum.ui.viewmodel
import android.os.SystemClock
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import info.nightscout.interfaces.queue.Callback
@ -255,6 +256,8 @@ class MedtrumViewModel @Inject constructor(
if (medtrumPump.pumpState >= MedtrumPumpState.OCCLUSION && medtrumPump.pumpState <= MedtrumPumpState.NO_CALIBRATION) {
// We are in a fault state, we need to force deactivation
aapsLogger.info(LTag.PUMP, "deactivatePatch: force deactivation")
medtrumService?.disconnect("ForceDeactivation")
SystemClock.sleep(1000)
medtrumPump.pumpState = MedtrumPumpState.STOPPED
} else {
aapsLogger.info(LTag.PUMP, "deactivatePatch: failure!")