Skip to content

Commit

Permalink
Merge pull request #112 from avouspierre/SAGE+Libre
Browse files Browse the repository at this point in the history
Fix SAGE uploads in NS for Libre Transmitter
  • Loading branch information
bjornoleh authored Apr 15, 2024
2 parents e4fa359 + 15713b0 commit 1748082
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions FreeAPS/Sources/APS/CGM/PluginSource.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Combine
import Foundation
import LibreTransmitter
import LoopKit
import LoopKitUI

Expand Down Expand Up @@ -148,8 +149,17 @@ extension PluginSource: CGMManagerDelegate {
switch readingResult {
case let .newData(values):

var sensorActivatedAt: Date?
var sensorTransmitterID: String?
/// specific for Libre transmitter and send SAGE
if let cgmTransmitterManager = cgmManager as? LibreTransmitterManagerV3 {
sensorActivatedAt = cgmTransmitterManager.sensorInfoObservable.activatedAt
sensorTransmitterID = cgmTransmitterManager.sensorInfoObservable.sensorSerial
}

let bloodGlucose = values.compactMap { newGlucoseSample -> BloodGlucose? in
let quantity = newGlucoseSample.quantity

let value = Int(quantity.doubleValue(for: .milligramsPerDeciliter))
return BloodGlucose(
_id: UUID().uuidString,
Expand All @@ -161,10 +171,10 @@ extension PluginSource: CGMManagerDelegate {
filtered: nil,
noise: nil,
glucose: value,
type: "sgv"
// activationDate: activationDate,
// sessionStartDate: sessionStartDate
// transmitterID: self.transmitterID
type: "sgv",
activationDate: sensorActivatedAt,
sessionStartDate: sensorActivatedAt,
transmitterID: sensorTransmitterID
)
}
promise?(.success(bloodGlucose))
Expand Down

0 comments on commit 1748082

Please sign in to comment.