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

Support the newer libre 2 plus European sensors. #886

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,22 @@ extension String {
}

public enum SensorType: String, CustomStringConvertible {
case libre1 = "DF"
case libre1A2 = "A2"
case libre2 = "9D"
case libre1 = "DF"
case libre1A2 = "A2"
case libre2 = "9D"
case libre2C5 = "C5"
case libreUS14day = "E5"
case libreUS14day = "E5"
case libreUS14dayE6 = "E6"
case libreProH = "70"
case libre2Plus = "C6"

public var description: String {
switch self {
case .libre1:
return "Libre 1"
case .libre1A2:
return "Libre 1 A2"
case .libre2, .libre2C5:
case .libre2, .libre2C5, .libre2Plus:
return "Libre 2"
case .libreUS14day, .libreUS14dayE6:
return "Libre US"
Expand All @@ -107,7 +108,7 @@ public extension SensorType {

let start = patchInfo[0..<2].uppercased()

let choices: [String: SensorType] = ["DF": .libre1, "A2": .libre1A2, "9D": .libre2, "C5": .libre2, "E5": .libreUS14day, "E6": .libreUS14dayE6, "70": .libreProH]
let choices: [String: SensorType] = ["DF": .libre1, "A2": .libre1A2, "9D": .libre2, "C5": .libre2C5, "C6": .libre2Plus, "E5": .libreUS14day, "E6": .libreUS14dayE6, "70": .libreProH]

if let res = choices[start] {
self = res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 == .libre2C5 || type == .libreUS14day || type == .libreUS14dayE6 else {
guard type == .libre2 || type == .libre2C5 || type == .libreUS14day || type == .libreUS14dayE6 || type == .libre2Plus else {
struct DecryptFRAMError: Error {
let errorDescription = "Unsupported sensor type"
}
Expand All @@ -24,8 +24,9 @@ public enum Libre2 {
return 0xcadc
}
return UInt16(info[5], info[4])
case .libre2, .libre2C5:
case .libre2, .libre2C5, .libre2Plus:
return UInt16(info[5], info[4]) ^ 0x44

default: fatalError("Unsupported sensor type")
}
}
Expand Down