Skip to content

Commit

Permalink
fix #131 - with 4.2 a check was added on slope parameters. This was t…
Browse files Browse the repository at this point in the history
…aken over from bubbledevteam pull request. Apparently this causes Libre 1 A2 failure.
  • Loading branch information
JohanDegraeve committed Jul 21, 2020
1 parent 1eada0a commit b8d5b0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ public struct Libre1DerivedAlgorithmParameters: Codable, CustomStringConvertible
return "LibreDerivedAlgorithmParameters:: slopeslope: \(slope_slope), slopeoffset: \(slope_offset), offsetoffset: \(offset_offset), offsetSlope: \(offset_slope), extraSlope: \(extraSlope), extraOffset: \(extraOffset), isValidForFooterWithReverseCRCs: \(isValidForFooterWithReverseCRCs)"
}

/// init will fail if slope_slope == 0 && slope_offset == 0 && offset_slope == 0 && offset_offset == 0
public init?(slope_slope: Double, slope_offset:Double, offset_slope: Double, offset_offset: Double, isValidForFooterWithReverseCRCs: Int, extraSlope: Double, extraOffset: Double, sensorSerialNumber:String) {

guard slope_slope != 0 &&
slope_offset != 0 &&
offset_slope != 0 &&
offset_offset != 0 else {return nil}
public init(slope_slope: Double, slope_offset:Double, offset_slope: Double, offset_offset: Double, isValidForFooterWithReverseCRCs: Int, extraSlope: Double, extraOffset: Double, sensorSerialNumber:String) {

self.slope_slope = slope_slope
self.slope_offset = slope_offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ class LibreDataParser {
LibreOOPClient.getOopWebCalibrationStatus(bytes: libreData, libreSensorSerialNumber: libreSensorSerialNumber, oopWebSite: oopWebSite, oopWebToken: oopWebToken) { (oopWebCalibrationStatus, xDripError) in

if let oopWebCalibrationStatus = oopWebCalibrationStatus as? OopWebCalibrationStatus,
let slope = oopWebCalibrationStatus.slope,
let libre1DerivedAlgorithmParameters = Libre1DerivedAlgorithmParameters(slope_slope: slope.slopeSlope ?? 0, slope_offset: slope.slopeOffset ?? 0, offset_slope: slope.offsetSlope ?? 0, offset_offset: slope.offsetOffset ?? 0, isValidForFooterWithReverseCRCs: Int(slope.isValidForFooterWithReverseCRCs ?? 1), extraSlope: 1.0, extraOffset: 0.0, sensorSerialNumber: libreSensorSerialNumber.serialNumber) {
let slope = oopWebCalibrationStatus.slope {

let libre1DerivedAlgorithmParameters = Libre1DerivedAlgorithmParameters(slope_slope: slope.slopeSlope ?? 0, slope_offset: slope.slopeOffset ?? 0, offset_slope: slope.offsetSlope ?? 0, offset_offset: slope.offsetOffset ?? 0, isValidForFooterWithReverseCRCs: Int(slope.isValidForFooterWithReverseCRCs ?? 1), extraSlope: 1.0, extraOffset: 0.0, sensorSerialNumber: libreSensorSerialNumber.serialNumber)

// store result in UserDefaults, next time, server will not be used anymore, we will use the stored value
UserDefaults.standard.libre1DerivedAlgorithmParameters = libre1DerivedAlgorithmParameters
Expand Down

0 comments on commit b8d5b0d

Please sign in to comment.