SmsCommunicator: only ask pump with support to add carbs.

This aligns with how this is generally handles elsewhere: check if a pump supports carbs and if not, don't bother the driver but add the carbs directly via TreatmentsPlugin.
This commit is contained in:
Johannes Mockenhaupt 2020-03-24 21:27:38 +01:00
parent e7c7ce32bb
commit fce6ec8d25
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -715,6 +715,7 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
detailedBolusInfo.carbs = anInteger().toDouble()
detailedBolusInfo.source = Source.USER
detailedBolusInfo.date = secondLong()
if (ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (result.success) {
@ -728,6 +729,12 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
}
}
})
} else {
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true)
var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger)
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
}
}
})
}