Skip to content

Commit

Permalink
Merge pull request #355 from MikePlante1/sage
Browse files Browse the repository at this point in the history
Upload SAGE to NS for Dexcom
  • Loading branch information
dnzxy authored Jul 21, 2024
2 parents 8303f0a + f351b9b commit f5a8d97
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions FreeAPS/Sources/APS/CGM/PluginSource.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import CGMBLEKit
import Combine
import Foundation
import G7SensorKit
import LibreTransmitter
import LoopKit
import LoopKitUI
Expand Down Expand Up @@ -162,11 +164,29 @@ extension PluginSource: CGMManagerDelegate {
case let .newData(values):

var sensorActivatedAt: Date?
var sensorStartDate: Date?
var sensorTransmitterID: String?
/// specific for Libre transmitter and send SAGE

/// SAGE
if let cgmTransmitterManager = cgmManager as? LibreTransmitterManagerV3 {
sensorActivatedAt = cgmTransmitterManager.sensorInfoObservable.activatedAt
sensorTransmitterID = cgmTransmitterManager.sensorInfoObservable.sensorSerial
let sensorInfo = cgmTransmitterManager.sensorInfoObservable
sensorActivatedAt = sensorInfo.activatedAt
sensorStartDate = sensorInfo.activatedAt
sensorTransmitterID = sensorInfo.sensorSerial
} else if let cgmTransmitterManager = cgmManager as? G5CGMManager {
let latestReading = cgmTransmitterManager.latestReading
sensorActivatedAt = latestReading?.activationDate
sensorStartDate = latestReading?.sessionStartDate
sensorTransmitterID = latestReading?.transmitterID
} else if let cgmTransmitterManager = cgmManager as? G6CGMManager {
let latestReading = cgmTransmitterManager.latestReading
sensorActivatedAt = latestReading?.activationDate
sensorStartDate = latestReading?.sessionStartDate
sensorTransmitterID = latestReading?.transmitterID
} else if let cgmTransmitterManager = cgmManager as? G7CGMManager {
sensorActivatedAt = cgmTransmitterManager.sensorActivatedAt
sensorStartDate = cgmTransmitterManager.sensorActivatedAt
sensorTransmitterID = cgmTransmitterManager.sensorName
}

let bloodGlucose = values.compactMap { newGlucoseSample -> BloodGlucose? in
Expand All @@ -185,7 +205,7 @@ extension PluginSource: CGMManagerDelegate {
glucose: value,
type: "sgv",
activationDate: sensorActivatedAt,
sessionStartDate: sensorActivatedAt,
sessionStartDate: sensorStartDate,
transmitterID: sensorTransmitterID
)
}
Expand Down

0 comments on commit f5a8d97

Please sign in to comment.