Skip to content

Remote PR Set #3 #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
36 changes: 4 additions & 32 deletions LoopKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,6 @@
A933DB8924BF97CC009B417A /* CriticalEventLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = A933DB8724BF956F009B417A /* CriticalEventLog.swift */; };
A935094426E2FAB70030B60D /* GlucoseCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935094326E2FAB70030B60D /* GlucoseCondition.swift */; };
A935094526E2FAB70030B60D /* GlucoseCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935094326E2FAB70030B60D /* GlucoseCondition.swift */; };
A935793B29A2570400246DED /* CarbAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935793629A2570300246DED /* CarbAction.swift */; };
A935793C29A2570400246DED /* OverrideCancelAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935793729A2570300246DED /* OverrideCancelAction.swift */; };
A935793D29A2570400246DED /* OverrideAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935793829A2570400246DED /* OverrideAction.swift */; };
A935793E29A2570400246DED /* BolusAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935793929A2570400246DED /* BolusAction.swift */; };
A935793F29A2570400246DED /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = A935793A29A2570400246DED /* Action.swift */; };
A93761C125ED670200F6BE43 /* BluetoothProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93761C025ED670200F6BE43 /* BluetoothProvider.swift */; };
A93761C225ED670200F6BE43 /* BluetoothProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93761C025ED670200F6BE43 /* BluetoothProvider.swift */; };
A93CA899278D08CC003B5A01 /* PumpAlarmType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93CA898278D08CC003B5A01 /* PumpAlarmType.swift */; };
Expand Down Expand Up @@ -514,11 +509,11 @@
A985465125144ABA0099C1A6 /* NotificationSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A985465025144ABA0099C1A6 /* NotificationSettingsTests.swift */; };
A987CD4624A5893500439ADC /* JSONStreamEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A987CD4524A5893500439ADC /* JSONStreamEncoder.swift */; };
A987CD4724A5893500439ADC /* JSONStreamEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A987CD4524A5893500439ADC /* JSONStreamEncoder.swift */; };
A98A0C4729C78A270067DE0F /* RemoteActionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98A0C4629C78A270067DE0F /* RemoteActionDelegate.swift */; };
A98ED5FB25312E3200FD8F70 /* HKObserverQueryMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1E7035E25001EA500DAB534 /* HKObserverQueryMock.swift */; };
A98ED5FC25312ED100FD8F70 /* HKAnchoredObjectQueryMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1E703612500390B00DAB534 /* HKAnchoredObjectQueryMock.swift */; };
A98ED5FE253132A400FD8F70 /* CarbStoreHKQueryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98ED5FD253132A400FD8F70 /* CarbStoreHKQueryTests.swift */; };
A994B884254241B10039B108 /* InsulinDeliveryStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A994B883254241B10039B108 /* InsulinDeliveryStoreTests.swift */; };
A99A116229AA2C2B007919CE /* RemoteCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99A116129AA2C2A007919CE /* RemoteCommand.swift */; };
A99C7373233990D400C80963 /* TempBasalRecommendationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99C7372233990D400C80963 /* TempBasalRecommendationTests.swift */; };
A99C73772339A67A00C80963 /* GlucoseThresholdTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99C73762339A67A00C80963 /* GlucoseThresholdTests.swift */; };
A99C73792339ACDC00C80963 /* ServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A99C73782339ACDC00C80963 /* ServiceTests.swift */; };
Expand Down Expand Up @@ -1476,11 +1471,6 @@
A932803A2798D63B0091D0A1 /* SyncAlertObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncAlertObject.swift; sourceTree = "<group>"; };
A933DB8724BF956F009B417A /* CriticalEventLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CriticalEventLog.swift; sourceTree = "<group>"; };
A935094326E2FAB70030B60D /* GlucoseCondition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseCondition.swift; sourceTree = "<group>"; };
A935793629A2570300246DED /* CarbAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CarbAction.swift; sourceTree = "<group>"; };
A935793729A2570300246DED /* OverrideCancelAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverrideCancelAction.swift; sourceTree = "<group>"; };
A935793829A2570400246DED /* OverrideAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverrideAction.swift; sourceTree = "<group>"; };
A935793929A2570400246DED /* BolusAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BolusAction.swift; sourceTree = "<group>"; };
A935793A29A2570400246DED /* Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Action.swift; sourceTree = "<group>"; };
A93761C025ED670200F6BE43 /* BluetoothProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BluetoothProvider.swift; sourceTree = "<group>"; };
A93CA898278D08CC003B5A01 /* PumpAlarmType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PumpAlarmType.swift; sourceTree = "<group>"; };
A9498D6E23386C0B00DAA9B9 /* TempBasalRecommendation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TempBasalRecommendation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1512,9 +1502,9 @@
A985464E251449FE0099C1A6 /* NotificationSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettings.swift; sourceTree = "<group>"; };
A985465025144ABA0099C1A6 /* NotificationSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationSettingsTests.swift; sourceTree = "<group>"; };
A987CD4524A5893500439ADC /* JSONStreamEncoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONStreamEncoder.swift; sourceTree = "<group>"; };
A98A0C4629C78A270067DE0F /* RemoteActionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteActionDelegate.swift; sourceTree = "<group>"; };
A98ED5FD253132A400FD8F70 /* CarbStoreHKQueryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbStoreHKQueryTests.swift; sourceTree = "<group>"; };
A994B883254241B10039B108 /* InsulinDeliveryStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryStoreTests.swift; sourceTree = "<group>"; };
A99A116129AA2C2A007919CE /* RemoteCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteCommand.swift; sourceTree = "<group>"; };
A99C7372233990D400C80963 /* TempBasalRecommendationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TempBasalRecommendationTests.swift; sourceTree = "<group>"; };
A99C73762339A67A00C80963 /* GlucoseThresholdTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseThresholdTests.swift; sourceTree = "<group>"; };
A99C73782339ACDC00C80963 /* ServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2898,23 +2888,10 @@
path = "View Controllers";
sourceTree = "<group>";
};
A935793529A256F800246DED /* Actions */ = {
isa = PBXGroup;
children = (
A935793A29A2570400246DED /* Action.swift */,
A935793929A2570400246DED /* BolusAction.swift */,
A935793629A2570300246DED /* CarbAction.swift */,
A935793829A2570400246DED /* OverrideAction.swift */,
A935793729A2570300246DED /* OverrideCancelAction.swift */,
);
path = Actions;
sourceTree = "<group>";
};
A98FF28F29A25699005739A5 /* Remote */ = {
isa = PBXGroup;
children = (
A935793529A256F800246DED /* Actions */,
A99A116129AA2C2A007919CE /* RemoteCommand.swift */,
A98A0C4629C78A270067DE0F /* RemoteActionDelegate.swift */,
);
path = Remote;
sourceTree = "<group>";
Expand Down Expand Up @@ -4018,7 +3995,6 @@
437AFEED2036A156008C4892 /* CachedCarbObject+CoreDataClass.swift in Sources */,
43D8FDF71C7290350073BE78 /* DailyValueSchedule.swift in Sources */,
4322B77D202FA2AF0002837D /* NewPumpEvent.swift in Sources */,
A935793F29A2570400246DED /* Action.swift in Sources */,
C1B8E6E52A1BB14E00AF38D0 /* HealthKitSampleStore.swift in Sources */,
434113AA20F171CB00D05747 /* CachedInsulinDeliveryObject+CoreDataClass.swift in Sources */,
C140DFFF260276BF000A4FF7 /* ManualBolusRecommendation.swift in Sources */,
Expand All @@ -4032,7 +4008,6 @@
43D8FDF51C7290350073BE78 /* CarbRatioSchedule.swift in Sources */,
4322B76F202FA26F0002837D /* GlucoseSampleValue.swift in Sources */,
89AE222C228BC66E00BDFD85 /* Locked.swift in Sources */,
A935793C29A2570400246DED /* OverrideCancelAction.swift in Sources */,
432CF87120D76D5A0066B889 /* GlucoseDisplayable.swift in Sources */,
A919889F2355016B00B75EEE /* DosingDecisionStore.swift in Sources */,
A9BD318224F4548900994B83 /* Modelv3EntityMigrationPolicy.swift in Sources */,
Expand All @@ -4054,7 +4029,6 @@
43D9888B1C87E47800DA4467 /* GlucoseValue.swift in Sources */,
A967D94924F99B6A00CDDF8A /* DataOutputStream.swift in Sources */,
43D8FDF41C7290350073BE78 /* BasalRateSchedule.swift in Sources */,
A935793B29A2570400246DED /* CarbAction.swift in Sources */,
4322B788202FA2B30002837D /* DoseStore.swift in Sources */,
A9498D6F23386C0B00DAA9B9 /* TempBasalRecommendation.swift in Sources */,
C187338E29B9486200519CDF /* ClosedRange.swift in Sources */,
Expand All @@ -4064,7 +4038,6 @@
C187338F29B9486200519CDF /* NumberFormatter.swift in Sources */,
4322B785202FA2AF0002837D /* ReservoirValue.swift in Sources */,
891A3FD9224BEB4600378B27 /* EGPSchedule.swift in Sources */,
A935793D29A2570400246DED /* OverrideAction.swift in Sources */,
89AE2229228BC54C00BDFD85 /* TemporaryScheduleOverrideHistory.swift in Sources */,
C187338B29B9486200519CDF /* Comparable.swift in Sources */,
437AFF24203BE402008C4892 /* HKHealthStore.swift in Sources */,
Expand Down Expand Up @@ -4144,11 +4117,10 @@
4322B780202FA2AF0002837D /* PumpEvent+CoreDataClass.swift in Sources */,
89AE2227228BC54C00BDFD85 /* TemporaryScheduleOverride.swift in Sources */,
4322B784202FA2AF0002837D /* Reservoir+CoreDataProperties.swift in Sources */,
A99A116229AA2C2B007919CE /* RemoteCommand.swift in Sources */,
4322B778202FA2790002837D /* HKQuantitySample+CarbKit.swift in Sources */,
4322B771202FA26F0002837D /* HKQuantitySample+GlucoseKit.swift in Sources */,
433BC7AB20538D4C000B1200 /* CachedGlucoseObject+CoreDataProperties.swift in Sources */,
A935793E29A2570400246DED /* BolusAction.swift in Sources */,
A98A0C4729C78A270067DE0F /* RemoteActionDelegate.swift in Sources */,
C187339929B9488300519CDF /* TimeZone.swift in Sources */,
C187339329B9486200519CDF /* OSLog.swift in Sources */,
43FB610720DDF19B002B996B /* PumpManagerError.swift in Sources */,
Expand Down
1 change: 0 additions & 1 deletion LoopKit/Notification/LoopNotificationCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public enum LoopNotificationCategory: String {
case alert
case remoteBolus
case remoteBolusFailure
case remoteCommandExpired
case remoteCarbs
case remoteCarbsFailure
case missedMeal
Expand Down
16 changes: 0 additions & 16 deletions LoopKit/Service/Remote/Actions/Action.swift

This file was deleted.

18 changes: 0 additions & 18 deletions LoopKit/Service/Remote/Actions/BolusAction.swift

This file was deleted.

24 changes: 0 additions & 24 deletions LoopKit/Service/Remote/Actions/CarbAction.swift

This file was deleted.

23 changes: 0 additions & 23 deletions LoopKit/Service/Remote/Actions/OverrideAction.swift

This file was deleted.

19 changes: 0 additions & 19 deletions LoopKit/Service/Remote/Actions/OverrideCancelAction.swift

This file was deleted.

16 changes: 16 additions & 0 deletions LoopKit/Service/Remote/RemoteActionDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// RemoteActionDelegate.swift
// LoopKit
//
// Created by Bill Gestrich on 3/19/23.
// Copyright © 2023 LoopKit Authors. All rights reserved.
//

import Foundation

Copy link
Contributor Author

@gestrich gestrich Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RemoteActionDelegate is conformed to both by the ServiceManager and DeviceDataManager to propogate actions to where they are delivered.

I'm using "handleRemote" in the method names to help disambiguate from existing APIs in DeviceDataManaager, like "enactBolus". I can drop the prefix if desired though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, "handle" is very vague. This API is exposing dosing functionality and settings change functionality. So it would be more descriptive to have the verbs describe actually enacting or delivering. I think it's fine to keep the "remote" in there, as that's the main foreseeable use for this API, but an API like this could theoretically be used by Services for other things, like maybe they have some kind of other trigger to change dosing, like a timer, or other notification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done but let me know if feedback on the names below.

public protocol RemoteActionDelegate: AnyObject {
func enactRemoteOverride(name: String, durationTime: TimeInterval?, remoteAddress: String) async throws
func cancelRemoteOverride() async throws
func deliverRemoteCarbs(amountInGrams: Double, absorptionTime: TimeInterval?, foodType: String?, startDate: Date?) async throws
func deliverRemoteBolus(amountInUnits: Double) async throws
}
13 changes: 0 additions & 13 deletions LoopKit/Service/Remote/RemoteCommand.swift

This file was deleted.

5 changes: 2 additions & 3 deletions LoopKit/Service/RemoteDataService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ public protocol RemoteDataService: Service {
func uploadSettingsData(_ stored: [StoredSettings], completion: @escaping (_ result: Result<Bool, Error>) -> Void)

/**
Fetch a RemoteCommand from a push notification
Handle a push notification
- Parameter notification: The push notification dictionary
- Returns: RemoteCommand
*/
func commandFromPushNotification(_ notification: [String: AnyObject]) async throws -> RemoteCommand
func remoteNotificationWasReceived(_ notification: [String: AnyObject]) async throws

}

Expand Down
2 changes: 1 addition & 1 deletion LoopKit/Service/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public protocol PluginHost {
var hostVersion: String { get }
}

public protocol ServiceDelegate: AnyObject, PluginHost, AlertIssuer {
public protocol ServiceDelegate: AnyObject, PluginHost, AlertIssuer, RemoteActionDelegate {
/// Informs the delegate that the state of the specified service was updated and the delegate should persist the service. May
/// be invoked prior to the service completing setup.
///
Expand Down
8 changes: 1 addition & 7 deletions MockKit/MockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ extension MockService: RemoteDataService {
completion(.success(false))
}

public func commandFromPushNotification(_ notification: [String: AnyObject]) async throws -> RemoteCommand {

enum MockServicePushNotificationError: LocalizedError {
case remoteCommandsNotSupported
}

throw MockServicePushNotificationError.remoteCommandsNotSupported
public func remoteNotificationWasReceived(_ notification: [String: AnyObject]) async throws {
}
}