@@ -138,7 +138,41 @@ final class NightscoutDataManager {
138138 let loopName = Bundle . main. bundleDisplayName
139139 let loopVersion = Bundle . main. shortVersionString
140140
141- let loopStatus = LoopStatus ( name: loopName, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
141+ //add new loop parameters
142+ var loopParams : String = " "
143+ var loopBGTlow : String = " "
144+ var loopBGThigh : String = " "
145+ var loopEventualBG : String = " "
146+ if let loopBGRange = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . value ( at: Date ( ) ) , let userUnit = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . unit {
147+ if userUnit == HKUnit . milligramsPerDeciliter ( ) {
148+ loopBGTlow = String ( Int ( ( loopBGRange. minValue) ) )
149+ loopBGThigh = String ( Int ( ( loopBGRange. maxValue) ) )
150+ }
151+ else
152+ {
153+ loopBGTlow = String ( format: " %.1f " , ( loopBGRange. minValue) )
154+ loopBGThigh = String ( format: " %.1f " , ( loopBGRange. maxValue) )
155+ }
156+ }
157+
158+ else {
159+ loopBGTlow = " N/A "
160+ loopBGThigh = " N/A "
161+ }
162+
163+ if let loopEventualBGquantity = predictedGlucose? . last? . quantity, let userUnit = deviceDataManager. loopManager. settings. glucoseTargetRangeSchedule? . unit {
164+ loopEventualBG = String ( Int ( loopEventualBGquantity. doubleValue ( for: userUnit) ) )
165+ }
166+ else
167+ {
168+ loopEventualBG = " N/A "
169+ }
170+
171+ loopParams = " BGTargets ( " + loopBGTlow + " : " + loopBGThigh + " ) | EvBG " + loopEventualBG + " | " + loopName
172+
173+ //upload loopParams instead of just loopName
174+ //that is the only pill that has the option to modify the text
175+ let loopStatus = LoopStatus ( name: loopParams, version: loopVersion, timestamp: statusTime, iob: iob, cob: cob, predicted: predicted, recommendedTempBasal: recommended, recommendedBolus: recommendedBolus, enacted: loopEnacted, failureReason: loopError)
142176
143177 uploadDeviceStatus ( nil , loopStatus: loopStatus, includeUploaderStatus: false )
144178
0 commit comments