Skip to content
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

Configuration profiles #782

Draft
wants to merge 41 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
aa7a852
Configuration profiles
Jon-b-m Jul 26, 2024
19f08ca
Merge remote-tracking branch 'refs/remotes/origin/dev'
Jon-b-m Jul 29, 2024
5fe626c
Only ask to import reset settings for old iAPS users.
Jon-b-m Jul 29, 2024
38759ff
Update Config.xcconfig
Jon-b-m Jul 29, 2024
adc6edb
Check if old/new iAPS user
Jon-b-m Jul 31, 2024
1790423
Updates
Jon-b-m Jul 31, 2024
2f5f97a
Make sure database uploads are complete
Jon-b-m Jul 31, 2024
8527942
Bump version
Jon-b-m Aug 11, 2024
69f24ca
Merge dev updates
Jon-b-m Aug 12, 2024
8318fe5
change default max carbs
Jon-b-m Aug 12, 2024
ba7f829
Merge dev updates (manually due to merge conflicts).
Jon-b-m Aug 23, 2024
e05eac0
Merge branch 'dev' into profiles
Jon-b-m Aug 23, 2024
1009dec
Merge dev updates into profiles
Jon-b-m Aug 25, 2024
b4c935c
fix merge
Jon-b-m Aug 25, 2024
4f44cec
Merge branch dev updates into profiles
Jon-b-m Aug 26, 2024
84b3adc
Merge branch 'dev' into profiles
Jon-b-m Aug 28, 2024
455b38f
Merge fix
Jon-b-m Aug 29, 2024
5c77829
Configuration profiles
Jon-b-m Jul 26, 2024
f1d2e2b
Only ask to import reset settings for old iAPS users.
Jon-b-m Jul 29, 2024
a68a54d
Check if old/new iAPS user
Jon-b-m Jul 31, 2024
03e494b
Updates
Jon-b-m Jul 31, 2024
f446328
Bump version
Jon-b-m Aug 11, 2024
c17bc60
change default max carbs
Jon-b-m Aug 12, 2024
162b29e
Merge dev updates (manually due to merge conflicts).
Jon-b-m Aug 23, 2024
b3c9df1
Update Config.xcconfig
Merkaffe Aug 23, 2024
b3f359f
fix merge
Jon-b-m Aug 25, 2024
b1a8e44
merge dev branch updates
Jon-b-m Aug 29, 2024
6018ce1
Merge dev updates into profile branch
Jon-b-m Aug 29, 2024
c2ebba9
dev updates
Jon-b-m Aug 29, 2024
33ee5fa
Remove my Bundle ID
Jon-b-m Aug 29, 2024
b114b65
Merge branch 'dev' into profiles
Jon-b-m Sep 4, 2024
12c1581
Update Config.xcconfig
Jon-b-m Sep 10, 2024
d43d2a4
Merge branch 'dev' into profiles
Jon-b-m Sep 23, 2024
02d8b22
merge fix and update defaults
Jon-b-m Sep 23, 2024
1dd3044
Merge fix
Jon-b-m Sep 23, 2024
5461452
Merge branch 'dev' into profiles
Jon-b-m Sep 24, 2024
a44727b
Merge branch 'dev' into profiles
Jon-b-m Oct 4, 2024
f649828
Merge branch 'dev' into profiles
Jon-b-m Oct 11, 2024
3290c31
Merge branch 'dev' into profiles
Jon-b-m Oct 22, 2024
c83f0cb
merge fix
Jon-b-m Oct 22, 2024
bff9feb
Merge branch 'dev' into profiles
Jon-b-m Oct 23, 2024
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
106 changes: 87 additions & 19 deletions FreeAPS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions FreeAPS.xcodeproj/xcshareddata/xcschemes/FreeAPS X.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
value = ""
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "IDEPreferLogStreaming"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
12 changes: 6 additions & 6 deletions FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift",
"state": {
"branch": null,
"revision": "19b3c3ceed117c5cc883517c4e658548315ba70b",
"version": "1.6.0"
"revision": "c9c3df6ab812de32bae61fc0cd1bf6d45170ebf0",
"version": "1.8.2"
}
},
{
Expand Down Expand Up @@ -60,17 +60,17 @@
"repositoryURL": "https://github.com/SwiftKickMobile/SwiftMessages",
"state": {
"branch": null,
"revision": "b29dd21090b708aa0ae9ecbaf6e2d0487028dc3f",
"version": "9.0.6"
"revision": "62e12e138fc3eedf88c7553dd5d98712aa119f40",
"version": "9.0.9"
}
},
{
"package": "Swinject",
"repositoryURL": "https://github.com/Swinject/Swinject",
"state": {
"branch": null,
"revision": "8bc503e60965298984fb58cf47b71c541449fe2a",
"version": "2.8.3"
"revision": "be9dbcc7b86811bc131539a20c6f9c2d3e56919f",
"version": "2.9.1"
}
}
]
Expand Down
4 changes: 0 additions & 4 deletions FreeAPS/Resources/javascript/prepare/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ function generate(pumpsettings_data, bgtargets_data, isf_data, basalprofile_data
Math.max(35, Math.min(preferences.insulinPeakTime, 100));
} else { preferences.insulinPeakTime = 55; }
}
// Migrate missing conversion from original freeaps
if (preferences.resistanceLowersTarget) {
preferences.resistance_lowers_target = true;
}
}

var tdd_factor = { };
Expand Down
125 changes: 63 additions & 62 deletions FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,68 @@
{
"units" : "mmol/L",
"closedLoop" : false,
"allowAnnouncements" : false,
"useAutotune" : false,
"isUploadEnabled" : false,
"useLocalGlucoseSource" : false,
"localGlucosePort" : 8080,
"debugOptions" : false,
"insulinReqPercentage" : 70,
"skipBolusScreenAfterCarbs" : false,
"displayHR" : false,
"cgm" : "nightscout",
"uploadGlucose" : true,
"useCalendar" : false,
"displayCalendarEmojis" : false,
"displayCalendarIOBandCOB" : false,
"glucoseBadge" : false,
"glucoseNotificationsAlways" : false,
"useAlarmSound" : false,
"addSourceInfoToGlucoseNotifications" : false,
"lowGlucose" : 72,
"highGlucose" : 270,
"carbsRequiredThreshold" : 10,
"animatedBackground" : false,
"useFPUconversion" : true,
"individualAdjustmentFactor" : 0.5,
"timeCap" : 8,
"minuteInterval" : 30,
"delay" : 60,
"useAppleHealth" : false,
"smoothGlucose" : false,
"displayOnWatch" : "BGTarget",
"overrideHbA1cUnit" : false,
"high" : 145,
"low" : 70,
"uploadStats" : false,
"hours" : 6,
"xGridLines" : true,
"yGridLines" : true,
"oneDimensionalGraph" : false,
"rulerMarks" : false,
"maxCarbs" : 200,
"displayFatAndProteinOnWatch" : false,
"confirmBolusFaster" : false,
"onlyAutotuneBasals" : false,
"overrideFactor" : 0.8,
"useCalc" : true,
"fattyMeals" : false,
"fattyMealFactor" : 0.7,
"displayPredictions" : true,
"useLiveActivity" : false,
"useTargetButton" : false,
"alwaysUseColors" : true,
"timeSettings" : true,
"disableCGMError" : true,
"allowBolusShortcut": false,
"profilesOrTempTargets": true,
"allowedRemoteBolusAmount": 0.0,
"cgm": "nightscout",
"low": 70,
"high": 145,
"delay": 60,
"hours": 6,
"units": "mmol/L",
"timeCap": 8,
"useCalc": true,
"profileID": "Hypo Treatment",
"maxCarbs": 200,
"birthDate": "0001-01-01T23:00:00.000Z",
"displayHR": true,
"closedLoop": false,
"eventualBG": true,
"minumimPrediction": true,
"fattyMeals": true,
"lowGlucose": 66.66666666666666,
"minimumSMB": 0.3,
"useInsulinBars": false,
"birthDate": Date.distantPast,
"rulerMarks": true,
"sexSetting": 3,
"xGridLines": true,
"yGridLines": true,
"highGlucose": 270,
"uploadStats": true,
"useAutotune": false,
"useCalendar": false,
"displayDelta": false,
"profileID": "Hypo Treatment"
"debugOptions": false,
"glucoseBadge": true,
"smoothGlucose": false,
"uploadGlucose": true,
"useAlarmSound": false,
"displayOnWatch": "BGTarget",
"minuteInterval": 30,
"overrideFactor": 1.0,
"useAppleHealth": false,
"useInsulinBars": true,
"alwaysUseColors": false,
"disableCGMError": true,
"fattyMealFactor": 0.7,
"isUploadEnabled": false,
"useLiveActivity": false,
"useTargetButton": false,
"localGlucosePort": 8080,
"skipGlucoseChart": false,
"useFPUconversion": true,
"minumimPrediction": true,
"overrideHbA1cUnit": false,
"allowAnnouncements": false,
"allowBolusShortcut": false,
"animatedBackground": false,
"confirmBolusFaster": false,
"displayPredictions": true,
"onlyAutotuneBasals": false,
"oneDimensionalGraph": false,
"insulinReqPercentage": 70,
"displayCalendarEmojis": false,
"profilesOrTempTargets": false,
"useLocalGlucoseSource": false,
"carbsRequiredThreshold": 25,
"allowedRemoteBolusAmount": 0,
"displayCalendarIOBandCOB": false,
"skipBolusScreenAfterCarbs": false,
"glucoseNotificationsAlways": false,
"individualAdjustmentFactor": 0.5,
"displayFatAndProteinOnWatch": true,
"addSourceInfoToGlucoseNotifications": false
}
101 changes: 50 additions & 51 deletions FreeAPS/Resources/json/defaults/preferences.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
{
"max_iob" : 0,
"max_daily_safety_multiplier" : 3,
"current_basal_safety_multiplier" : 4,
"autosens_max" : 1.2,
"autosens_min" : 0.7,
"smb_delivery_ratio" : 0.5,
"rewind_resets_autosens" : true,
"high_temptarget_raises_sensitivity" : false,
"low_temptarget_lowers_sensitivity" : false,
"sensitivity_raises_target" : false,
"resistance_lowers_target" : false,
"adv_target_adjustments" : false,
"exercise_mode" : false,
"half_basal_exercise_target" : 160,
"maxCOB" : 120,
"wide_bg_target_range" : false,
"skip_neutral_temps" : false,
"unsuspend_if_no_temp" : false,
"min_5m_carbimpact" : 8,
"autotune_isf_adjustmentFraction" : 1,
"remainingCarbsCap" : 90,
"remainingCarbsFraction" : 1,
"enableUAM" : false,
"A52_risk_enable" : false,
"enableSMB_with_COB" : false,
"enableSMB_with_temptarget" : false,
"enableSMB_always" : false,
"enableSMB_after_carbs" : false,
"allowSMB_with_high_temptarget" : false,
"maxSMBBasalMinutes" : 30,
"maxUAMSMBBasalMinutes" : 30,
"SMBInterval" : 3,
"bolus_increment" : 0.1,
"curve" : "rapid-acting",
"useCustomPeakTime" : false,
"insulinPeakTime" : 75,
"carbsReqThreshold" : 1,
"noisyCGMTargetMultiplier" : 1.3,
"suspend_zeros_iob" : false,
"maxDelta_bg_threshold" : 0.2,
"curve": "rapid-acting",
"adjustmentFactor" : 0.5,
"sigmoid" : true,
"enableDynamicCR" : false,
"useNewFormula" : false,
"useWeightedAverage" : true,
"weightPercentage" : 0.65,
"tddAdjBasal" : false,
"enableSMB_high_bg" : false,
"enableSMB_high_bg_target" : 110,
"threshold_setting" : 65,
"updateInterval" : 20
"maxCOB": 350,
"max_iob": 10,
"sigmoid": true,
"enableUAM": true,
"SMBInterval": 3,
"tddAdjBasal": false,
"autosens_max": 1.3,
"autosens_min": 0.7,
"exercise_mode": false,
"useNewFormula": false,
"updateInterval": 20,
"A52_risk_enable": false,
"bolus_increment": 0.1,
"enableDynamicCR": false,
"insulinPeakTime": 75,
"adjustmentFactor": 0.5,
"enableSMB_always": true,
"weightPercentage": 0.65,
"carbsReqThreshold": 1,
"enableSMB_high_bg": false,
"min_5m_carbimpact": 8,
"remainingCarbsCap": 90,
"suspend_zeros_iob": false,
"threshold_setting": 67.56756756756755,
"useCustomPeakTime": false,
"enableSMB_with_COB": false,
"maxSMBBasalMinutes": 150,
"skip_neutral_temps": false,
"smb_delivery_ratio": 0.5,
"useWeightedAverage": false,
"unsuspend_if_no_temp": false,
"wide_bg_target_range": false,
"enableSMB_after_carbs": false,
"maxDelta_bg_threshold": 0.25,
"maxUAMSMBBasalMinutes": 80,
"adv_target_adjustments": false,
"remainingCarbsFraction": 1,
"resistance_lowers_target": false,
"rewind_resets_autosens": false,
"enableSMB_high_bg_target": 110,
"noisyCGMTargetMultiplier": 1.3,
"enableSMB_with_temptarget": false,
"sensitivity_raises_target": false,
"half_basal_exercise_target": 160,
"max_daily_safety_multiplier": 3,
"allowSMB_with_high_temptarget": false,
"autotune_isf_adjustmentFraction": 1,
"current_basal_safety_multiplier": 4,
"low_temptarget_lowers_sensitivity": true,
"high_temptarget_raises_sensitivity": true
}
19 changes: 13 additions & 6 deletions FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ final class OpenAPS {
reasonString.insert(contentsOf: ", SMB Ratio: \(smbRatio)", at: index)
}

// Active Configuration profile
let active = CoreDataStorage().fetchActiveProfile()
if active != "default" {
let index = reasonString.firstIndex(of: ";") ?? reasonString.index(reasonString.startIndex, offsetBy: 0)
reasonString.insert(contentsOf: ", Configuration: \(active)", at: index)
}

// SMBs Disabled?
if let required = suggestion.insulinReq, required > 0, (suggestion.units ?? 0) <= 0 {
let index = reasonString.endIndex
reasonString.insert(contentsOf: " SMBs Disabled.", at: index)
}

// Middleware
if targetGlucose != nil, let middlewareString = readMiddleware(json: profile, variable: "mw"),
middlewareString.count > 2
Expand All @@ -388,12 +401,6 @@ final class OpenAPS {
}
}

// SMBs Disabled?
if let required = suggestion.insulinReq, required > 0, (suggestion.units ?? 0) <= 0 {
let index = reasonString.endIndex
reasonString.insert(contentsOf: " SMBs Disabled.", at: index)
}

// Save Suggestion to CoreData
coredataContext.perform { [self] in
if let isf = readReason(reason: reason, variable: "ISF"),
Expand Down
14 changes: 14 additions & 0 deletions FreeAPS/Sources/Helpers/Token.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

final class Token {
func getIdentifier() -> String {
let keychain = BaseKeychain()
var identfier = keychain.getValue(String.self, forKey: IAPSconfig.id) ?? ""
guard identfier.count > 1 else {
identfier = UUID().uuidString
keychain.setValue(identfier, forKey: IAPSconfig.id)
return identfier
}
return identfier
}
}
5 changes: 2 additions & 3 deletions FreeAPS/Sources/Logger/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ final class Logger {
static let deviceManager = Logger(category: .deviceManager, reporter: baseReporter)
static let apsManager = Logger(category: .apsManager, reporter: baseReporter)
static let nightscout = Logger(category: .nightscout, reporter: baseReporter)
static let dynamic = Logger(category: .dynamic, reporter: baseReporter)

enum Category: String {
case `default`
Expand All @@ -131,13 +130,13 @@ final class Logger {
var logger: Logger {
switch self {
case .default: return .default
case .service: return .service
case .dynamic,
.service: return .service
case .businessLogic: return .businessLogic
case .openAPS: return .openAPS
case .deviceManager: return .deviceManager
case .apsManager: return .apsManager
case .nightscout: return .nightscout
case .dynamic: return .dynamic
}
}

Expand Down
2 changes: 2 additions & 0 deletions FreeAPS/Sources/Models/Configs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ extension Font {
static let carbsDotFont = Font.custom("CarbsDotFont", fixedSize: 12)
static let bolusDotFont = Font.custom("BolusDotFont", fixedSize: 12)
static let announcementSymbolFont = Font.custom("AnnouncementSymbolFont", fixedSize: 14)

static let settingsListed = Font.custom("settingsListed", fixedSize: 15)
}
3 changes: 1 addition & 2 deletions FreeAPS/Sources/Models/FreeAPSSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ struct FreeAPSSettings: JSON, Equatable {
var useInsulinBars: Bool = false
var disableCGMError: Bool = true
var skipGlucoseChart: Bool = false
var birthDate = Date.distantPast
// var sex: Sex = .secret
var birthDate: Date = .distantPast
var sexSetting: Int = 3
var displayDelta: Bool = false
var profileID: String = "Hypo Treatment"
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS/Sources/Models/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension Preferences {
case highTemptargetRaisesSensitivity = "high_temptarget_raises_sensitivity"
case lowTemptargetLowersSensitivity = "low_temptarget_lowers_sensitivity"
case sensitivityRaisesTarget = "sensitivity_raises_target"
case resistanceLowersTarget
case resistanceLowersTarget = "resistance_lowers_target"
case advTargetAdjustments = "adv_target_adjustments"
case exerciseMode = "exercise_mode"
case halfBasalExerciseTarget = "half_basal_exercise_target"
Expand Down
Loading