Fix bolus not properly updating for short bolus

This commit is contained in:
jbr7rr 2023-07-11 14:54:40 +02:00
parent dda7fa6086
commit a7d7f373de

View file

@ -276,13 +276,6 @@ class MedtrumService : DaggerService(), BLECommCallback {
fun setBolus(detailedBolusInfo: DetailedBolusInfo, t: EventOverviewBolusProgress.Treatment): Boolean {
if (!isConnected) return false
val insulin = detailedBolusInfo.insulin
val result = sendPacketAndGetResponse(SetBolusPacket(injector, insulin))
if (result == false) {
aapsLogger.error(LTag.PUMPCOMM, "Failed to set bolus")
commandQueue.loadEvents(null) // make sure if anything is delivered (which is highly unlikely at this point) we get it
return false
}
val bolusStart = System.currentTimeMillis()
medtrumPump.bolusDone = false
@ -292,6 +285,13 @@ class MedtrumService : DaggerService(), BLECommCallback {
medtrumPump.bolusStopForced = false
medtrumPump.bolusProgressLastTimeStamp = bolusStart
val result = sendPacketAndGetResponse(SetBolusPacket(injector, insulin))
if (result == false) {
aapsLogger.error(LTag.PUMPCOMM, "Failed to set bolus")
commandQueue.loadEvents(null) // make sure if anything is delivered (which is highly unlikely at this point) we get it
return false
}
detailedBolusInfo.timestamp = bolusStart // Make sure the timestamp is set to the start of the bolus
detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history
// Sync the initial bolus