Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
36a2a53
Omnikit
ps2 Sep 2, 2018
5746df1
Add OmniKit frameworks
ps2 Sep 11, 2018
6988bb8
fix cartfile
ps2 Sep 12, 2018
1b23177
Track lastAddedPumpData, including lastAddedPumpEvents
ps2 Sep 15, 2018
6b4544c
Fix carthage copy frameworks script
ps2 Sep 19, 2018
5e9f41a
rebase
ps2 Sep 20, 2018
096b347
update deps
ps2 Sep 25, 2018
65e3c9e
Initialize setupViewController with existing pump settings
ps2 Sep 26, 2018
2ee5feb
Suspend/Resume
ps2 Sep 28, 2018
ad73ea8
Use normal separator behavior
ps2 Sep 28, 2018
230a441
Reload pump section after adding pumpmanager
ps2 Sep 29, 2018
83f2943
LoopKit PumpManagerStatus updates
ps2 Oct 11, 2018
ff978b4
Merge in dev
ps2 Oct 11, 2018
d0c4a91
PumpManagerUI vended HUD views
ps2 Oct 18, 2018
b2a68e0
Add missing file
ps2 Oct 22, 2018
63932d1
Update to LoopKit naming changes
ps2 Oct 22, 2018
8524093
Push instead of present pumpmanager vended vc in response to HUD view…
ps2 Oct 23, 2018
37ef4aa
Add prep_workspace.sh script
ps2 Oct 23, 2018
996bc3d
HUDProvider updates
ps2 Oct 26, 2018
c32cd8c
Fix hud clearing after removing pump manager. Show boluses that take …
ps2 Oct 31, 2018
76c8f26
PumpManager returns DoseEntry for requested bolus, including duration
ps2 Nov 4, 2018
bdaea1d
Example jumpstart
ps2 Nov 6, 2018
b535cfc
Suspend/Resume with new PumpManager status updates
ps2 Nov 20, 2018
3a12b02
Fix issue with DeviceDataManager missing from issue report
ps2 Nov 26, 2018
b4276a1
Handle LoopKit and rileylink_ios updates
ps2 Dec 2, 2018
511f0c2
Cleanup testing code
ps2 Dec 5, 2018
fb006e5
Update Loop today widget when HUD views change
ps2 Dec 9, 2018
3624d1a
Renaming updates from LoopKit
ps2 Jan 11, 2019
8598af6
Updates for recent LoopKit pumpmanager-changes branch
ps2 Jan 22, 2019
6a9ce73
update prep script for CGMBLEKit branch change
Kdisimone Jan 22, 2019
0334c23
Merge pull request #12 from ps2/Kdisimone-patch-1
ps2 Jan 22, 2019
849916d
Updates for hud provider delegate change
ps2 Jan 29, 2019
a7f89ca
Merge branch 'omnikit' of github.com:ps2/loop-priv into omnikit
ps2 Jan 29, 2019
8a152ee
Pumpmanager updates
ps2 Jan 30, 2019
dd2e2c3
Update prep script
ps2 Jan 30, 2019
a18cfb4
Fix permissions on prep workspace script
ps2 Jan 30, 2019
2683aa5
Merge in dev
ps2 Jan 31, 2019
e22f4b0
Pumpmanager changes
ps2 Feb 2, 2019
c0c2242
Update to pumpmanager-updates
ps2 Feb 3, 2019
7cff7b4
Back out DEVELOPMENT_TEAM settings
ps2 Feb 5, 2019
ebd1e2b
Context object does not need HUDProvider reference
ps2 Feb 5, 2019
ba571a7
Include dose in enactBolus completion
ps2 Feb 5, 2019
f209407
Add omnikit back to Loop
ps2 Feb 6, 2019
e54617a
Bump dependency revisions
ps2 Feb 6, 2019
6a24216
Update HUD set of views only on PumpManager change
ps2 Feb 7, 2019
9a6f219
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into pu…
ps2 Feb 7, 2019
8a893b6
Remove unused file
ps2 Feb 7, 2019
5147bfd
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into om…
ps2 Feb 7, 2019
23842de
synchronize deviceDataManager.pumpManagerStatus access
ps2 Feb 8, 2019
9a729c6
Bump dep revisions
ps2 Feb 8, 2019
509573c
Remove unused files
ps2 Feb 8, 2019
26e0ea5
Remove unneeded reloadSections calls
ps2 Feb 8, 2019
3e8f83c
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into pu…
ps2 Feb 8, 2019
d020d86
Merge branch 'pumpmanager-changes' of github.com:LoopKit/Loop into om…
ps2 Feb 8, 2019
2493df5
Add script for workspace prep
ps2 Feb 8, 2019
538e337
Bump rileylink_ios rev
ps2 Feb 8, 2019
ac68688
Link in OmniKit frameworks
ps2 Feb 8, 2019
14ae518
Fix build issue when carthage is run from Xcode
ps2 Feb 8, 2019
bbd36d1
Only allow BLE to trigger looping every 5 minutes
ps2 Feb 9, 2019
995c3e2
Use bolus end date to clear lastRequestedBolus
ps2 Feb 11, 2019
83b1e2e
present instead of show settings vc
ps2 Feb 11, 2019
82e66f0
small refactorings
ps2 Feb 11, 2019
4f652a8
Improvements from @mpangburn's review
ps2 Feb 13, 2019
2985424
Update active flag on HUDProvider when hud is visible and app is active
ps2 Feb 15, 2019
be5f843
Remove signing team changes
ps2 Feb 15, 2019
a14d597
Merge remote-tracking branch 'origin/pumpmanager-changes' into omnikit
ps2 Feb 15, 2019
9e27c6b
HUDProvider active -> visible
ps2 Feb 16, 2019
e12cb26
Merge remote-tracking branch 'origin/pumpmanager-changes' into omnikit
ps2 Feb 16, 2019
9cdefeb
Update to dev LoopKit
ps2 Feb 19, 2019
9d9e6e2
Update to dev LoopKit
ps2 Feb 19, 2019
8d48ada
Merge in basal-picker
ps2 Mar 5, 2019
2478961
Limit recommended temp basals to supported rates.
ps2 Mar 6, 2019
d204ca2
Merge branch 'supported-temp-basal-rates' of github.com:tidepool-org/…
ps2 Mar 6, 2019
3212f6e
Merge remote-tracking branch 'origin/supported-temp-basal-rates' into…
ps2 Mar 6, 2019
1afb294
Merge remote-tracking branch 'origin/dev' into omnikit
ps2 Mar 9, 2019
c36cc77
Unset DEVELOPMENT_TEAM
ps2 Mar 9, 2019
d350e23
Merge remote-tracking branch 'origin/dev' into omnikit
ps2 Mar 9, 2019
ef67244
Remove lockedSupportedTempBasalRates
ps2 Mar 9, 2019
00fd4b6
Update to new GlucoseRangeSchedule.Override initializer signature
ps2 Mar 9, 2019
a2109d1
Merge remote-tracking branch 'origin/dev' into omnikit
ps2 Mar 20, 2019
f18417f
Copy LoopTestingKit framework to Loop app bundle
ps2 Mar 20, 2019
a7b01e1
Merge remote-tracking branch 'origin/dev' into omnikit
ps2 Mar 20, 2019
40b599a
Merge remote-tracking branch 'origin/dev' into omnikit
ps2 Mar 29, 2019
8c6b9c6
update swift charts for Xcode 10.2
Kdisimone Apr 1, 2019
a7d90cd
Updated cartfile.resolved for swift charts 0.6.5
Kdisimone Apr 1, 2019
3716343
Merge pull request #15 from ps2/Kdisimone-patch-2
ps2 Apr 1, 2019
4f84a81
Merge branch 'dev' into omnikit
ps2 Apr 6, 2019
574fc80
Handle notifications scheduled by DeviceManagers
ps2 Apr 12, 2019
76676d9
Merge remote-tracking branch 'origin/devicemanager-notifications' int…
ps2 Apr 12, 2019
9956125
Checkout notification-identifiers branch of LoopKit
ps2 Apr 12, 2019
00c78e0
Perform UNUserNotificationCenter calls on main queue
ps2 Apr 12, 2019
bcb0eaa
Use omnipod-testing branches
ps2 Apr 21, 2019
d90252a
Bump rileylink_ios/omnipod-testing rev
ps2 Apr 22, 2019
77a1cfa
include pump manufacturer and model in the pump status
jasoncalabrese May 4, 2019
3cec2f3
only upload the reservoir units if they're current
jasoncalabrese May 5, 2019
561aa12
Merge pull request #947 from jasoncalabrese/omnipod-testing-pump-status
ps2 May 9, 2019
b7eca0d
Bump rileylink_ios rev
ps2 May 9, 2019
a12dd42
Fix initial checkout branch for workspace builds
ps2 May 12, 2019
f027d5b
Bring in g6 updates
ps2 Jul 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
github "LoopKit/LoopKit" "dev"
github "LoopKit/CGMBLEKit" "dev"
github "LoopKit/dexcom-share-client-swift" "dev"
github "LoopKit/G4ShareSpy" "dev"
github "ps2/rileylink_ios" "dev"
github "LoopKit/LoopKit" "omnipod-testing"
github "LoopKit/CGMBLEKit" "omnipod-testing"
github "i-schuetz/SwiftCharts" == 0.6.5
github "LoopKit/dexcom-share-client-swift" "omnipod-testing"
github "LoopKit/G4ShareSpy" "omnipod-testing"
github "ps2/rileylink_ios" "omnipod-testing"
github "LoopKit/Amplitude-iOS" "decreepify"
github "maxkonovalov/MKRingProgressView" ~> 2.2
12 changes: 6 additions & 6 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github "LoopKit/Amplitude-iOS" "2137d5fd44bf630ed33e1e72d7af6d8f8612f270"
github "LoopKit/CGMBLEKit" "ea1267791c66e884f1013fffd36faf4555cc6eaf"
github "LoopKit/G4ShareSpy" "fed5a389e3e47e3a1953878dd21852aa5f44b360"
github "LoopKit/LoopKit" "e386a24577244ee6b2add52e8b2aff0385c2200b"
github "LoopKit/dexcom-share-client-swift" "b0419edf55c7f389b36cb47dd5c376bbd3d03d69"
github "LoopKit/CGMBLEKit" "76c14b44fd40421c6238a9e00cb5ca66b50dbc2e"
github "LoopKit/G4ShareSpy" "af2a6dd2f8a468d3864f3c6cd27519a7b694cc04"
github "LoopKit/LoopKit" "ca1123d01bcad6061fcaf26a0ffe72829f234e65"
github "LoopKit/dexcom-share-client-swift" "3eb7e2c08335a9ad5bafb9b1e0fad1eab7e53f65"
github "i-schuetz/SwiftCharts" "0.6.5"
github "maxkonovalov/MKRingProgressView" "2.2.1"
github "ps2/rileylink_ios" "e0dc72050510fb8bf7fc85f655b8d24dc4de0097"
github "maxkonovalov/MKRingProgressView" "2.2.2"
github "ps2/rileylink_ios" "f1577d71371202c2ae1e6a240473946f603caa06"
2 changes: 2 additions & 0 deletions Common/Models/PumpManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import Foundation
import LoopKit
import MinimedKit
import OmniKit
import MockKit


let allPumpManagers: [PumpManager.Type] = [
OmnipodPumpManager.self,
MinimedPumpManager.self,
MockPumpManager.self,
]
Expand Down
27 changes: 27 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@
898ECA69218ABDA9001E9D35 /* CLKTextProvider+Compound.m in Sources */ = {isa = PBXBuildFile; fileRef = 898ECA67218ABDA8001E9D35 /* CLKTextProvider+Compound.m */; };
C10428971D17BAD400DD539A /* NightscoutUploadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */; };
C10B28461EA9BA5E006EA1FC /* far_future_high_bg_forecast.json in Resources */ = {isa = PBXBuildFile; fileRef = C10B28451EA9BA5E006EA1FC /* far_future_high_bg_forecast.json */; };
C110A0E7221BC2400016560B /* OmniKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C7F1BF220D675700689850 /* OmniKit.framework */; };
C110A0E8221BC2430016560B /* OmniKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C7F1C0220D675700689850 /* OmniKitUI.framework */; };
C11C87DE1E21EAAD00BB71D3 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; };
C12F21A71DFA79CB00748193 /* recommend_temp_basal_very_low_end_in_range.json in Resources */ = {isa = PBXBuildFile; fileRef = C12F21A61DFA79CB00748193 /* recommend_temp_basal_very_low_end_in_range.json */; };
C13255D6223E7BE2008AF50C /* BolusProgressTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C1F8B1DB223862D500DD66CF /* BolusProgressTableViewCell.xib */; };
Expand All @@ -354,6 +356,8 @@
C1C0BE2A224C0FA000C03B4D /* SwiftCharts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4346D1EF1C781BEA00ABAFE3 /* SwiftCharts.framework */; };
C1C6591C1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json in Resources */ = {isa = PBXBuildFile; fileRef = C1C6591B1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json */; };
C1C73F0D1DE3D0270022FC89 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C1C73F0F1DE3D0270022FC89 /* InfoPlist.strings */; };
C1C7F1C1220D675800689850 /* OmniKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C7F1BF220D675700689850 /* OmniKit.framework */; };
C1C7F1C2220D675800689850 /* OmniKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C7F1C0220D675700689850 /* OmniKitUI.framework */; };
C1E2773E224177C000354103 /* ClockKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E2773D224177C000354103 /* ClockKit.framework */; };
C1E2774822433D7A00354103 /* MKRingProgressView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E2774722433D7A00354103 /* MKRingProgressView.framework */; };
C1F8B243223E73FD00DD66CF /* BolusProgressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1F8B1D122375E4200DD66CF /* BolusProgressTableViewCell.swift */; };
Expand Down Expand Up @@ -483,6 +487,13 @@
remoteGlobalIDString = 4F75288A1DFE1DC600C322D6;
remoteInfo = LoopUI;
};
C110A0E9221BC29B0016560B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 43776F841B8022E90074EA36 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 432CF87720D8B8380066B889;
remoteInfo = Cartfile;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -999,6 +1010,8 @@
C18C8C501D5A351900E043FB /* NightscoutDataManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightscoutDataManager.swift; sourceTree = "<group>"; };
C1C108C22152F46D00EA5165 /* CGMBLEKitUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CGMBLEKitUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C1C6591B1E1B1FDA0025CC58 /* recommend_temp_basal_dropping_then_rising.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = recommend_temp_basal_dropping_then_rising.json; sourceTree = "<group>"; };
C1C7F1BF220D675700689850 /* OmniKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OmniKit.framework; path = Carthage/Build/iOS/OmniKit.framework; sourceTree = "<group>"; };
C1C7F1C0220D675700689850 /* OmniKitUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OmniKitUI.framework; path = Carthage/Build/iOS/OmniKitUI.framework; sourceTree = "<group>"; };
C1E2773D224177C000354103 /* ClockKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ClockKit.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS5.1.sdk/System/Library/Frameworks/ClockKit.framework; sourceTree = DEVELOPER_DIR; };
C1E2774722433D7A00354103 /* MKRingProgressView.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MKRingProgressView.framework; path = Carthage/Build/iOS/MKRingProgressView.framework; sourceTree = "<group>"; };
C1F8B1D122375E4200DD66CF /* BolusProgressTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusProgressTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1026,6 +1039,7 @@
892A5D2C222EF60A008961AB /* MockKitUI.framework in Frameworks */,
4F7528941DFE1E9500C322D6 /* LoopUI.framework in Frameworks */,
434FB6461D68F1CD007B9C70 /* Amplitude.framework in Frameworks */,
C1C7F1C1220D675800689850 /* OmniKit.framework in Frameworks */,
43A8EC6F210E622700A81379 /* CGMBLEKitUI.framework in Frameworks */,
438A95A81D8B9B24009D12E1 /* CGMBLEKit.framework in Frameworks */,
43C246A81D89990F0031F8D1 /* Crypto.framework in Frameworks */,
Expand All @@ -1035,6 +1049,7 @@
437AFEE7203688CF008C4892 /* LoopKitUI.framework in Frameworks */,
43CA93371CB98079000026B5 /* MinimedKit.framework in Frameworks */,
43709AEA20DF3F8200F941B3 /* MinimedKitUI.framework in Frameworks */,
C1C7F1C2220D675800689850 /* OmniKitUI.framework in Frameworks */,
C10428971D17BAD400DD539A /* NightscoutUploadKit.framework in Frameworks */,
437AFEE42035252A008C4892 /* RileyLinkBLEKit.framework in Frameworks */,
43523EDB1CC35083001850F1 /* RileyLinkKit.framework in Frameworks */,
Expand Down Expand Up @@ -1115,6 +1130,8 @@
C1C0BE2A224C0FA000C03B4D /* SwiftCharts.framework in Frameworks */,
4F7528951DFE1E9B00C322D6 /* LoopUI.framework in Frameworks */,
437AFEE520352591008C4892 /* NotificationCenter.framework in Frameworks */,
C110A0E7221BC2400016560B /* OmniKit.framework in Frameworks */,
C110A0E8221BC2430016560B /* OmniKitUI.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1695,6 +1712,8 @@
968DCD53F724DE56FFE51920 /* Frameworks */ = {
isa = PBXGroup;
children = (
C1C7F1BF220D675700689850 /* OmniKit.framework */,
C1C7F1C0220D675700689850 /* OmniKitUI.framework */,
C1E2773D224177C000354103 /* ClockKit.framework */,
C1E2774722433D7A00354103 /* MKRingProgressView.framework */,
892A5D5A222F0D7C008961AB /* LoopTestingKit.framework */,
Expand Down Expand Up @@ -1931,6 +1950,7 @@
buildRules = (
);
dependencies = (
C110A0EA221BC29B0016560B /* PBXTargetDependency */,
43D9000D21EB0BEA00AF44BF /* PBXTargetDependency */,
4F7528991DFE1ED800C322D6 /* PBXTargetDependency */,
);
Expand Down Expand Up @@ -2295,6 +2315,8 @@
"$(SRCROOT)/Carthage/Build/iOS/MinimedKitUI.framework",
"$(SRCROOT)/Carthage/Build/iOS/CGMBLEKitUI.framework",
"$(SRCROOT)/Carthage/Build/iOS/ShareClientUI.framework",
"$(SRCROOT)/Carthage/Build/iOS/OmniKit.framework",
"$(SRCROOT)/Carthage/Build/iOS/OmniKitUI.framework",
"$(SRCROOT)/Carthage/Build/iOS/LoopTestingKit.framework",
"$(SRCROOT)/Carthage/Build/iOS/MockKit.framework",
"$(SRCROOT)/Carthage/Build/iOS/MockKitUI.framework",
Expand Down Expand Up @@ -2718,6 +2740,11 @@
target = 4F75288A1DFE1DC600C322D6 /* LoopUI */;
targetProxy = 4F7528981DFE1ED800C322D6 /* PBXContainerItemProxy */;
};
C110A0EA221BC29B0016560B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 432CF87720D8B8380066B889 /* Cartfile */;
targetProxy = C110A0E9221BC29B0016560B /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down
34 changes: 33 additions & 1 deletion Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LoopKit
import LoopKitUI
import LoopCore
import LoopTestingKit

import UserNotifications

final class DeviceDataManager {

Expand Down Expand Up @@ -68,6 +68,8 @@ final class DeviceDataManager {
}
}

private var lastBLEDrivenUpdate = Date.distantPast

private let lockedPumpManagerStatus: Locked<PumpManagerStatus?> = Locked(nil)

static let batteryReplacementDetectionThreshold = 0.5
Expand Down Expand Up @@ -176,6 +178,29 @@ extension DeviceDataManager: RemoteDataManagerDelegate {
}
}

// MARK: - DeviceManagerDelegate
extension DeviceDataManager: DeviceManagerDelegate {
func scheduleNotification(for manager: DeviceManager,
identifier: String,
content: UNNotificationContent,
trigger: UNNotificationTrigger?) {
let request = UNNotificationRequest(
identifier: identifier,
content: content,
trigger: trigger
)

DispatchQueue.main.async {
UNUserNotificationCenter.current().add(request)
}
}

func clearNotification(for manager: DeviceManager, identifier: String) {
DispatchQueue.main.async {
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [identifier])
}
}
}

// MARK: - CGMManagerDelegate
extension DeviceDataManager: CGMManagerDelegate {
Expand Down Expand Up @@ -243,6 +268,13 @@ extension DeviceDataManager: PumpManagerDelegate {
func pumpManagerBLEHeartbeatDidFire(_ pumpManager: PumpManager) {
log.default("PumpManager:\(type(of: pumpManager)) did fire BLE heartbeat")

let bleHeartbeatUpdateInterval = TimeInterval(minutes: 4.5)
guard lastBLEDrivenUpdate.timeIntervalSinceNow < -bleHeartbeatUpdateInterval else {
log.default("Skipping ble heartbeat")
return
}
lastBLEDrivenUpdate = Date()

cgmManager?.fetchNewDataIfNeeded { (result) in
if case .newData = result {
AnalyticsManager.shared.didFetchNewCGMData()
Expand Down
11 changes: 10 additions & 1 deletion Loop/Managers/NightscoutDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,23 @@ final class NightscoutDataManager {
bolusing = false
}

let currentReservoirUnits: Double?
if let lastReservoirValue = deviceManager.loopManager.doseStore.lastReservoirValue, lastReservoirValue.startDate > Date().addingTimeInterval(.minutes(-15)) {
currentReservoirUnits = lastReservoirValue.unitVolume
} else {
currentReservoirUnits = nil
}

pumpStatus = NightscoutUploadKit.PumpStatus(
clock: Date(),
pumpID: pumpManagerStatus.device.localIdentifier ?? "Unknown",
manufacturer: pumpManagerStatus.device.manufacturer,
model: pumpManagerStatus.device.model,
iob: nil,
battery: battery,
suspended: pumpManagerStatus.basalDeliveryState == .suspended,
bolusing: bolusing,
reservoir: deviceManager.loopManager.doseStore.lastReservoirValue?.unitVolume,
reservoir: currentReservoirUnits,
secondsFromGMT: pumpManagerStatus.timeZone.secondsFromGMT())
} else {
pumpStatus = nil
Expand Down
38 changes: 15 additions & 23 deletions Loop/Managers/NotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ import UIKit
import UserNotifications
import LoopKit


struct NotificationManager {
enum Category: String {
case bolusFailure
case loopNotRunning
case pumpBatteryLow
case pumpReservoirEmpty
case pumpReservoirLow
}

enum Action: String {
case retryBolus
Expand All @@ -39,7 +31,7 @@ struct NotificationManager {
)

categories.append(UNNotificationCategory(
identifier: Category.bolusFailure.rawValue,
identifier: LoopNotificationCategory.bolusFailure.rawValue,
actions: [retryBolusAction],
intentIdentifiers: [],
options: []
Expand Down Expand Up @@ -89,7 +81,7 @@ struct NotificationManager {
notification.sound = UNNotificationSound.default()

if startDate.timeIntervalSinceNow >= TimeInterval(minutes: -5) {
notification.categoryIdentifier = Category.bolusFailure.rawValue
notification.categoryIdentifier = LoopNotificationCategory.bolusFailure.rawValue
}

notification.userInfo = [
Expand All @@ -99,7 +91,7 @@ struct NotificationManager {

let request = UNNotificationRequest(
// Only support 1 bolus notification at once
identifier: Category.bolusFailure.rawValue,
identifier: LoopNotificationCategory.bolusFailure.rawValue,
content: notification,
trigger: nil
)
Expand Down Expand Up @@ -131,11 +123,11 @@ struct NotificationManager {

notification.title = NSLocalizedString("Loop Failure", comment: "The notification title for a loop failure")
notification.sound = UNNotificationSound.default()
notification.categoryIdentifier = Category.loopNotRunning.rawValue
notification.threadIdentifier = Category.loopNotRunning.rawValue
notification.categoryIdentifier = LoopNotificationCategory.loopNotRunning.rawValue
notification.threadIdentifier = LoopNotificationCategory.loopNotRunning.rawValue

let request = UNNotificationRequest(
identifier: "\(Category.loopNotRunning.rawValue)\(failureInterval)",
identifier: "\(LoopNotificationCategory.loopNotRunning.rawValue)\(failureInterval)",
content: notification,
trigger: UNTimeIntervalNotificationTrigger(
timeInterval: failureInterval + gracePeriod,
Expand All @@ -151,7 +143,7 @@ struct NotificationManager {
// Clear out any existing not-running notifications
UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
let loopNotRunningIdentifiers = notifications.filter({
$0.request.content.categoryIdentifier == Category.loopNotRunning.rawValue
$0.request.content.categoryIdentifier == LoopNotificationCategory.loopNotRunning.rawValue
}).map({
$0.request.identifier
})
Expand All @@ -166,10 +158,10 @@ struct NotificationManager {
notification.title = NSLocalizedString("Pump Battery Low", comment: "The notification title for a low pump battery")
notification.body = NSLocalizedString("Change the pump battery immediately", comment: "The notification alert describing a low pump battery")
notification.sound = UNNotificationSound.default()
notification.categoryIdentifier = Category.pumpBatteryLow.rawValue
notification.categoryIdentifier = LoopNotificationCategory.pumpBatteryLow.rawValue

let request = UNNotificationRequest(
identifier: Category.pumpBatteryLow.rawValue,
identifier: LoopNotificationCategory.pumpBatteryLow.rawValue,
content: notification,
trigger: nil
)
Expand All @@ -178,7 +170,7 @@ struct NotificationManager {
}

static func clearPumpBatteryLowNotification() {
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [Category.pumpBatteryLow.rawValue])
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [LoopNotificationCategory.pumpBatteryLow.rawValue])
}

static func sendPumpReservoirEmptyNotification() {
Expand All @@ -187,11 +179,11 @@ struct NotificationManager {
notification.title = NSLocalizedString("Pump Reservoir Empty", comment: "The notification title for an empty pump reservoir")
notification.body = NSLocalizedString("Change the pump reservoir now", comment: "The notification alert describing an empty pump reservoir")
notification.sound = UNNotificationSound.default()
notification.categoryIdentifier = Category.pumpReservoirEmpty.rawValue
notification.categoryIdentifier = LoopNotificationCategory.pumpReservoirEmpty.rawValue

let request = UNNotificationRequest(
// Not a typo: this should replace any pump reservoir low notifications
identifier: Category.pumpReservoirLow.rawValue,
identifier: LoopNotificationCategory.pumpReservoirLow.rawValue,
content: notification,
trigger: nil
)
Expand Down Expand Up @@ -220,10 +212,10 @@ struct NotificationManager {
}

notification.sound = UNNotificationSound.default()
notification.categoryIdentifier = Category.pumpReservoirLow.rawValue
notification.categoryIdentifier = LoopNotificationCategory.pumpReservoirLow.rawValue

let request = UNNotificationRequest(
identifier: Category.pumpReservoirLow.rawValue,
identifier: LoopNotificationCategory.pumpReservoirLow.rawValue,
content: notification,
trigger: nil
)
Expand All @@ -232,6 +224,6 @@ struct NotificationManager {
}

static func clearPumpReservoirNotification() {
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [Category.pumpReservoirLow.rawValue])
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [LoopNotificationCategory.pumpReservoirLow.rawValue])
}
}
Loading