Просмотр исходного кода

Merge pull request #158 from dnzxy/fix-nightscout-status-mmol

Fix NS devicestatus Enacted and Suggested mmol/L Parsing
polscm32 1 год назад
Родитель
Сommit
8009444353

+ 7 - 3
FreeAPS/Sources/Services/Network/Nightscout/NightscoutManager.swift

@@ -429,9 +429,14 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
         var modifiedSuggestedDetermination = fetchedSuggestedDetermination
         if var suggestion = fetchedSuggestedDetermination {
             suggestion.timestamp = suggestion.deliverAt
-
+            
             if settingsManager.settings.units == .mmolL {
                 suggestion.reason = parseReasonGlucoseValuesToMmolL(suggestion.reason)
+                // TODO: verify that these parsings are needed for 3rd party apps, e.g., LoopFollow
+                suggestion.current_target = suggestion.current_target?.asMmolL
+                suggestion.minGuardBG = suggestion.minGuardBG?.asMmolL
+                suggestion.minPredBG = suggestion.minPredBG?.asMmolL
+                suggestion.threshold = suggestion.threshold?.asMmolL
             }
             // Check whether the last suggestion that was uploaded is the same that is fetched again when we are attempting to upload the enacted determination
             // Apparently we are too fast; so the flag update is not fast enough to have the predicate filter last suggestion out
@@ -447,8 +452,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
             var modifiedFetchedEnactedDetermination = fetchedEnactedDetermination
             modifiedFetchedEnactedDetermination?
                 .reason = parseReasonGlucoseValuesToMmolL(fetchedEnacted.reason)
-
-            modifiedFetchedEnactedDetermination?.bg = fetchedEnacted.bg?.asMmolL
+            // TODO: verify that these parsings are needed for 3rd party apps, e.g., LoopFollow
             modifiedFetchedEnactedDetermination?.current_target = fetchedEnacted.current_target?.asMmolL
             modifiedFetchedEnactedDetermination?.minGuardBG = fetchedEnacted.minGuardBG?.asMmolL
             modifiedFetchedEnactedDetermination?.minPredBG = fetchedEnacted.minPredBG?.asMmolL