From fce6ec8d2581ed3becfa82a6c17ab3c42a0c88cf Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 24 Mar 2020 21:27:38 +0100 Subject: [PATCH] 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. --- .../smsCommunicator/SmsCommunicatorPlugin.kt | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 41c28bbf21..433acf9403 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -715,19 +715,26 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription() detailedBolusInfo.carbs = anInteger().toDouble() detailedBolusInfo.source = Source.USER detailedBolusInfo.date = secondLong() - ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { - override fun run() { - if (result.success) { - var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger) - replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) - sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - } else { - var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed) - replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) - sendSMS(Sms(receivedSms.phoneNumber, replyText)) + if (ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) { + ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { + override fun run() { + if (result.success) { + var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger) + replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) + sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + } else { + var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed) + 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)) + } } }) }