diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml
index cf81c5e8675..6f5ed8199ad 100644
--- a/core/ui/src/main/res/values/strings.xml
+++ b/core/ui/src/main/res/values/strings.xml
@@ -114,7 +114,7 @@
BG
Calibration
Run alarm in %1$d min
- Bolus reported an error. Manually check real delivered amount
+ Bolus reported an error. Manually check real delivered insulin and carb amount
Bolus reminder
Duration
g
diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt
index 45b1ddfd3fa..95102a85b21 100644
--- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt
+++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPlugin.kt
@@ -397,10 +397,9 @@ import kotlin.math.abs
result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep
result.bolusDelivered = t.insulin
if (!result.success) {
- // Note: There are no error codes
- result.comment = "failed"
+ result.comment(medtrumPump.bolusErrorReason ?: rh.gs(R.string.bolus_error_reason_pump_error))
} else {
- result.comment = "ok"
+ result.comment(app.aaps.core.ui.R.string.ok)
}
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Success: ${result.success} Asked: ${detailedBolusInfo.insulin} Delivered: ${result.bolusDelivered}")
return result
diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt
index a59edda971e..fdcec62530e 100644
--- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt
+++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/MedtrumPump.kt
@@ -250,10 +250,13 @@ class MedtrumPump @Inject constructor(
_bolusAmountToBeDelivered = value
sp.putDouble(R.string.key_bolus_amount_to_be_delivered, value)
}
+
+
var bolusingTreatment: EventOverviewBolusProgress.Treatment? = null // actually delivered treatment
var bolusProgressLastTimeStamp: Long = 0 // timestamp of last bolus progress message
var bolusStopped = false // bolus stopped by user
var bolusDone = true // Bolus completed or stopped on pump, initialize as true as to don't show bolus on init
+ var bolusErrorReason: String? = null
private val _bolusAmountDelivered = MutableStateFlow(0.0)
val bolusAmountDeliveredFlow: StateFlow = _bolusAmountDelivered
diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt
index af367c30d01..a9c71afa709 100644
--- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt
+++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/services/MedtrumService.kt
@@ -315,6 +315,8 @@ class MedtrumService : DaggerService(), BLECommCallback {
} else {
aapsLogger.error(LTag.PUMPCOMM, "Failed to load events")
}
+ // Update ui text to getting pump status (indicating syncing records is finished)
+ rxBus.send(EventPumpStatusChanged(rh.gs(R.string.getting_pump_status)))
return result
}
@@ -352,8 +354,10 @@ class MedtrumService : DaggerService(), BLECommCallback {
val insulin = detailedBolusInfo.insulin
medtrumPump.bolusDone = false
medtrumPump.bolusStopped = false
+ medtrumPump.bolusErrorReason = null
if (!sendBolusCommand(insulin)) {
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_unable_to_send_command)
aapsLogger.error(LTag.PUMPCOMM, "Failed to set bolus")
commandQueue.readStatus(rh.gs(R.string.bolus_error), null) // make sure if anything is delivered (which is highly unlikely at this point) we get it
medtrumPump.bolusDone = true
@@ -414,14 +418,17 @@ class MedtrumService : DaggerService(), BLECommCallback {
private fun canSetBolus(): Boolean {
if (!isConnected) {
aapsLogger.warn(LTag.PUMPCOMM, "Pump not connected, not setting bolus")
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_not_connected)
return false
}
if (BolusProgressData.stopPressed) {
aapsLogger.warn(LTag.PUMPCOMM, "Bolus stop pressed, not setting bolus")
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_user)
return false
}
if (!medtrumPump.bolusDone) {
aapsLogger.warn(LTag.PUMPCOMM, "Bolus already in progress, not setting new one")
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_already_in_progress)
return false
}
return true
@@ -454,6 +461,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
connectionRetryCounter++
} else {
communicationLost = true
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_communication_lost)
aapsLogger.warn(LTag.PUMPCOMM, "Retry connection failed, communication stopped")
disconnect("Communication stopped")
}
@@ -494,6 +502,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
fun stopBolus() {
aapsLogger.debug(LTag.PUMPCOMM, "bolusStop >>>>> @ " + if (medtrumPump.bolusingTreatment == null) "" else medtrumPump.bolusingTreatment?.insulin)
+ medtrumPump.bolusErrorReason = rh.gs(R.string.bolus_error_reason_user)
if (isConnected) {
var success = sendPacketAndGetResponse(CancelBolusPacket(injector))
val timeout = System.currentTimeMillis() + T.secs(30).msecs()
@@ -563,6 +572,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
var failureCount = 0
if (medtrumPump.syncedSequenceNumber < medtrumPump.currentSequenceNumber) {
for (sequence in (medtrumPump.syncedSequenceNumber + 1)..medtrumPump.currentSequenceNumber) {
+ rxBus.send(EventPumpStatusChanged(rh.gs(R.string.syncing_records, (medtrumPump.currentSequenceNumber - sequence + 1))))
val packet = GetRecordPacket(injector, sequence)
result = sendPacketAndGetResponse(packet, COMMAND_SYNC_TIMEOUT_SEC)
if (!result && packet.failed) {
diff --git a/pump/medtrum/src/main/res/values/strings.xml b/pump/medtrum/src/main/res/values/strings.xml
index e5ac7972ed6..025ea7d9bb0 100644
--- a/pump/medtrum/src/main/res/values/strings.xml
+++ b/pump/medtrum/src/main/res/values/strings.xml
@@ -162,8 +162,16 @@
Getting pump status
+ Syncing records, %1$d left
Getting bolus status
Getting temporary basal status
Setting user options
+
+ Bolus cancelled by user
+ Pump not connected
+ Bolus already in progress
+ Unable to send bolus command
+ Timeout getting bolus status
+ Pump error