Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@
A9C62D882331703100535612 /* Service.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C62D852331703000535612 /* Service.swift */; };
A9C62D892331703100535612 /* LoggingServicesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C62D862331703000535612 /* LoggingServicesManager.swift */; };
A9C62D8A2331703100535612 /* ServicesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C62D872331703000535612 /* ServicesManager.swift */; };
AC87CACC45C01E5FC5B62A08 /* RemoteCommandGuard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C633B93FCDD95990EF512A6 /* RemoteCommandGuard.swift */; };
A9C62D8E2331708700535612 /* AuthenticationTableViewCell+NibLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C62D8D2331708700535612 /* AuthenticationTableViewCell+NibLoadable.swift */; };
A9CBE458248AB564008E7BA2 /* DoseStore+SimulatedCoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CBE457248AB564008E7BA2 /* DoseStore+SimulatedCoreData.swift */; };
A9CBE45A248ACBE1008E7BA2 /* DosingDecisionStore+SimulatedCoreData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CBE459248ACBE1008E7BA2 /* DosingDecisionStore+SimulatedCoreData.swift */; };
Expand Down Expand Up @@ -548,6 +549,7 @@
C1275E1C2E82269A0013B99D /* LoopKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C1275E1A2E82269A0013B99D /* LoopKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C1275E1F2E822CEE0013B99D /* DerivedAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A966152923EA5A37005D8B29 /* DerivedAssets.xcassets */; };
C129BF4A2B2791EE00DF15CB /* TemporaryPresetsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C129BF492B2791EE00DF15CB /* TemporaryPresetsManagerTests.swift */; };
D9E8D6887773403C8FD4AD37 /* RemoteCommandGuardTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E343B6C171D669C639F11F8B /* RemoteCommandGuardTests.swift */; };
C129D3BF2B8697F100FEA6A9 /* TempBasalRecommendationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C129D3BE2B8697F100FEA6A9 /* TempBasalRecommendationTests.swift */; };
C12D72402E4FBC5F00BD628A /* WatchActionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12D723F2E4FBC5D00BD628A /* WatchActionsView.swift */; };
D7A3000100000000000A0006 /* WatchSensorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7A3000100000000000A0005 /* WatchSensorView.swift */; };
Expand Down Expand Up @@ -1292,6 +1294,7 @@
A9C62D852331703000535612 /* Service.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Service.swift; sourceTree = "<group>"; };
A9C62D862331703000535612 /* LoggingServicesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggingServicesManager.swift; sourceTree = "<group>"; };
A9C62D872331703000535612 /* ServicesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServicesManager.swift; sourceTree = "<group>"; };
6C633B93FCDD95990EF512A6 /* RemoteCommandGuard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteCommandGuard.swift; sourceTree = "<group>"; };
A9C62D8D2331708700535612 /* AuthenticationTableViewCell+NibLoadable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AuthenticationTableViewCell+NibLoadable.swift"; sourceTree = "<group>"; };
A9CBE457248AB564008E7BA2 /* DoseStore+SimulatedCoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DoseStore+SimulatedCoreData.swift"; sourceTree = "<group>"; };
A9CBE459248ACBE1008E7BA2 /* DosingDecisionStore+SimulatedCoreData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DosingDecisionStore+SimulatedCoreData.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1405,6 +1408,7 @@
C1275E1A2E82269A0013B99D /* LoopKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LoopKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C1275E1D2E8227260013B99D /* LoopKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LoopKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C129BF492B2791EE00DF15CB /* TemporaryPresetsManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryPresetsManagerTests.swift; sourceTree = "<group>"; };
E343B6C171D669C639F11F8B /* RemoteCommandGuardTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteCommandGuardTests.swift; sourceTree = "<group>"; };
C129D3BE2B8697F100FEA6A9 /* TempBasalRecommendationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TempBasalRecommendationTests.swift; sourceTree = "<group>"; };
C12CB9AC23106A3C00F84978 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Intents.strings; sourceTree = "<group>"; };
C12CB9AE23106A5C00F84978 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Intents.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1835,6 +1839,7 @@
1D70C40026EC0F9D00C62570 /* SupportManagerTests.swift */,
A7E1C0B12F8A4D2E00C0FFEE /* AnalyticsServicesManagerTests.swift */,
C129BF492B2791EE00DF15CB /* TemporaryPresetsManagerTests.swift */,
E343B6C171D669C639F11F8B /* RemoteCommandGuardTests.swift */,
A9F5F1F4251050EC00E7C8A4 /* ZipArchiveTests.swift */,
);
path = Managers;
Expand Down Expand Up @@ -2306,6 +2311,7 @@
7E69CFFB2A16A77E00203CBD /* ResetLoopManager.swift */,
A9C62D852331703000535612 /* Service.swift */,
A9C62D872331703000535612 /* ServicesManager.swift */,
6C633B93FCDD95990EF512A6 /* RemoteCommandGuard.swift */,
C1F7822527CC056900C0919A /* SettingsManager.swift */,
A96DAC2B2838F31200D94E38 /* SharedLogging.swift */,
E9BB27AA23B85C3500FB4987 /* SleepStore.swift */,
Expand Down Expand Up @@ -3792,6 +3798,7 @@
A96DAC242838325900D94E38 /* DiagnosticLog.swift in Sources */,
A9CBE45A248ACBE1008E7BA2 /* DosingDecisionStore+SimulatedCoreData.swift in Sources */,
A9C62D8A2331703100535612 /* ServicesManager.swift in Sources */,
AC87CACC45C01E5FC5B62A08 /* RemoteCommandGuard.swift in Sources */,
43DBF0531C93EC8200B3C386 /* DeviceDataManager.swift in Sources */,
A9347F2F24E7508A00C99C34 /* WatchHistoricalCarbs.swift in Sources */,
C10509792D8B636900118A37 /* Environment+TemporaryPresetsManager.swift in Sources */,
Expand Down Expand Up @@ -4239,6 +4246,7 @@
A96DAC2A2838EF8A00D94E38 /* DiagnosticLogTests.swift in Sources */,
A9DAE7D02332D77F006AE942 /* LoopTests.swift in Sources */,
C129BF4A2B2791EE00DF15CB /* TemporaryPresetsManagerTests.swift in Sources */,
D9E8D6887773403C8FD4AD37 /* RemoteCommandGuardTests.swift in Sources */,
E93E86B024DDE1BD00FF40C8 /* MockGlucoseStore.swift in Sources */,
C18859A82AF292D90010F21F /* MockTrustedTimeChecker.swift in Sources */,
C129D3BF2B8697F100FEA6A9 /* TempBasalRecommendationTests.swift in Sources */,
Expand Down
21 changes: 21 additions & 0 deletions Loop/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@
},
" -" : {

},
"Bolus may have been delivered. Check the history before sending another bolus." : {
"comment" : "Remote bolus error description: the pump did not confirm whether the bolus was delivered."
},
"Command rejected: %1$@ U of insulin has not been uploaded to Nightscout yet." : {
"comment" : "Remote bolus error description: insulin not yet uploaded. (1: units of insulin)"
},
"Command rejected: %1$@ U of insulin was delivered after the command was sent (or after the newest treatment you had seen)." : {
"comment" : "Remote bolus error description: insulin the sender had not seen. (1: units of insulin)"
},
"Command rejected: %1$d carb entries totaling %2$@ g were recorded that you had not seen." : {
"comment" : "Remote carb error description: several carb entries the sender had not seen. (1: number of entries, 2: total grams of carbs)"
},
"Command rejected: a carb entry of %1$@ g was recorded that you had not seen." : {
"comment" : "Remote carb error description: one carb entry the sender had not seen. (1: grams of carbs)"
},
"Command rejected: treatment history is not available." : {
"comment" : "Remote command error description: treatment history could not be checked."
},
"Loop is not ready to deliver remote commands" : {
"comment" : "Remote command error description: the component that delivers remote boluses and carbs is not available."
},
" - " : {

Expand Down
11 changes: 10 additions & 1 deletion Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -828,18 +828,27 @@ extension DeviceDataManager {
metadata.activationType = activationType
let doseId = await newDoseId(for: metadata)

// A remote command reports the pump's error to its sender and sends its own failure notification
let rethrowsErrors = metadata.origin == .remote

do {
try await pumpManager.enactBolus(doseId: doseId, units: units, activationType: activationType)
} catch PumpManagerError.uncertainDelivery {
// Do not generate notification on uncertain delivery error
if rethrowsErrors {
throw PumpManagerError.uncertainDelivery
}
} catch {
if !activationType.isAutomatic, let error = error as? PumpManagerError {
if !activationType.isAutomatic, !rethrowsErrors, let error = error as? PumpManagerError {
do {
try await NotificationManager.sendBolusFailureNotification(for: error, units: units, at: Date(), decisionId: metadata.decisionId, activationType: activationType)
} catch {
log.error("Error sending bolus failure notification %{public}@", String(describing: error))
}
}
if rethrowsErrors {
throw error
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions Loop/Managers/LoopAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ class LoopAppManager: NSObject {
servicesManagerDelegate: loopDataManager,
servicesManagerDosingDelegate: self
)
servicesManager.remoteCommandGate.treatmentSource = self

statefulPluginManager = StatefulPluginManager(pluginManager: pluginManager, servicesManager: servicesManager)

Expand Down Expand Up @@ -1104,6 +1105,29 @@ extension LoopAppManager: ServicesManagerDosingDelegate {
}
}

// MARK: - RemoteCommandTreatmentSource

extension LoopAppManager: RemoteCommandTreatmentSource {
func bolusHistory(since start: Date) async throws -> [DoseEntry] {
try await doseStore.getBoluses(start: start)
}

var bolusInProgress: DoseEntry? {
guard case .inProgress(let dose) = deviceDataManager?.bolusState else {
return nil
}
return dose
}

func carbEntries(since start: Date) async throws -> [StoredCarbEntry] {
try await carbStore.getCarbEntries(start: start)
}

func roundToSupportedBolusVolume(units: Double) -> Double {
deviceDataManager?.pumpManager?.roundToSupportedBolusVolume(units: units) ?? units
}
}

protocol DiagnosticReportGenerator: AnyObject {
func generateDiagnosticReport() async -> String
}
Expand Down
Loading