@@ -116,22 +116,22 @@ public class G7CGMManager: CGMManager {
116116 guard let activatedAt = sensorActivatedAt else {
117117 return nil
118118 }
119- return activatedAt. addingTimeInterval ( G7Sensor . lifetime)
119+ return activatedAt. addingTimeInterval ( state . sensorType . lifetime)
120120 }
121121
122122 public var sensorEndsAt : Date ? {
123123 guard let activatedAt = sensorActivatedAt else {
124124 return nil
125125 }
126- return activatedAt. addingTimeInterval ( G7Sensor . lifetime + G7Sensor . gracePeriod)
126+ return activatedAt. addingTimeInterval ( state . sensorType . lifetime + state . sensorType . gracePeriod)
127127 }
128128
129129
130130 public var sensorFinishesWarmupAt : Date ? {
131131 guard let activatedAt = sensorActivatedAt else {
132132 return nil
133133 }
134- return activatedAt. addingTimeInterval ( G7Sensor . warmupDuration)
134+ return activatedAt. addingTimeInterval ( state . sensorType . warmupDuration)
135135 }
136136
137137 public var latestReading : G7GlucoseMessage ? {
@@ -229,7 +229,9 @@ public class G7CGMManager: CGMManager {
229229
230230 public static let pluginIdentifier : String = " G7CGMManager "
231231
232- public let localizedTitle = LocalizedString ( " Dexcom G7 " , comment: " CGM display title " )
232+ public var localizedTitle : String {
233+ return state. sensorType. displayName
234+ }
233235
234236 public let isOnboarded = true // No distinction between created and onboarded
235237
@@ -242,6 +244,7 @@ public class G7CGMManager: CGMManager {
242244
243245 mutateState { state in
244246 state. sensorID = nil
247+ state. sensorType = . unknown
245248 state. activatedAt = nil
246249 }
247250 sensor. scanForNewSensor ( )
@@ -251,7 +254,7 @@ public class G7CGMManager: CGMManager {
251254 return HKDevice (
252255 name: state. sensorID ?? " Unknown " ,
253256 manufacturer: " Dexcom " ,
254- model: " G7 " ,
257+ model: state . sensorType . rawValue ,
255258 hardwareVersion: nil ,
256259 firmwareVersion: nil ,
257260 softwareVersion: " CGMBLEKit " + String( G7SensorKitVersionNumber) ,
@@ -292,14 +295,15 @@ extension G7CGMManager: G7SensorDelegate {
292295 if shouldSwitchToNewSensor {
293296 mutateState { state in
294297 state. sensorID = name
298+ state. sensorType = sensor. sensorType
295299 state. activatedAt = activatedAt
296300 }
297301 let event = PersistedCgmEvent (
298302 date: activatedAt,
299303 type: . sensorStart,
300304 deviceIdentifier: name,
301- expectedLifetime: . hours( 24 * 10 + 12 ) ,
302- warmupPeriod: . hours( 2 )
305+ expectedLifetime: . hours( sensor . sensorType . lifetime . hours + sensor . sensorType . gracePeriod . hours ) ,
306+ warmupPeriod: . hours( sensor . sensorType . warmupDuration . hours )
303307 )
304308 delegate. notify { delegate in
305309 delegate? . cgmManager ( self , hasNew: [ event] )
0 commit comments