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:
parent
e7c7ce32bb
commit
fce6ec8d25
1 changed files with 19 additions and 12 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue