Merge pull request #2533 from jotomo/2742-2

SMS Carb command update
This commit is contained in:
Milos Kozak 2020-04-05 21:09:12 +02:00 committed by GitHub
commit 970f553a9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View file

@ -713,7 +713,9 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
override fun run() {
val detailedBolusInfo = DetailedBolusInfo()
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) {
@ -727,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))
}
}
})
}

View file

@ -280,6 +280,10 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
// return true if new record is created
public UpdateReturn createOrUpdate(Treatment treatment) {
if (treatment != null && treatment.source == Source.NONE) {
log.error("Coder error: source is not set for treatment: " + treatment, new Exception());
FabricPrivacy.logException(new Exception("Coder error: source is not set for treatment: " + treatment));
}
try {
Treatment old;
treatment.date = DatabaseHelper.roundDateToSec(treatment.date);