diff --git a/FreeAPS/Sources/APS/APSManager.swift b/FreeAPS/Sources/APS/APSManager.swift index 9aa83a005..236a13bc5 100644 --- a/FreeAPS/Sources/APS/APSManager.swift +++ b/FreeAPS/Sources/APS/APSManager.swift @@ -197,6 +197,7 @@ final class BaseAPSManager: APSManager, Injectable { // Open loop completed guard self.settings.closedLoop else { + self.nightscout.uploadStatus() return Just(()).setFailureType(to: Error.self).eraseToAnyPublisher() } @@ -238,6 +239,9 @@ final class BaseAPSManager: APSManager, Injectable { loopStats(loopStatRecord: loopStatRecord) + // Create a statistics.json + statistics() + if settings.closedLoop { reportEnacted(received: error == nil) } @@ -659,9 +663,6 @@ final class BaseAPSManager: APSManager, Injectable { // Create a tdd.json tdd(enacted_: enacted) - // Create a statistics.json - statistics() - debug(.apsManager, "Suggestion enacted. Received: \(received)") DispatchQueue.main.async { self.broadcaster.notify(EnactedSuggestionObserver.self, on: .main) { diff --git a/FreeAPS/Sources/Services/Network/NightscoutManager.swift b/FreeAPS/Sources/Services/Network/NightscoutManager.swift index 40a32c75c..20f8fb5f3 100644 --- a/FreeAPS/Sources/Services/Network/NightscoutManager.swift +++ b/FreeAPS/Sources/Services/Network/NightscoutManager.swift @@ -189,12 +189,26 @@ final class BaseNightscoutManager: NightscoutManager, Injectable { suggested?.predictions = nil } - let openapsStatus = OpenAPSStatus( - iob: iob?.first, - suggested: suggested, - enacted: enacted, - version: "0.7.0" - ) + let loopIsClosed = settingsManager.settings.closedLoop + + var openapsStatus: OpenAPSStatus + + // Only upload suggested in Open Loop Mode. Only upload enacted in Closed Loop Mode. + if loopIsClosed { + openapsStatus = OpenAPSStatus( + iob: iob?.first, + suggested: nil, + enacted: enacted, + version: "0.7.1" + ) + } else { + openapsStatus = OpenAPSStatus( + iob: iob?.first, + suggested: suggested, + enacted: nil, + version: "0.7.1" + ) + } let battery = storage.retrieve(OpenAPS.Monitor.battery, as: Battery.self)