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

Merge alpha into dev #333

Merged
merged 31 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f902c73
Auto-remove trailing slash and other unwanted errors from Nightscout URL
LiroyvH May 14, 2024
9967d63
Xcode auto changes of indentation in NightscoutConfigStateModel.swift
bjornoleh May 18, 2024
c9c9e19
Merge pull request #1 from bjornoleh/patch-1
LiroyvH May 29, 2024
61ec999
Fix the dexcom share in Trio
avouspierre Jun 8, 2024
5e11f67
delete a function not used
avouspierre Jun 8, 2024
3a1360f
Merge pull request #292 from nightscout/dev
dnzxy Jun 10, 2024
7a093ff
Merge branch 'nightscout:dev' into patch-1
LiroyvH Jun 10, 2024
217d1d6
Merge pull request #190 from LiroyvH/patch-1
dnzxy Jun 10, 2024
a5d159d
Change TIR to include low and high setting values
MikePlante1 Jun 8, 2024
174a6df
update the testflight.md file
marionbarker Jun 11, 2024
51bdc77
Add the optional instructions for modifying automated build and sync
bjornoleh Jun 11, 2024
7a6ddf3
Merge pull request #298 from MikePlante1/stats
bjornoleh Jun 13, 2024
189c935
modify .gitmodules to point to loopandlearn
marionbarker Jun 13, 2024
9f1b847
Merge pull request #303 from loopandlearn/modify_submodule_source
bjornoleh Jun 15, 2024
d7a730c
Merge pull request #308 from nightscout/dev
bjornoleh Jun 15, 2024
3be872c
Merge pull request #282 from avouspierre/dev+dexcomshare
bjornoleh Jun 15, 2024
82f2d01
Merge pull request #299 from bjornoleh/testflight.md_enable_disable_a…
dnzxy Jun 16, 2024
1d1a332
fix(bgtargets): change variable from double to decimal
Sjoerd-Bo3 Jun 17, 2024
9be108b
refactor(bgtargets): typo fix
Sjoerd-Bo3 Jun 17, 2024
45d1ede
fix(bgtargets): correctly assigning highindex
Sjoerd-Bo3 Jun 17, 2024
9b177a2
Merge branch 'alpha' into update_browser_build_directions
marionbarker Jun 17, 2024
58adcd3
Merge branch 'alpha' into fix-setting-of-bg-targets
Sjoerd-Bo3 Jun 18, 2024
b6db960
use Trio specific names; remove APP_GROUPS from LiveActivity
marionbarker Jun 18, 2024
434e62a
Merge branch 'trio-specific-identifiers' into update_browser_build_di…
marionbarker Jun 18, 2024
14b5a86
update instructions in testflight.md, match Fastfile improvements
marionbarker Jun 19, 2024
59479e2
clarify some wording for testflight.md
marionbarker Jun 19, 2024
6fc084d
Merge pull request #297 from loopandlearn/update_browser_build_direct…
dnzxy Jun 19, 2024
7c88bac
Merge pull request #321 from Sjoerd-Bo3/fix-setting-of-bg-targets
dnzxy Jun 19, 2024
8c20819
update submodule CGMBLEKit: no change in function, add log to filter …
marionbarker Jun 22, 2024
3ec6176
Merge pull request #330 from loopandlearn/update_CGMBLEKit_submodule
Sjoerd-Bo3 Jun 23, 2024
4b91846
Merge pull request #334 from nightscout/dev
bjornoleh Jun 26, 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
39 changes: 20 additions & 19 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
[submodule "LoopKit"]
path = LoopKit
url = https://github.com/LoopKit/LoopKit.git
branch = dev
url = https://github.com/loopandlearn/LoopKit.git
branch = trio
[submodule "CGMBLEKit"]
path = CGMBLEKit
url = https://github.com/LoopKit/CGMBLEKit.git
branch = dev
url = https://github.com/loopandlearn/CGMBLEKit.git
branch = trio
[submodule "dexcom-share-client-swift"]
path = dexcom-share-client-swift
url = https://github.com/LoopKit/dexcom-share-client-swift.git
branch = dev
url = https://github.com/loopandlearn/dexcom-share-client-swift.git
branch = trio
[submodule "RileyLinkKit"]
path = RileyLinkKit
url = https://github.com/LoopKit/RileyLinkKit
branch = dev
url = https://github.com/loopandlearn/RileyLinkKit
branch = trio
[submodule "OmniBLE"]
path = OmniBLE
url = https://github.com/LoopKit/OmniBLE.git
branch = dev
url = https://github.com/loopandlearn/OmniBLE.git
branch = trio
[submodule "G7SensorKit"]
path = G7SensorKit
url = https://github.com/LoopKit/G7SensorKit.git
branch = main
url = https://github.com/loopandlearn/G7SensorKit.git
branch = trio
[submodule "OmniKit"]
path = OmniKit
url = https://github.com/LoopKit/OmniKit.git
branch = main
url = https://github.com/loopandlearn/OmniKit.git
branch = trio
[submodule "MinimedKit"]
path = MinimedKit
url = https://github.com/LoopKit/MinimedKit.git
branch = main
url = https://github.com/loopandlearn/MinimedKit.git
branch = trio
[submodule "LibreTransmitter"]
path = LibreTransmitter
url = https://github.com/LoopKit/LibreTransmitter.git
branch = main
url = https://github.com/loopandlearn/LibreTransmitter.git
branch = trio
[submodule "TidepoolService"]
path = TidepoolService
url = https://github.com/LoopKit/TidepoolService.git
url = https://github.com/loopandlearn/TidepoolService.git
branch = trio
2 changes: 1 addition & 1 deletion CGMBLEKit
52 changes: 30 additions & 22 deletions FreeAPS/Sources/APS/CGM/PluginSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,26 @@ final class PluginSource: GlucoseSource {
cgmManager?.cgmManagerDelegate = self
}

/// Function that fetches blood glucose data
/// This function combines two data fetching mechanisms (`callBLEFetch` and `fetchIfNeeded`) into a single publisher.
/// It returns the first non-empty result from either of the sources within a 5-minute timeout period.
/// If no valid data is fetched within the timeout, it returns an empty array.
///
/// - Parameter timer: An optional `DispatchTimer` (not used in the function but can be used to trigger fetch logic).
/// - Returns: An `AnyPublisher` that emits an array of `BloodGlucose` values or an empty array if an error occurs or the timeout is reached.
func fetch(_: DispatchTimer?) -> AnyPublisher<[BloodGlucose], Never> {
Publishers.Merge(
callBLEFetch(),
fetchIfNeeded()
)
.filter { !$0.isEmpty }
.first()
.timeout(60 * 5, scheduler: processQueue, options: nil, customError: nil)
.replaceError(with: [])
.eraseToAnyPublisher()
}

func callBLEFetch() -> AnyPublisher<[BloodGlucose], Never> {
Future<[BloodGlucose], Error> { [weak self] promise in
self?.promise = promise
}
Expand All @@ -35,17 +54,15 @@ final class PluginSource: GlucoseSource {
}

func fetchIfNeeded() -> AnyPublisher<[BloodGlucose], Never> {
Future<[BloodGlucose], Error> { _ in
Future<[BloodGlucose], Error> { [weak self] promise in
guard let self = self else { return }
self.processQueue.async {
guard let cgmManager = self.cgmManager else { return }
cgmManager.fetchNewDataIfNeeded { result in
self.processCGMReadingResult(cgmManager, readingResult: result) {
// nothing to do
}
promise(self.readCGMResult(readingResult: result))
}
}
}
.timeout(60, scheduler: processQueue, options: nil, customError: nil)
.replaceError(with: [])
.replaceEmpty(with: [])
.eraseToAnyPublisher()
Expand Down Expand Up @@ -92,11 +109,10 @@ extension PluginSource: CGMManagerDelegate {
glucoseManager?.cgmGlucoseSourceType = .none
}

func cgmManager(_ manager: CGMManager, hasNew readingResult: CGMReadingResult) {
func cgmManager(_: CGMManager, hasNew readingResult: CGMReadingResult) {
dispatchPrecondition(condition: .onQueue(processQueue))
processCGMReadingResult(manager, readingResult: readingResult) {
debug(.deviceManager, "CGM PLUGIN - Direct return done")
}
promise?(readCGMResult(readingResult: readingResult))
debug(.deviceManager, "CGM PLUGIN - Direct return done")
}

func cgmManager(_: LoopKit.CGMManager, hasNew events: [LoopKit.PersistedCgmEvent]) {
Expand Down Expand Up @@ -140,11 +156,7 @@ extension PluginSource: CGMManagerDelegate {
}
}

private func processCGMReadingResult(
_: CGMManager,
readingResult: CGMReadingResult,
completion: @escaping () -> Void
) {
private func readCGMResult(readingResult: CGMReadingResult) -> Result<[BloodGlucose], Error> {
debug(.deviceManager, "PLUGIN CGM - Process CGM Reading Result launched with \(readingResult)")
switch readingResult {
case let .newData(values):
Expand Down Expand Up @@ -177,18 +189,14 @@ extension PluginSource: CGMManagerDelegate {
transmitterID: sensorTransmitterID
)
}
promise?(.success(bloodGlucose))
completion()
return .success(bloodGlucose)
case .unreliableData:
// loopManager.receivedUnreliableCGMReading()
promise?(.failure(GlucoseDataError.unreliableData))
completion()
return .failure(GlucoseDataError.unreliableData)
case .noData:
promise?(.failure(GlucoseDataError.noData))
completion()
return .failure(GlucoseDataError.noData)
case let .error(error):
promise?(.failure(error))
completion()
return .failure(error)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ extension NightscoutConfig {
}

func connect() {
if let CheckURL = url.last, CheckURL == "/" {
let fixedURL = url.dropLast()
url = String(fixedURL)
}
guard let url = URL(string: url) else {
message = "Invalid URL"
return
Expand Down
24 changes: 12 additions & 12 deletions FreeAPS/Sources/Modules/Stat/View/ChartsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ struct ChartsView: View {
type: NSLocalizedString(
"Low",
comment: ""
) + " (\(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
) + " (<\(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
percent: fetched[0].decimal
),
.init(type: NSLocalizedString("In Range", comment: ""), percent: fetched[1].decimal),
.init(
type: NSLocalizedString(
"High",
comment: ""
) + " (\(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
) + " (>\(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
percent: fetched[2].decimal
)
]
Expand All @@ -142,12 +142,12 @@ struct ChartsView: View {
NSLocalizedString(
"Low",
comment: ""
) + " (\(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .red,
) + " (<\(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .red,
NSLocalizedString("In Range", comment: ""): .green,
NSLocalizedString(
"High",
comment: ""
) + " (\(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .orange
) + " (>\(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .orange
]).frame(maxHeight: 25)
}

Expand All @@ -161,18 +161,18 @@ struct ChartsView: View {
type: NSLocalizedString(
"Low",
comment: ""
) + " ( \(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
) + " (< \(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
percent: fetched[0].decimal
),
.init(
type: "> \(low.formatted(.number.precision(.fractionLength(fraction)))) - < \(high.formatted(.number.precision(.fractionLength(fraction))))",
type: "\(low.formatted(.number.precision(.fractionLength(fraction)))) - \(high.formatted(.number.precision(.fractionLength(fraction))))",
percent: fetched[1].decimal
),
.init(
type: NSLocalizedString(
"High",
comment: ""
) + " ( \(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
) + " (> \(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))",
percent: fetched[2].decimal
)
]
Expand All @@ -196,12 +196,12 @@ struct ChartsView: View {
NSLocalizedString(
"Low",
comment: ""
) + " ( \(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .red,
"> \(low.formatted(.number.precision(.fractionLength(fraction)))) - < \(high.formatted(.number.precision(.fractionLength(fraction))))": .green,
) + " (< \(low.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .red,
"\(low.formatted(.number.precision(.fractionLength(fraction)))) - \(high.formatted(.number.precision(.fractionLength(fraction))))": .green,
NSLocalizedString(
"High",
comment: ""
) + " ( \(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .orange
) + " (> \(high.formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))))": .orange
])
}

Expand Down Expand Up @@ -276,11 +276,11 @@ struct ChartsView: View {
let justGlucoseArray = glucose.compactMap({ each in Int(each.glucose as Int16) })
let totalReadings = justGlucoseArray.count

let hyperArray = glucose.filter({ $0.glucose >= hyperLimit })
let hyperArray = glucose.filter({ $0.glucose > hyperLimit })
let hyperReadings = hyperArray.compactMap({ each in each.glucose as Int16 }).count
let hyperPercentage = Double(hyperReadings) / Double(totalReadings) * 100

let hypoArray = glucose.filter({ $0.glucose <= hypoLimit })
let hypoArray = glucose.filter({ $0.glucose < hypoLimit })
let hypoReadings = hypoArray.compactMap({ each in each.glucose as Int16 }).count
let hypoPercentage = Double(hypoReadings) / Double(totalReadings) * 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extension TargetsEditor {

let timeValues = stride(from: 0.0, to: 1.days.timeInterval, by: 30.minutes.timeInterval).map { $0 }

var rateValues: [Double] {
var rateValues: [Decimal] {
switch units {
case .mgdL:
return stride(from: 72, to: 180.01, by: 1.0).map { $0 }
Expand All @@ -27,8 +27,8 @@ extension TargetsEditor {
units = profile.units
items = profile.targets.map { value in
let timeIndex = timeValues.firstIndex(of: Double(value.offset * 60)) ?? 0
let lowIndex = rateValues.firstIndex(of: Double(value.low)) ?? 0
let highIndex = lowIndex
let lowIndex = rateValues.firstIndex(of: value.low) ?? 0
let highIndex = rateValues.firstIndex(of: value.high) ?? 0
return Item(lowIndex: lowIndex, highIndex: highIndex, timeIndex: timeIndex)
}
}
Expand All @@ -50,14 +50,14 @@ extension TargetsEditor {

func save() {
let targets = items.map { item -> BGTargetEntry in
let fotmatter = DateFormatter()
fotmatter.timeZone = TimeZone(secondsFromGMT: 0)
fotmatter.dateFormat = "HH:mm:ss"
let formatter = DateFormatter()
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "HH:mm:ss"
let date = Date(timeIntervalSince1970: self.timeValues[item.timeIndex])
let minutes = Int(date.timeIntervalSince1970 / 60)
let low = Decimal(self.rateValues[item.lowIndex])
let low = self.rateValues[item.lowIndex]
let high = low
return BGTargetEntry(low: low, high: high, start: fotmatter.string(from: date), offset: minutes)
return BGTargetEntry(low: low, high: high, start: formatter.string(from: date), offset: minutes)
}
let profile = BGTargets(units: units, userPrefferedUnits: settingsManager.settings.units, targets: targets)
provider.saveProfile(profile)
Expand All @@ -68,8 +68,7 @@ extension TargetsEditor {
let uniq = Array(Set(self.items))
let sorted = uniq.sorted { $0.timeIndex < $1.timeIndex }
.map { item -> Item in
guard item.highIndex < item.lowIndex else { return item }
return Item(lowIndex: item.lowIndex, highIndex: item.lowIndex, timeIndex: item.timeIndex)
Item(lowIndex: item.lowIndex, highIndex: item.highIndex, timeIndex: item.timeIndex)
}
sorted.first?.timeIndex = 0
self.items = sorted
Expand Down
10 changes: 4 additions & 6 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,22 @@ platform :ios do
}
end

configure_bundle_id("FreeAPS", "#{BUNDLE_ID}", [
configure_bundle_id("Trio", "#{BUNDLE_ID}", [
Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT,
Spaceship::ConnectAPI::BundleIdCapability::Type::NFC_TAG_READING
])

configure_bundle_id("FreeAPSWatch WatchKit Extension", "#{BUNDLE_ID}.watchkitapp.watchkitextension", [
configure_bundle_id("Trio WatchKit Extension", "#{BUNDLE_ID}.watchkitapp.watchkitextension", [
Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT
])

configure_bundle_id("FreeAPSWatch", "#{BUNDLE_ID}.watchkitapp", [
configure_bundle_id("Trio Watch", "#{BUNDLE_ID}.watchkitapp", [
Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS
])

configure_bundle_id("LiveActivityExtension", "#{BUNDLE_ID}.LiveActivity", [
Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS
])
configure_bundle_id("Trio LiveActivity", "#{BUNDLE_ID}.LiveActivity", [])

end

Expand Down
Loading