Skip to content

Commit

Permalink
Reduce NS data trafic
Browse files Browse the repository at this point in the history
1.Upload status even when in open loop.
2. When in closed loop => upload enacted.json, when in open loop => upload suggested.json, not both as the same time.
3. Update oref0 version info (0.7.1)
  • Loading branch information
Jon-b-m committed Dec 10, 2022
1 parent 6f5ffef commit 55e9ede
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
7 changes: 4 additions & 3 deletions FreeAPS/Sources/APS/APSManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -238,6 +239,9 @@ final class BaseAPSManager: APSManager, Injectable {

loopStats(loopStatRecord: loopStatRecord)

// Create a statistics.json
statistics()

if settings.closedLoop {
reportEnacted(received: error == nil)
}
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 20 additions & 6 deletions FreeAPS/Sources/Services/Network/NightscoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 55e9ede

Please sign in to comment.