Skip to content

Commit

Permalink
Merge pull request #554 from gui-dos/develop
Browse files Browse the repository at this point in the history
Workaround for Xcode 16; new LLU `la` subdomain and 4.11 Account-Id header
  • Loading branch information
JohanDegraeve authored Jul 17, 2024
2 parents 6f3a469 + 13e4a1e commit 238fbae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class LibreNFC: NSObject, NFCTagReaderSessionDelegate {

tag.customCommand(requestFlags: .highDataRate, customCommandCode: Int(cmd.code), customRequestParameters: cmd.parameters) { response, error in

let debugInfo = "NFC: '" + subCmd.description + " command response " + response.count.description + " bytes : 0x" + response.toHexString() + ", error: " + (error?.localizedDescription ?? "none")
let debugInfo = "NFC: '" + subCmd.description + " command response " + response.count.description + " bytes : 0x" + response.toHexString() + ", error: " + error.debugDescription

xdrip.trace("%{public}@", log: self.log, category: ConstantsLog.categoryLibreNFC, type: .info, debugInfo)

Expand Down
2 changes: 1 addition & 1 deletion xdrip/Constants/ConstantsLibreLinkUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
enum ConstantsLibreLinkUp {

/// string to hold the default LibreLinkUp version number
static let libreLinkUpVersionDefault: String = "4.7.0"
static let libreLinkUpVersionDefault: String = "4.11.0"

/// double to hold maximum sensor days for Libre sensors that upload to LibreLinkUp
/// currently easy as they are all the same at 14 days exactly (LibreLink doesn't upload the extra 12 hours)
Expand Down
5 changes: 5 additions & 0 deletions xdrip/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ extension String {
// sha1() here is a function in CryptoSwift Library
return Data(self.utf8).sha1().hexEncodedString()
}

func sha256() -> String {
// sha256() here is a function in CryptoSwift Library
return Data(self.utf8).sha256().hexEncodedString()
}

/// creates uicolor interpreting hex as hex color code, example #CED430
func hexStringToUIColor () -> UIColor {
Expand Down
2 changes: 2 additions & 0 deletions xdrip/Managers/LibreLinkUp/LibreLinkUpFollowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ class LibreLinkUpFollowManager: NSObject {
// this is pretty much the same request as done in requestLogin()
var request = URLRequest(url: url)
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
request.setValue((libreLinkUpId ?? "").sha256(), forHTTPHeaderField: "Account-Id")

for (header, value) in libreLinkUpRequestHeaders {
request.setValue(value, forHTTPHeaderField: header)
Expand Down Expand Up @@ -627,6 +628,7 @@ class LibreLinkUpFollowManager: NSObject {
// this is pretty much the same request as done in loginRequest()
var request = URLRequest(url: url)
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
request.setValue((libreLinkUpId ?? "").sha256(), forHTTPHeaderField: "Account-Id")

for (header, value) in libreLinkUpRequestHeaders {
request.setValue(value, forHTTPHeaderField: header)
Expand Down
11 changes: 9 additions & 2 deletions xdrip/Managers/LibreLinkUp/LibreLinkUpModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum LibreLinkUpRegion: Int, CaseIterable {
case eu2 = 7
case fr = 8
case jp = 9
case us = 10
case la = 10
case us = 11


init?() {
Expand Down Expand Up @@ -56,6 +57,8 @@ public enum LibreLinkUpRegion: Int, CaseIterable {
self = .fr
case "jp":
self = .jp
case "la":
self = .la
case "us":
self = .us
default:
Expand Down Expand Up @@ -88,6 +91,8 @@ public enum LibreLinkUpRegion: Int, CaseIterable {
return "France"
case .jp:
return "Japan"
case .la:
return "Latin America"
case .us:
return "United States"

Expand Down Expand Up @@ -165,8 +170,10 @@ public enum LibreLinkUpRegion: Int, CaseIterable {
return 8
case 9:// jp
return 9
case 10:// us
case 10:// la
return 10
case 11:// us
return 11
default:
fatalError("in libreLinkUpRawValue, unknown case")
}
Expand Down

0 comments on commit 238fbae

Please sign in to comment.