From 28f31414ba19c37b0356c7b26eb53f748bcdc115 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 23 Nov 2017 11:13:47 +0100 Subject: [PATCH] Update pump profile during Combo init. --- .../plugins/PumpCombo/ComboPlugin.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index cab7f72fe0..94e9967534 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -49,6 +49,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SP; import static de.jotomo.ruffy.spi.BolusProgressReporter.State.FINISHED; @@ -263,10 +264,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf @Override public boolean isThisProfileSet(Profile profile) { - if (!isInitialized()) - return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS - if (pump.basalProfile == null) - return true; // TODO: not sure what's better. so far TRUE to prevent too many SMS + if (!isInitialized()) { + // This is called too soon (for the Combo) on startup, so ignore this. + // The Combo init (refreshDataFromPump) will read the profile and update the pump's + // profile if the pref is set; + return true; + } return pump.basalProfile.equals(convertProfileToComboProfile(profile)); } @@ -341,6 +344,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf return; } pump.basalProfile = readBasalResult.basalProfile; + + Profile profile = MainApp.getConfigBuilder().getProfile(); + if (SP.getBoolean("syncprofiletopump", false) + && !pump.basalProfile.equals(convertProfileToComboProfile(profile))) { + setNewBasalProfile(profile); + } } if (!checkPumpHistory()) {