@@ -447,7 +447,7 @@ extension LibreTransmitterManager {
447447 glucose += LibreGlucose.fromHistoryMeasurements(sortedHistory, nativeCalibrationData: calibrationData)
448448 }*/
449449
450- let newGlucose = glucosesToSamplesFilter ( glucose, startDate: getStartDateForFilter ( ) )
450+ var newGlucose = glucosesToSamplesFilter ( glucose, startDate: getStartDateForFilter ( ) )
451451
452452 if newGlucose. isEmpty {
453453 self . countTimesWithoutData &+= 1
@@ -459,6 +459,10 @@ extension LibreTransmitterManager {
459459
460460 //todo: predictions also for libre2 bluetooth data
461461 //self.latestPrediction = prediction?.first
462+ var predictions : [ LibreGlucose ] = [ ]
463+
464+ overcalibrate ( entries: & newGlucose, prediction: & predictions)
465+
462466 self . setObservables ( sensorData: nil , bleData: bleData, metaData: device)
463467
464468 self . logger. debug ( " dabear:: handleGoodReading returned with \( newGlucose. count) entries " )
@@ -638,6 +642,12 @@ extension LibreTransmitterManager {
638642 entries += LibreGlucose . fromHistoryMeasurements ( history, nativeCalibrationData: calibration)
639643 }
640644
645+ overcalibrate ( entries: & entries, prediction: & prediction)
646+
647+ return ( glucose: entries, prediction: prediction)
648+ }
649+
650+ private func overcalibrate( entries: inout [ LibreGlucose ] , prediction: inout [ LibreGlucose ] ) {
641651 // overcalibrate
642652 var overcalibration : ( ( Double ) -> ( Double ) ) ? = nil
643653 delegateQueue. sync { overcalibration = cgmManagerDelegate? . overcalibration ( for: self ) }
@@ -654,8 +664,6 @@ extension LibreTransmitterManager {
654664 entries = overcalibrate ( entries: entries)
655665 prediction = overcalibrate ( entries: prediction)
656666 }
657-
658- return ( glucose: entries, prediction: prediction)
659667 }
660668
661669 public func handleGoodReading( data: SensorData ? , _ callback: @escaping ( LibreError ? , GlucoseArrayWithPrediction ? ) -> Void ) {
0 commit comments