Skip to content

Commit

Permalink
Added LibreView integration for BloodGlucose data
Browse files Browse the repository at this point in the history
Update to iOS 16
  • Loading branch information
DobbyWanKenoby committed Dec 20, 2022
1 parent 5983726 commit 53a1004
Show file tree
Hide file tree
Showing 15 changed files with 1,046 additions and 27 deletions.
44 changes: 40 additions & 4 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
61962FCAF8A2D222553AC5A3 /* LibreConfigDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66A5B83E7967C38F7CBD883C /* LibreConfigDataFlow.swift */; };
63E890B4D951EAA91C071D5C /* BasalProfileEditorStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAFF91130F2FCCC7EBBA11AD /* BasalProfileEditorStateModel.swift */; };
642F76A05A4FF530463A9FD0 /* NightscoutConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8782B44544F38F2B2D82C38E /* NightscoutConfigRootView.swift */; };
6559084D2933A5BB00960C87 /* LibreViewConfigDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6559084C2933A5BB00960C87 /* LibreViewConfigDataFlow.swift */; };
6559084F2933A5C800960C87 /* LibreViewConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6559084E2933A5C800960C87 /* LibreViewConfigProvider.swift */; };
655908512933A5D700960C87 /* LibreViewStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 655908502933A5D700960C87 /* LibreViewStateModel.swift */; };
655908542933A63300960C87 /* LibreViewConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 655908532933A63300960C87 /* LibreViewConfigRootView.swift */; };
65D16C5A29422ED100ABF87A /* LibreLinkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D16C5929422ED100ABF87A /* LibreLinkManager.swift */; };
6632A0DC746872439A858B44 /* ISFEditorDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BDA519C9B890FD9A5DFCF3 /* ISFEditorDataFlow.swift */; };
69A31254F2451C20361D172F /* BolusStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 223EC0494F55A91E3EA69EF4 /* BolusStateModel.swift */; };
69B9A368029F7EB39F525422 /* CREditorStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64AA5E04A2761F6EEA6568E1 /* CREditorStateModel.swift */; };
Expand Down Expand Up @@ -677,6 +682,11 @@
60744C3E9BB3652895C908CC /* DataTableProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = DataTableProvider.swift; sourceTree = "<group>"; };
618E62C9757B2F95431B5DC0 /* AddCarbsProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AddCarbsProvider.swift; sourceTree = "<group>"; };
64AA5E04A2761F6EEA6568E1 /* CREditorStateModel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CREditorStateModel.swift; sourceTree = "<group>"; };
6559084C2933A5BB00960C87 /* LibreViewConfigDataFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreViewConfigDataFlow.swift; sourceTree = "<group>"; };
6559084E2933A5C800960C87 /* LibreViewConfigProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreViewConfigProvider.swift; sourceTree = "<group>"; };
655908502933A5D700960C87 /* LibreViewStateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreViewStateModel.swift; sourceTree = "<group>"; };
655908532933A63300960C87 /* LibreViewConfigRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreViewConfigRootView.swift; sourceTree = "<group>"; };
65D16C5929422ED100ABF87A /* LibreLinkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreLinkManager.swift; sourceTree = "<group>"; };
66A5B83E7967C38F7CBD883C /* LibreConfigDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = LibreConfigDataFlow.swift; sourceTree = "<group>"; };
67F94DD2853CF42BA4E30616 /* BasalProfileEditorDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BasalProfileEditorDataFlow.swift; sourceTree = "<group>"; };
680C4420C9A345D46D90D06C /* ManualTempBasalProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ManualTempBasalProvider.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -902,6 +912,7 @@
C11D545CED3ECEB525EDEE23 /* LibreConfig */,
3811DE1A25C9D48300A708ED /* Main */,
5031FE61F63C2A8A8B7674DD /* ManualTempBasal */,
6559084B2933A58E00960C87 /* LibreViewConfig */,
D533BF261CDC1C3F871E7BFD /* NightscoutConfig */,
F66B236E00924A05D6A9F9DF /* NotificationsConfig */,
3E1C41D9301B7058AA7BF5EA /* PreferencesEditor */,
Expand Down Expand Up @@ -1047,6 +1058,7 @@
3811DE9725C9D88300A708ED /* NightscoutManager.swift */,
38FE826925CC82DB001FF17A /* NetworkService.swift */,
38FE826C25CC8461001FF17A /* NightscoutAPI.swift */,
65D16C5929422ED100ABF87A /* LibreLinkManager.swift */,
);
path = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -1628,6 +1640,25 @@
path = TargetsEditor;
sourceTree = "<group>";
};
6559084B2933A58E00960C87 /* LibreViewConfig */ = {
isa = PBXGroup;
children = (
655908522933A61D00960C87 /* View */,
6559084C2933A5BB00960C87 /* LibreViewConfigDataFlow.swift */,
6559084E2933A5C800960C87 /* LibreViewConfigProvider.swift */,
655908502933A5D700960C87 /* LibreViewStateModel.swift */,
);
path = LibreViewConfig;
sourceTree = "<group>";
};
655908522933A61D00960C87 /* View */ = {
isa = PBXGroup;
children = (
655908532933A63300960C87 /* LibreViewConfigRootView.swift */,
);
path = View;
sourceTree = "<group>";
};
672F63EEAE27400625E14BAD /* AutotuneConfig */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2237,6 +2268,7 @@
388358C825EEF6D200E024B2 /* BasalProfileEntry.swift in Sources */,
3811DE0B25C9D32F00A708ED /* BaseView.swift in Sources */,
3811DE3225C9D49500A708ED /* HomeDataFlow.swift in Sources */,
6559084D2933A5BB00960C87 /* LibreViewConfigDataFlow.swift in Sources */,
38569347270B5DFB0002C50D /* CGMType.swift in Sources */,
3821ED4C25DD18BA00BC42AD /* Constants.swift in Sources */,
384E803425C385E60086DB71 /* JavaScriptWorker.swift in Sources */,
Expand Down Expand Up @@ -2302,6 +2334,7 @@
5D16287A969E64D18CE40E44 /* PumpConfigStateModel.swift in Sources */,
E974172296125A5AE99E634C /* PumpConfigRootView.swift in Sources */,
448B6FCB252BD4796E2960C0 /* PumpSettingsEditorDataFlow.swift in Sources */,
6559084F2933A5C800960C87 /* LibreViewConfigProvider.swift in Sources */,
38E44536274E411700EC9A94 /* Disk.swift in Sources */,
2BE9A6FA20875F6F4F9CD461 /* PumpSettingsEditorProvider.swift in Sources */,
6B9625766B697D1C98E455A2 /* PumpSettingsEditorStateModel.swift in Sources */,
Expand Down Expand Up @@ -2337,6 +2370,7 @@
17A9D0899046B45E87834820 /* CREditorProvider.swift in Sources */,
69B9A368029F7EB39F525422 /* CREditorStateModel.swift in Sources */,
F97F722827A9741C007B6620 /* MigrationStateModel.swift in Sources */,
655908512933A5D700960C87 /* LibreViewStateModel.swift in Sources */,
38E44538274E411700EC9A94 /* Disk+[Data].swift in Sources */,
98641AF4F92123DA668AB931 /* CREditorRootView.swift in Sources */,
38E4453D274E411700EC9A94 /* Disk+Errors.swift in Sources */,
Expand Down Expand Up @@ -2382,6 +2416,7 @@
38E4453B274E411700EC9A94 /* Disk+VolumeInformation.swift in Sources */,
F97F722127A957AF007B6620 /* MigrationPublisher.swift in Sources */,
7BCFACB97C821041BA43A114 /* ManualTempBasalRootView.swift in Sources */,
655908542933A63300960C87 /* LibreViewConfigRootView.swift in Sources */,
38E44534274E411700EC9A94 /* Disk+InternalHelpers.swift in Sources */,
38A00B2325FC2B55006BC0B0 /* LRUCache.swift in Sources */,
3083261C4B268E353F36CD0B /* AutotuneConfigDataFlow.swift in Sources */,
Expand All @@ -2390,6 +2425,7 @@
A05235B9112E677ED03B6E8E /* AutotuneConfigRootView.swift in Sources */,
7F7B756BE8543965D9FDF1A2 /* DataTableDataFlow.swift in Sources */,
1D845DF2E3324130E1D95E67 /* DataTableProvider.swift in Sources */,
65D16C5A29422ED100ABF87A /* LibreLinkManager.swift in Sources */,
0D9A5E34A899219C5C4CDFAF /* DataTableStateModel.swift in Sources */,
D6D02515BBFBE64FEBE89856 /* DataTableRootView.swift in Sources */,
38569349270B5DFB0002C50D /* AppGroupSource.swift in Sources */,
Expand Down Expand Up @@ -2583,7 +2619,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -2641,7 +2677,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -2666,7 +2702,7 @@
DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -2703,7 +2739,7 @@
DEVELOPMENT_TEAM = "${DEVELOPER_TEAM}";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
25 changes: 6 additions & 19 deletions FreeAPS.xcodeproj/xcshareddata/xcschemes/FreeAPSWatch.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,33 @@
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
notificationPayloadFile = "FreeAPSWatch WatchKit Extension/PushNotificationPayload.apns">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/FreeAPS X">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38E8751B27554D5500975559"
BuildableName = "FreeAPSWatch.app"
BlueprintName = "FreeAPSWatch"
ReferencedContainer = "container:FreeAPS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/FreeAPS X">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38E8751B27554D5500975559"
BuildableName = "FreeAPSWatch.app"
BlueprintName = "FreeAPSWatch"
ReferencedContainer = "container:FreeAPS.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38E8751B27554D5500975559"
BuildableName = "FreeAPSWatch.app"
BlueprintName = "FreeAPSWatch"
ReferencedContainer = "container:FreeAPS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
6 changes: 5 additions & 1 deletion FreeAPS/Sources/APS/FetchGlucoseManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
private let processQueue = DispatchQueue(label: "BaseGlucoseManager.processQueue")
@Injected() var glucoseStorage: GlucoseStorage!
@Injected() var nightscoutManager: NightscoutManager!
@Injected() var libreLinkManager: LibreLinkManager!
@Injected() var apsManager: APSManager!
@Injected() var settingsManager: SettingsManager!
@Injected() var libreTransmitter: LibreTransmitterSource!
@Injected() var healthKitManager: HealthKitManager!
@Injected() var deviceDataManager: DeviceDataManager!
@Injected() private var keychain: Keychain!

private var lifetime = Lifetime()
private let timer = DispatchTimer(timeInterval: 1.minutes.timeInterval)
Expand Down Expand Up @@ -83,8 +85,10 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
self.glucoseStorage.storeGlucose(filtered)
self.apsManager.heartbeat(date: date)
self.nightscoutManager.uploadGlucose()
let glucoseForHealth = filteredByDate.filter { !glucoseFromHealth.contains($0) }

self.libreLinkManager.uploadIfNeeded()

let glucoseForHealth = filteredByDate.filter { !glucoseFromHealth.contains($0) }
guard glucoseForHealth.isNotEmpty else { return }
self.healthKitManager.saveIfNeeded(bloodGlucose: glucoseForHealth)
}
Expand Down
1 change: 1 addition & 0 deletions FreeAPS/Sources/Assemblies/NetworkAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ final class NetworkAssembly: Assembly {
}

container.register(NightscoutManager.self) { r in BaseNightscoutManager(resolver: r) }
container.register(LibreLinkManager.self) { r in BaseLibreLinkManager(resolver: r) }
}
}
67 changes: 66 additions & 1 deletion FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Enact a temp Basal or a temp target */
/* */
"Manual Temp Basal" = "Manual Temp Basal";

/* Allow uploads tp NS */
/* Allow uploads to different services */
"Allow uploads" = "Allow uploads";

/* API secret in NS */
Expand Down Expand Up @@ -1066,3 +1066,68 @@ Enact a temp Basal or a temp target */

/* "Noisy CGM Target Multiplier" */
"Defaults to 1.3. Increase target by this amount when looping off raw/noisy CGM data" = "Defaults to 1.3. Increase target by this amount when looping off raw/noisy CGM data";

/* Libre View --------------------*/
/* */
"LibreView config" = "LibreView config";

/* Secription on LibreView settings screen */
"To use LibreView, you need to enter credentials and create a connection" = "To use LibreView, you need to enter credentials and create a connection";

/* Button on LibreView settings screen */
"Update a connection" = "Update a connection";

/* Button on LibreView settings screen */
"Create a connection" = "Create a connection";

/* Setting on LibreView settings screen */
"Custom server" = "Custom server";

/* Section on LibreView settings screen */
"Connection settings" = "Connection settings";

/* Button on LibreView settings screen */
"Remove a connection" = "Remove a connection";

/* Alert message on LibreView settings screen */
"Please, set correct LibreView server" = "Please, set correct LibreView server";

/* Setting on LibreView settings screen */
"LibreView Server" = "LibreView Server";

/* Button on LibreView settings screen */
"Force upload glocose" = "Force upload glocose";

/* Message after success uploading of glusoce to LibreView server */
"Glucose was upload success" = "Glucose was upload success";

"Last upload date to LibreLink is more, that current date. Try later or check preferences" = "Last upload date to LibreLink is more, that current date. Try later or check preferences";

"Have not new glucose to upload" = "Have not new glucose to upload";

"Wrong connection's token" = "Wrong connection's token";

"Actions" = "Actions";

"Frequency of uploads" = "Frequency of uploads";
"Each Loop" = "Each Loop";
"Every 15 minutes" = "Every 15 minutes";
"Every 30 minutes" = "Every 30 minutes";
"Every hour" = "Every hour";
"Every 4 hours" = "Every 4 hours";
"Random upload, but less than 4 hours after the last one" = "Random upload, but less than 4 hours after the last one";
"It is recommended to use random uploads, they are more natural" = "It is recommended to use random uploads, they are more natural";
"Last upload on %@. Next upload no earlier than %@" = "Last upload on %@. Next upload no earlier than %@";

/* Credentials and autentification --------------------*/
/* */
"Credentials" = "Credentials";

/* */
"Login" = "Login";

/* */
"Password" = "Password";

/* */
"Wrong password or login" = "Wrong password or login";
67 changes: 66 additions & 1 deletion FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Enact a temp Basal or a temp target */
/* */
"Manual Temp Basal" = "Ручная ВБС";

/* Allow uploads tp NS */
/* Allow uploads data to different services */
"Allow uploads" = "Разрешить выгрузку";

/* API secret in NS */
Expand Down Expand Up @@ -1066,3 +1066,68 @@ Enact a temp Basal or a temp target */

/* "Noisy CGM Target Multiplier" */
"Defaults to 1.3. Increase target by this amount when looping off raw/noisy CGM data" = "По умолчанию 1,3. Увеличивает цель на эту величину, когда цикл отключается из за шума сенсора";

/* Libre View --------------------*/
/* */
"LibreView config" = "Настройки LibreView";

/* Secription on LibreView settings screen */
"To use LibreView, you need to enter credentials and create a connection" = "Для использования LibreView вам необходимо ввести данные авторизации и создать подключение";

/* Button on LibreView settings screen */
"Update a connection" = "Обновить подключение";

/* Button on LibreView settings screen */
"Create a connection" = "Создать подключение";

/* Setting on LibreView settings screen */
"Custom server" = "Собственный сервер";

/* Section on LibreView settings screen */
"Connection settings" = "Настройки подключения";

/* Button on LibreView settings screen */
"Remove a connection" = "Удалить подключение";

/* Alert message on LibreView settings screen */
"Please, set correct LibreView server" = "Пожалуйста, установите корректный адрес сервера";

/* Setting on LibreView settings screen */
"LibreView Server" = "Сервер LibreView";

/* Button on LibreView settings screen */
"Force upload glocose" = "Принудительная выгрузка глюкозы";

/* Message after success uploading of glusoce to LibreView server */
"Glucose was upload success" = "Глюкоза была успешно выгружена";

"Last upload date to LibreLink is more, that current date. Try later or check preferences" = "Дата последней выгрузки больше текущей даты. Попробуйте позже или проверьте настройки";

"Have not new glucose to upload" = "Новая глюкоза для выгрузки отсутсвует";

"Wrong connection's token" = "Неверный токен безопасности";

"Actions" = "Действия";

"Frequency of uploads" = "Частота выгрузки";
"Each Loop" = "Каждый цикл петли";
"Every 15 minutes" = "Каждые 15 минут";
"Every 30 minutes" = "Каждые 30 минут";
"Every hour" = "Каждый час";
"Every 4 hours" = "Каждые 4 часа";
"Random upload, but less than 4 hours after the last one" = "Случайные выгрузки, но не менее 1 раза в 4 часа";
"It is recommended to use random uploads, they are more natural" = "Рекомендовано использовать случайную частоту выгрузки, так как она более естественна";
"Last upload on %@. Next upload no earlier than %@" = "Последняя выгрузка %@. Следующая не ранее, чем %@";

/* Credentials and autentification --------------------*/
/* */
"Credentials" = "Данные для входа";

/* */
"Login" = "Логин";

/* */
"Password" = "Пароль";

/* */
"Wrong password or login" = "Неверный логин или пароль";
Loading

0 comments on commit 53a1004

Please sign in to comment.