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,19 +715,26 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
detailedBolusInfo.carbs = anInteger().toDouble() detailedBolusInfo.carbs = anInteger().toDouble()
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.date = secondLong() detailedBolusInfo.date = secondLong()
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { if (ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
override fun run() { ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
if (result.success) { override fun run() {
var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger) if (result.success) {
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
} else { sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed) } else {
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
}
} }
} })
}) } 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))
}
} }
}) })
} }