Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion Loop/Managers/NightscoutDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,51 @@ final class NightscoutDataManager {
let loopName = Bundle.main.bundleDisplayName
let loopVersion = Bundle.main.shortVersionString

let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
//add new loop parameters
var loopParams : String = ""
var loopBGTlow : String = ""
var loopBGThigh : String = ""
var loopEventualBG : String = ""
if let loopBGRange = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.value(at: Date()), let userUnit = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.unit {
if userUnit == HKUnit.milligramsPerDeciliter() {
loopBGTlow = String(Int((loopBGRange.minValue)))
loopBGThigh = String(Int((loopBGRange.maxValue)))
}
else
{
loopBGTlow = String(format:"%.1f", (loopBGRange.minValue))
loopBGThigh = String(format:"%.1f",(loopBGRange.maxValue))
}
}

else {
loopBGTlow = "N/A"
loopBGThigh = "N/A"
}

if let loopEventualBGquantity = predictedGlucose?.last?.quantity, let userUnit = deviceDataManager.loopManager.settings.glucoseTargetRangeSchedule?.unit {
if userUnit == HKUnit.milligramsPerDeciliter() {
loopEventualBG = String(Int(loopEventualBGquantity.doubleValue(for: userUnit)))
}
else
{
loopEventualBG = String(format:"%.1f",loopEventualBGquantity.doubleValue(for: userUnit))
}
}
else
{
loopEventualBG = "N/A"
}

loopParams = "BGTargets (" + loopBGTlow + ":" + loopBGThigh + ") | EvBG " + loopEventualBG + " | " + loopName

//upload loopParams instead of just loopName
//that is the only pill that has the option to modify the text
let loopStatus = LoopStatus(name: loopParams, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than overriding the "name" field, a new field/fields should be added to the upload structure in the rileylink_ios project.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ps2 I can do that no problem, but how will NS display it ? I dont think NS will just create a new pill. But I may be wrong on that!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, supporting this in NS would require an NS PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenstack Is it a complicated thing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kdisimone @ps2 it is still possible to pull to the dev?


//if you wish to have the Loop pill clean, without the added BGtargets and EventualBG showing, remove the slashes on code line below, and add slashes to code line above

//let loopStatus = LoopStatus(name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)

uploadDeviceStatus(nil, loopStatus: loopStatus, includeUploaderStatus: false)

Expand Down