Skip to content
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
21 changes: 17 additions & 4 deletions NightscoutService.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@
C1398D2027C41E3D00416AD6 /* ProfileSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1398D1F27C41E3D00416AD6 /* ProfileSet.swift */; };
C1398D2227C434FB00416AD6 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1398D2127C434FB00416AD6 /* Data.swift */; };
C1B9ACF827DE987400857532 /* OneTimePassword in Frameworks */ = {isa = PBXBuildFile; productRef = C1B9ACF727DE987400857532 /* OneTimePassword */; };
C1B9ACF927DE995C00857532 /* NightscoutUploadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C130B6F727DD4CD000173048 /* NightscoutUploadKit.framework */; };
C1B9ACFC27DE99D600857532 /* NightscoutUploadKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C130B6F727DD4CD000173048 /* NightscoutUploadKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C1C1349627DD35060097B5AD /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C1349527DD35060097B5AD /* LoopKit.framework */; };
C1C1349827DD35260097B5AD /* LoopKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1C1349727DD35260097B5AD /* LoopKitUI.framework */; };
C1C1349D27DD38000097B5AD /* NightscoutServiceKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A91BAC3A22BC69B500ABF1BB /* NightscoutServiceKitUI.framework */; };
C1C1349E27DD38000097B5AD /* NightscoutServiceKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A91BAC3A22BC69B500ABF1BB /* NightscoutServiceKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
C1CEBFF429BCC104007FD8A3 /* NightscoutKit in Frameworks */ = {isa = PBXBuildFile; productRef = C1CEBFF329BCC104007FD8A3 /* NightscoutKit */; };
C1E703642506BE9400DAB534 /* ObjectIdCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1E703632506BE9400DAB534 /* ObjectIdCache.swift */; };
C1E7036625070A0E00DAB534 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C1E7036525070A0E00DAB534 /* Assets.xcassets */; };
C1E7036C25070D3200DAB534 /* ServiceUICoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1E7036B25070D3200DAB534 /* ServiceUICoordinator.swift */; };
Expand Down Expand Up @@ -109,7 +108,6 @@
dstSubfolderSpec = 10;
files = (
C1C1349E27DD38000097B5AD /* NightscoutServiceKitUI.framework in Embed Frameworks */,
C1B9ACFC27DE99D600857532 /* NightscoutUploadKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -217,7 +215,7 @@
files = (
C1C1349827DD35260097B5AD /* LoopKitUI.framework in Frameworks */,
C1C1349627DD35060097B5AD /* LoopKit.framework in Frameworks */,
C1B9ACF927DE995C00857532 /* NightscoutUploadKit.framework in Frameworks */,
C1CEBFF429BCC104007FD8A3 /* NightscoutKit in Frameworks */,
C1B9ACF827DE987400857532 /* OneTimePassword in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -458,6 +456,7 @@
name = NightscoutServiceKit;
packageProductDependencies = (
C1B9ACF727DE987400857532 /* OneTimePassword */,
C1CEBFF329BCC104007FD8A3 /* NightscoutKit */,
);
productName = NightscoutService;
productReference = A91BAC1B22BC691A00ABF1BB /* NightscoutServiceKit.framework */;
Expand Down Expand Up @@ -581,6 +580,7 @@
mainGroup = A91BAC1122BC691A00ABF1BB;
packageReferences = (
C1B9ACF627DE987400857532 /* XCRemoteSwiftPackageReference "OneTimePassword" */,
C1CEBFF229BCC104007FD8A3 /* XCRemoteSwiftPackageReference "NightscoutKit" */,
);
productRefGroup = A91BAC1C22BC691A00ABF1BB /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1263,6 +1263,14 @@
revision = 8e4022f2852d77240d0a17482cbfe325354aac70;
};
};
C1CEBFF229BCC104007FD8A3 /* XCRemoteSwiftPackageReference "NightscoutKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/LoopKit/NightscoutKit";
requirement = {
branch = main;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -1271,6 +1279,11 @@
package = C1B9ACF627DE987400857532 /* XCRemoteSwiftPackageReference "OneTimePassword" */;
productName = OneTimePassword;
};
C1CEBFF329BCC104007FD8A3 /* NightscoutKit */ = {
isa = XCSwiftPackageProductDependency;
package = C1CEBFF229BCC104007FD8A3 /* XCRemoteSwiftPackageReference "NightscoutKit" */;
productName = NightscoutKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = A91BAC1222BC691A00ABF1BB /* Project object */;
Expand Down
2 changes: 1 addition & 1 deletion NightscoutServiceKit/Extensions/DoseEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension DoseEntry {

Expand Down
10 changes: 5 additions & 5 deletions NightscoutServiceKit/Extensions/NightscoutUploader.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//
// NightscoutUploader.swift
// NightscoutClient.swift
// NightscoutServiceKit
//
// Created by Darin Krauss on 6/20/19.
// Copyright © 2019 LoopKit Authors. All rights reserved.
//

import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension NightscoutUploader {
extension NightscoutClient {

func createCarbData(_ data: [SyncCarbObject], completion: @escaping (Result<[String], Error>) -> Void) {
guard !data.isEmpty else {
Expand Down Expand Up @@ -74,7 +74,7 @@ extension NightscoutUploader {

}

extension NightscoutUploader {
extension NightscoutClient {

func uploadGlucoseSamples(_ samples: [StoredGlucoseSample], completion: @escaping (Result<Bool, Error>) -> Void) {
guard !samples.isEmpty else {
Expand All @@ -94,7 +94,7 @@ extension NightscoutUploader {

}

extension NightscoutUploader {
extension NightscoutClient {

func createDoses(_ data: [DoseEntry], usingObjectIdCache objectIdCache: ObjectIdCache, completion: @escaping (Result<[String], Error>) -> Void) {
guard !data.isEmpty else {
Expand Down
2 changes: 1 addition & 1 deletion NightscoutServiceKit/Extensions/OverrideTreament.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import NightscoutUploadKit
import NightscoutKit
import LoopKit
import HealthKit

Expand Down
4 changes: 2 additions & 2 deletions NightscoutServiceKit/Extensions/ProfileSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Foundation
import NightscoutUploadKit
import NightscoutKit
import LoopKit
import HealthKit

Expand Down Expand Up @@ -96,7 +96,7 @@ extension ProfileSet {
}


extension NightscoutUploadKit.TemporaryScheduleOverride {
extension NightscoutKit.TemporaryScheduleOverride {

func loopOverride(for unit: HKUnit) -> LoopKit.TemporaryScheduleOverridePreset? {
guard let name = name,
Expand Down
12 changes: 6 additions & 6 deletions NightscoutServiceKit/Extensions/StoredDosingDecision.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import HealthKit
import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension StoredDosingDecision {

Expand All @@ -34,7 +34,7 @@ extension StoredDosingDecision {
return PredictedBG(startDate: startDate, values: predictedGlucose.map { $0.quantity })
}

var loopStatusAutomaticDoseRecommendation: NightscoutUploadKit.AutomaticDoseRecommendation? {
var loopStatusAutomaticDoseRecommendation: NightscoutKit.AutomaticDoseRecommendation? {
guard let automaticDoseRecommendation = automaticDoseRecommendation else {
return nil
}
Expand All @@ -47,7 +47,7 @@ extension StoredDosingDecision {
nightscoutTempBasalAdjustment = nil
}

return NightscoutUploadKit.AutomaticDoseRecommendation(
return NightscoutKit.AutomaticDoseRecommendation(
timestamp: date,
tempBasalAdjustment: nightscoutTempBasalAdjustment,
bolusVolume: automaticDoseRecommendation.bolusUnits ?? 0)
Expand Down Expand Up @@ -115,11 +115,11 @@ extension StoredDosingDecision {
)
}

var overrideStatus: NightscoutUploadKit.OverrideStatus {
var overrideStatus: NightscoutKit.OverrideStatus {
guard let scheduleOverride = scheduleOverride, scheduleOverride.isActive(),
let glucoseTargetRange = glucoseTargetRangeSchedule?.value(at: date) else
{
return NightscoutUploadKit.OverrideStatus(timestamp: date, active: false)
return NightscoutKit.OverrideStatus(timestamp: date, active: false)
}

let unit = glucoseTargetRangeSchedule?.unit ?? HKUnit.milligramsPerDeciliter
Expand All @@ -128,7 +128,7 @@ extension StoredDosingDecision {
let currentCorrectionRange = CorrectionRange(minValue: lowerTarget, maxValue: upperTarget)
let duration = scheduleOverride.duration != .indefinite ? round(scheduleOverride.actualEndDate.timeIntervalSince(date)): nil

return NightscoutUploadKit.OverrideStatus(name: scheduleOverride.context.name,
return NightscoutKit.OverrideStatus(name: scheduleOverride.context.name,
timestamp: date,
active: true,
currentCorrectionRange: currentCorrectionRange,
Expand Down
2 changes: 1 addition & 1 deletion NightscoutServiceKit/Extensions/StoredGlucoseSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension StoredGlucoseSample {

Expand Down
9 changes: 5 additions & 4 deletions NightscoutServiceKit/Extensions/StoredSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import HealthKit
import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension AutomaticDosingStrategy {
var name: String {
Expand All @@ -34,7 +34,7 @@ extension AutomaticDosingStrategy {

extension StoredSettings {

var loopSettings: NightscoutUploadKit.LoopSettings? {
var loopSettings: NightscoutKit.LoopSettings? {
guard let bloodGlucoseUnit = bloodGlucoseUnit else {
return nil
}
Expand All @@ -47,7 +47,7 @@ extension StoredSettings {
upper: preMealTargetRange.maxValue))
}

return NightscoutUploadKit.LoopSettings(
return NightscoutKit.LoopSettings(
dosingEnabled: dosingEnabled,
overridePresets: overridePresets?.map { $0.nsScheduleOverride(for: bloodGlucoseUnit) } ?? [],
scheduleOverride: scheduleOverride?.nsScheduleOverride(for: bloodGlucoseUnit),
Expand Down Expand Up @@ -100,7 +100,8 @@ extension StoredSettings {
enteredBy: "Loop",
defaultProfile: "Default",
store: ["Default": profile],
settings: loopSettings)
settings: loopSettings,
syncIdentifier: syncIdentifier.uuidString)
}

}
Expand Down
2 changes: 1 addition & 1 deletion NightscoutServiceKit/Extensions/SyncCarbObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation
import LoopKit
import NightscoutUploadKit
import NightscoutKit
import HealthKit

extension SyncCarbObject {
Expand Down
10 changes: 5 additions & 5 deletions NightscoutServiceKit/Extensions/TemporaryScheduleOverride.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import HealthKit
import LoopKit
import NightscoutUploadKit
import NightscoutKit

extension LoopKit.TemporaryScheduleOverride {

func nsScheduleOverride(for unit: HKUnit) -> NightscoutUploadKit.TemporaryScheduleOverride {
func nsScheduleOverride(for unit: HKUnit) -> NightscoutKit.TemporaryScheduleOverride {
let nsTargetRange: ClosedRange<Double>?
if let targetRange = settings.targetRange {
nsTargetRange = ClosedRange(uncheckedBounds: (
Expand All @@ -30,7 +30,7 @@ extension LoopKit.TemporaryScheduleOverride {
nsDuration = 0
}

return NightscoutUploadKit.TemporaryScheduleOverride(
return NightscoutKit.TemporaryScheduleOverride(
duration: nsDuration,
targetRange: nsTargetRange,
insulinNeedsScaleFactor: settings.insulinNeedsScaleFactor,
Expand Down Expand Up @@ -68,7 +68,7 @@ extension LoopKit.TemporaryScheduleOverride.Context {

extension LoopKit.TemporaryScheduleOverridePreset {

func nsScheduleOverride(for unit: HKUnit) -> NightscoutUploadKit.TemporaryScheduleOverride {
func nsScheduleOverride(for unit: HKUnit) -> NightscoutKit.TemporaryScheduleOverride {
let nsTargetRange: ClosedRange<Double>?
if let targetRange = settings.targetRange {
nsTargetRange = ClosedRange(uncheckedBounds: (
Expand All @@ -86,7 +86,7 @@ extension LoopKit.TemporaryScheduleOverridePreset {
nsDuration = 0
}

return NightscoutUploadKit.TemporaryScheduleOverride(
return NightscoutKit.TemporaryScheduleOverride(
duration: nsDuration,
targetRange: nsTargetRange,
insulinNeedsScaleFactor: settings.insulinNeedsScaleFactor,
Expand Down
10 changes: 5 additions & 5 deletions NightscoutServiceKit/NightscoutService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os.log
import HealthKit
import LoopKit
import NightscoutUploadKit
import NightscoutKit

public enum NightscoutServiceError: Error {
case incompatibleTherapySettings
Expand Down Expand Up @@ -46,14 +46,14 @@ public final class NightscoutService: Service {
}
private let lockedObjectIdCache: Locked<ObjectIdCache>

private var _uploader: NightscoutUploader?
private var _uploader: NightscoutClient?

private var uploader: NightscoutUploader? {
private var uploader: NightscoutClient? {
if _uploader == nil {
guard let siteURL = siteURL, let apiSecret = apiSecret else {
return nil
}
_uploader = NightscoutUploader(siteURL: siteURL, APISecret: apiSecret)
_uploader = NightscoutClient(siteURL: siteURL, apiSecret: apiSecret)
}
return _uploader
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public final class NightscoutService: Service {
return
}

let uploader = NightscoutUploader(siteURL: siteURL, APISecret: apiSecret)
let uploader = NightscoutClient(siteURL: siteURL, apiSecret: apiSecret)
uploader.checkAuth(completion)
}

Expand Down