From de1475dbba5056b64d0d89c81fd2e68a8f00104c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 3 Jan 2018 22:28:48 +0100 Subject: [PATCH 1/7] remove logging --- .../androidaps/data/QuickWizardEntry.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java index 70dd37a6ab..08d1a7295a 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/data/QuickWizardEntry.java @@ -181,7 +181,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBG"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -190,7 +190,7 @@ public class QuickWizardEntry { try { return storage.getInt("useCOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -199,7 +199,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBolusIOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -208,7 +208,7 @@ public class QuickWizardEntry { try { return storage.getInt("useBasalIOB"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return YES; } @@ -217,7 +217,7 @@ public class QuickWizardEntry { try { return storage.getInt("useTrend"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -226,7 +226,7 @@ public class QuickWizardEntry { try { return storage.getInt("useSuperBolus"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } @@ -235,7 +235,7 @@ public class QuickWizardEntry { try { return storage.getInt("useTempTarget"); } catch (JSONException e) { - log.error("Unhandled exception", e); + //log.error("Unhandled exception", e); } return NO; } From 4643cdc3b9f1ec6d8d602dad2f1f5175ed89fc1a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 4 Jan 2018 09:45:17 +0100 Subject: [PATCH 2/7] accept local NS data broadcast even when ns_upload_only is selected --- .../info/nightscout/androidaps/Services/DataService.java | 9 +++++++-- .../NSClientInternal/broadcasts/BroadcastTreatment.java | 3 ++- .../NSClientInternal/receivers/DBAccessReceiver.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 3fec202ae0..e4d65eadc0 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -96,7 +96,12 @@ public class DataService extends IntentService { boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class); - boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false); + boolean acceptNSData = !SP.getBoolean(R.string.key_ns_upload_only, false); + Bundle bundles = intent.getExtras(); + if (bundles != null && bundles.containsKey("islocal")) { + acceptNSData = acceptNSData || bundles.getBoolean("islocal"); + } + if (intent != null) { final String action = intent.getAction(); @@ -125,7 +130,7 @@ public class DataService extends IntentService { } else if (isNSProfile && Intents.ACTION_NEW_PROFILE.equals(action) || Intents.ACTION_NEW_DEVICESTATUS.equals(action)) { // always handle Profile if NSProfile is enabled without looking at nsUploadOnly handleNewDataFromNSClient(intent); - } else if (!nsUploadOnly && + } else if (acceptNSData && (Intents.ACTION_NEW_TREATMENT.equals(action) || Intents.ACTION_CHANGED_TREATMENT.equals(action) || Intents.ACTION_REMOVED_TREATMENT.equals(action) || diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java index 43c46bf072..94b83c56bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java @@ -24,11 +24,12 @@ import info.nightscout.utils.SP; public class BroadcastTreatment { private static Logger log = LoggerFactory.getLogger(BroadcastTreatment.class); - public static void handleNewTreatment(JSONObject treatment, boolean isDelta) { + public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) { Bundle bundle = new Bundle(); bundle.putString("treatment", treatment.toString()); bundle.putBoolean("delta", isDelta); + bundle.putBoolean("islocal", isLocalBypass); Intent intent = new Intent(Intents.ACTION_NEW_TREATMENT); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java index 4590490ecf..1ab93a53d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java @@ -110,7 +110,7 @@ public class DBAccessReceiver extends BroadcastReceiver { JSONObject data = new JSONObject(request.data); data.put("mills", DateUtil.fromISODateString(data.getString("created_at")).getTime()); data.put("_id", data.get("NSCLIENT_ID")); // this is only fake id - BroadcastTreatment.handleNewTreatment(data, false); + BroadcastTreatment.handleNewTreatment(data, false, true); } catch (Exception e) { log.error("Unhadled exception", e); } From 2d769ccf9aea1244d1530a21f4f5559649a93ff6 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 1 Jan 2018 14:04:45 +0100 Subject: [PATCH 3/7] Remove debug code. --- .../src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index c61b80cc6d..77d5990792 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -202,7 +202,7 @@ public class RuffyScripter implements RuffyCommands { return; } try { - log.debug("Disconnecting, requested by ...", new Exception()); + log.debug("Disconnecting"); ruffyService.doRTDisconnect(); } catch (RemoteException e) { // ignore From 9457fb61e538d7f57da778963ce3b600f9e0ae63 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 4 Jan 2018 11:05:19 +0100 Subject: [PATCH 4/7] RuffyScripter.isConnected: longer wait. Declare the connection dead if no menu update was sent within 10s. Occassionally it takes up 4s for regular updates to come in (possibly due to other busy background threads? Iob/Cob calc is suspiscously often running when the error occurs). With the previous timeout, commands were killed too early when things (pump, ruffy, aaps ...) needed some time to think). --- .../src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 77d5990792..2eb121111f 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -187,10 +187,7 @@ public class RuffyScripter implements RuffyCommands { if (!ruffyService.isConnected()) { return false; } - if (System.currentTimeMillis() - menuLastUpdated >= 1500) { - waitForScreenUpdate(); - } - return System.currentTimeMillis() - menuLastUpdated < 1500; + return ruffyService.isConnected() && System.currentTimeMillis() - menuLastUpdated < 10 * 1000; } catch (RemoteException e) { return false; } From 41fb92815b74b4a0ca70001806f0c3fa5a5f8944 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 4 Jan 2018 12:22:08 +0100 Subject: [PATCH 5/7] request new data on preference change --- .../info/nightscout/androidaps/watchfaces/BaseWatchFace.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index c23c2930a9..ea5b41176b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -569,6 +569,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){ + if("delta_granularity".equals(key)){ + ListenerService.requestData(this); + } + if(layoutSet){ setDataFields(); setColor(); From c3d14b506d9c0ea042a8daeed6718605d0309f83 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 4 Jan 2018 16:20:49 +0100 Subject: [PATCH 6/7] allow old data on the wf --- .../nightscout/androidaps/data/GlucoseStatus.java | 11 +++++++++-- .../Wear/wearintegration/WatchUpdaterService.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java index 1623028a82..ad4f161799 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java @@ -64,14 +64,21 @@ public class GlucoseStatus { return this; } + + @Nullable - public static GlucoseStatus getGlucoseStatusData() { + public static GlucoseStatus getGlucoseStatusData(){ + return getGlucoseStatusData(false); + } + + @Nullable + public static GlucoseStatus getGlucoseStatusData(boolean allowOldData) { // load 45min long fromtime = (long) (System.currentTimeMillis() - 60 * 1000L * 45); List data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false); int sizeRecords = data.size(); - if (sizeRecords < 1 || data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L) { + if (sizeRecords < 1 || (data.get(0).date < System.currentTimeMillis() - 7 * 60 * 1000L && !allowOldData)) { return null; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 91045ba4d6..6ea01692fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -316,7 +316,7 @@ public class WatchUpdaterService extends WearableListenerService implements if (last_bg == null) return; List graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true); - GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); + GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(true); if (!graph_bgs.isEmpty()) { DataMap entries = dataMapSingleBG(last_bg, glucoseStatus); From d47b2f8b4b115753a31be9a8a8033b902cbb4e14 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 4 Jan 2018 21:20:12 +0100 Subject: [PATCH 7/7] Swallow exception on disconnect. --- .../src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 2eb121111f..974b4fb721 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -203,6 +203,8 @@ public class RuffyScripter implements RuffyCommands { ruffyService.doRTDisconnect(); } catch (RemoteException e) { // ignore + } catch (Exception e) { + log.warn("Disconnect not happy", e); } }