nightscout / Trio

MIT License
45 stars 125 forks source link

update submodule CGMBLEKit: no change in function #330

Closed marionbarker closed 1 week ago

marionbarker commented 1 week ago

Summary:

update submodule CGMBLEKit: no change in function, add log to filter future events

Details:

Previously, Trio pointed to the SHA from loopandlearn dev_rc branch; this branch comprised LoopKit version plus code found in three PR open at that time to LoopKit/CGMBLEKit.

Subsequent to the dev_rc branch creation, a modification was requested to LoopKit CGMBLEKit PR 191; which was implemented. And 2 of the 3 PR were merged into dev over at LoopKit.

After the merge of #303, we created a new trio branch for loopandlearn/CGMBLEKit based off of LoopKit/CGMBLEKit dev branch. So the trio branch has the modified code for PR 191 (added logging of any future events before they are filtered out). And then the trio branch was modified to include the cherry-pick from the one PR (192) still open over at LoopKit.

So the function of this code is identical except for the added logging.

git index details:

Trio % git diff alpha update_CGMBLEKit_submodule
diff --git a/CGMBLEKit b/CGMBLEKit
index a92e9752..15af9cf3 160000
--- a/CGMBLEKit
+++ b/CGMBLEKit
@@ -1 +1 @@
-Subproject commit a92e9752994e7b143cdb007d3c7bcba0c0cc9214
+Subproject commit 15af9cf319bff2ac49c361da254ad667461d4687

Logging change in CGMBLEKit:

CGMBLEKit % git diff a92e9752 15af9cf31
diff --git a/CGMBLEKit/TransmitterManager.swift b/CGMBLEKit/TransmitterManager.swift
index cdff276..9500060 100644
--- a/CGMBLEKit/TransmitterManager.swift
+++ b/CGMBLEKit/TransmitterManager.swift
@@ -336,10 +336,15 @@ public class TransmitterManager: TransmitterDelegate {
         }

         // Filter out future-dated events
+        // Stopgap measure for the issue described in https://github.com/LoopKit/Loop/issues/2087
         events = events.filter { event in
-            return event.date <= Date() // Ensure event date is not in the future
+            if event.date > Date() {
+                log.error("Future-dated event detected: %{public}@", String(describing: event))
+                return false
+            }
+            return true
         }
-        
+
         if !events.isEmpty {
             shareManager.delegate.notify { delegate in
                 delegate?.cgmManager(self.shareManager, hasNew: events)