Libre : trace in case values are ignored because equal (flat) values are detected

This commit is contained in:
Johan Degraeve 2021-01-19 22:00:40 +01:00
parent 08c9027b49
commit f2b8434501
3 changed files with 14 additions and 0 deletions

View File

@ -1,4 +1,8 @@
import Foundation
import OSLog
/// for trace
fileprivate let log = OSLog(subsystem: ConstantsLog.subSystem, category: ConstantsLog.categoryLibre2BLEUtilities)
/// - utilities for Libre 2 data processing, here it's for the case where data is read via bluetooth
/// - if read via NFC or other transmitter, go to PreLibre2
@ -150,7 +154,11 @@ class Libre2BLEUtilities {
// check if the rawGlucoseValues and the previousRawGlucoseValues have at least 5 equal values, if so this is an expired sensor that keeps sending the same values, in that case no further processing
if let previousRawGlucoseValues = UserDefaults.standard.previousRawGlucoseValues {
if rawGlucoseValues.hasEqualValues(howManyToCheck: 5, otherArray: previousRawGlucoseValues) {
trace("in parseBLEData, did detect flat values, returning empty GlucoseData array", log: log, category: ConstantsLog.categoryLibreDataParser, type: .info)
return ([GlucoseData](), wearTimeMinutes)
}
}

View File

@ -106,6 +106,9 @@ class LibreDataParser {
// check if the trend and the previous raw values have at least 5 equal values, if so this is an expired sensor that keeps sending the same values, in that case no further processing
if trend.hasEqualValues(howManyToCheck: 5, otherArray: previousRawValues) {
trace("in libreDataProcessor, did detect flat values, returning empty GlucoseData array", log: log, category: ConstantsLog.categoryLibreDataParser, type: .info)
return ([GlucoseData](), sensorState, sensorTimeInMinutes)
}

View File

@ -148,5 +148,8 @@ enum ConstantsLog {
/// for use in cgm transmitter bubble
static let categoryLibreSensorType = "categoryLibreSensorType "
/// for use in Libre2BLEUtilities
static let categoryLibre2BLEUtilities = "Libre2BLEUtilities "
}