Просмотр исходного кода

New Libre 2 versions. Support for patchInfo starting with "c5" (#104)

Ported from the xdripswift repo
Jon B Mårtensson 2 лет назад
Родитель
Сommit
3be9604fe6

+ 3 - 2
Dependencies/LibreTransmitter/Sources/LibreTransmitter/Bluetooth/LibreTransmitterMetadata.swift

@@ -80,6 +80,7 @@ public enum SensorType: String, CustomStringConvertible {
     case libre1    = "DF"
     case libre1A2 =  "A2"
     case libre2    = "9D"
+    case libre2C5 = "C5"
     case libreUS14day   = "E5"
     case libreUS14dayE6 = "E6"
     case libreProH = "70"
@@ -90,7 +91,7 @@ public enum SensorType: String, CustomStringConvertible {
             return "Libre 1"
         case .libre1A2:
             return "Libre 1 A2"
-        case .libre2:
+        case .libre2, .libre2C5:
             return "Libre 2"
         case .libreUS14day, .libreUS14dayE6:
             return "Libre US"
@@ -106,7 +107,7 @@ public extension SensorType {
 
         let start = patchInfo[0..<2].uppercased()
 
-        let choices: [String: SensorType] = ["DF": .libre1, "A2": .libre1A2, "9D": .libre2, "E5": .libreUS14day, "E6": .libreUS14dayE6, "70": .libreProH]
+        let choices: [String: SensorType] = ["DF": .libre1, "A2": .libre1A2, "9D": .libre2, "C5": .libre2, "E5": .libreUS14day, "E6": .libreUS14dayE6, "70": .libreProH]
 
         if let res = choices[start] {
             self = res

+ 2 - 2
Dependencies/LibreTransmitter/Sources/LibreTransmitter/LibreSensor/SensorContents/PreLibre2.swift

@@ -9,7 +9,7 @@ public enum Libre2 {
     ///   - data: Encrypted FRAM data
     /// - Returns: Decrypted FRAM data
     static public func decryptFRAM(type: SensorType, id: [UInt8], info: [UInt8], data: [UInt8]) throws -> [UInt8] {
-        guard type == .libre2 || type == .libreUS14day || type == .libreUS14dayE6 else {
+        guard type == .libre2 || type == .libre2C5 || type == .libreUS14day || type == .libreUS14dayE6 else {
             struct DecryptFRAMError: Error {
                 let errorDescription = "Unsupported sensor type"
             }
@@ -24,7 +24,7 @@ public enum Libre2 {
                     return 0xcadc
                 }
                 return UInt16(info[5], info[4])
-            case .libre2:
+            case .libre2, .libre2C5:
                 return UInt16(info[5], info[4]) ^ 0x44
             default: fatalError("Unsupported sensor type")
             }

+ 7 - 7
FreeAPS/Sources/APS/CGM/CGMType.swift

@@ -5,8 +5,8 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
 
     case nightscout
     case xdrip
-    case dexcomG6
     case dexcomG5
+    case dexcomG6
     case dexcomG7
     case simulator
     case libreTransmitter
@@ -21,10 +21,10 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
             return "xDrip"
         case .glucoseDirect:
             return "Glucose Direct"
-        case .dexcomG6:
-            return "Dexcom G6"
         case .dexcomG5:
             return "Dexcom G5"
+        case .dexcomG6:
+            return "Dexcom G6"
         case .dexcomG7:
             return "Dexcom G7"
         case .simulator:
@@ -45,12 +45,12 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
             return URL(string: "xdripswift://")!
         case .glucoseDirect:
             return URL(string: "libredirect://")!
+        case .dexcomG5:
+            return URL(string: "dexcomgcgm://")!
         case .dexcomG6:
             return URL(string: "dexcomg6://")!
         case .dexcomG7:
             return URL(string: "dexcomg7://")!
-        case .dexcomG5:
-            return URL(string: "dexcomgcgm://")!
         case .simulator:
             return nil
         case .libreTransmitter:
@@ -77,10 +77,10 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
                 "Using shared app group with external CGM app xDrip4iOS",
                 comment: "Shared app group xDrip4iOS"
             )
-        case .dexcomG6:
-            return NSLocalizedString("Dexcom G6 app", comment: "Dexcom G6 app")
         case .dexcomG5:
             return NSLocalizedString("Native G5 app", comment: "Native G5 app")
+        case .dexcomG6:
+            return NSLocalizedString("Dexcom G6 app", comment: "Dexcom G6 app")
         case .dexcomG7:
             return NSLocalizedString("Dexcom G7 app", comment: "Dexcom G76 app")
         case .simulator:

+ 4 - 4
FreeAPS/Sources/Modules/CGM/View/CGMSetupView.swift

@@ -30,15 +30,15 @@ extension CGM {
             }
 
             switch CGMType {
-            case .dexcomG6:
-                setupViewController = G6CGMManager.setupViewController(
+            case .dexcomG5:
+                setupViewController = G5CGMManager.setupViewController(
                     bluetoothProvider: bluetoothManager,
                     displayGlucoseUnitObservable: displayGlucoseUnitObservable,
                     colorPalette: .default,
                     allowDebugFeatures: false
                 )
-            case .dexcomG5:
-                setupViewController = G5CGMManager.setupViewController(
+            case .dexcomG6:
+                setupViewController = G6CGMManager.setupViewController(
                     bluetoothProvider: bluetoothManager,
                     displayGlucoseUnitObservable: displayGlucoseUnitObservable,
                     colorPalette: .default,