Skip to content

Commit 786f561

Browse files
authored
Merge pull request #217 from ps2/dev
v0.11.0
2 parents c90b9b5 + 79358ad commit 786f561

34 files changed

+352
-108
lines changed

MinimedKit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.10.0</string>
18+
<string>0.11.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

MinimedKit/PumpEventType.swift

+19-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public enum PumpEventType: UInt8 {
2222
case ChangeTime = 0x17
2323
case JournalEntryPumpLowBattery = 0x19
2424
case Battery = 0x1a
25+
case SetAutoOff = 0x1b
2526
case Suspend = 0x1e
2627
case Resume = 0x1f
2728
case Rewind = 0x21
29+
case ClearSettings = 0x22
2830
case ChangeChildBlockEnable = 0x23
2931
case ChangeMaxBolus = 0x24
3032
case EnableDisableRemote = 0x26
@@ -42,12 +44,19 @@ public enum PumpEventType: UInt8 {
4244
case JournalEntryExerciseMarker = 0x41
4345
case JournalEntryInsulinMarker = 0x42
4446
case JournalEntryOtherMarker = 0x43
47+
case ChangeBolusWizardSetup = 0x4f
4548
case ChangeSensorSetup2 = 0x50
49+
case RestoreMystery51 = 0x51
50+
case RestoreMystery52 = 0x52
51+
case RestoreMystery53 = 0x53
52+
case RestoreMystery54 = 0x54
53+
case RestoreMystery55 = 0x55
4654
case ChangeSensorRateOfChangeAlertSetup = 0x56
4755
case ChangeBolusScrollStepSize = 0x57
48-
case ChangeBolusWizardSetup = 0x5a
56+
case BolusWizardSetup = 0x5a
4957
case BolusWizardBolusEstimate = 0x5b
5058
case UnabsorbedInsulin = 0x5c
59+
case SaveSettings = 0x5d
5160
case ChangeVariableBolus = 0x5e
5261
case ChangeAudioBolus = 0x5f
5362
case ChangeBGReminderEnable = 0x60
@@ -59,6 +68,7 @@ public enum PumpEventType: UInt8 {
5968
case ChangeBolusReminderEnable = 0x66
6069
case ChangeBolusReminderTime = 0x67
6170
case DeleteBolusReminderTime = 0x68
71+
case RestoreMystery69 = 0x69
6272
case DeleteAlarmClockTime = 0x6a
6373
case Model522ResultTotals = 0x6d
6474
case Sara6E = 0x6e
@@ -84,6 +94,8 @@ public enum PumpEventType: UInt8 {
8494
return ChangeBasalProfilePatternPumpEvent.self
8595
case .ChangeBasalProfile:
8696
return ChangeBasalProfilePumpEvent.self
97+
case .ChangeBolusWizardSetup:
98+
return ChangeBolusWizardSetupPumpEvent.self
8799
case .CalBGForPH:
88100
return CalBGForPHPumpEvent.self
89101
case .AlarmSensor:
@@ -140,8 +152,8 @@ public enum PumpEventType: UInt8 {
140152
return ChangeSensorRateOfChangeAlertSetupPumpEvent.self
141153
case .ChangeBolusScrollStepSize:
142154
return ChangeBolusScrollStepSizePumpEvent.self
143-
case .ChangeBolusWizardSetup:
144-
return ChangeBolusWizardSetupPumpEvent.self
155+
case .BolusWizardSetup:
156+
return BolusWizardSetupPumpEvent.self
145157
case .BolusWizardBolusEstimate:
146158
return BolusWizardEstimatePumpEvent.self
147159
case .UnabsorbedInsulin:
@@ -190,6 +202,10 @@ public enum PumpEventType: UInt8 {
190202
return ChangeCaptureEventEnablePumpEvent.self
191203
case .SelectBasalProfile:
192204
return SelectBasalProfilePumpEvent.self
205+
case .RestoreMystery54:
206+
return RestoreMystery54PumpEvent.self
207+
case .RestoreMystery55:
208+
return RestoreMystery55PumpEvent.self
193209
default:
194210
return PlaceholderPumpEvent.self
195211
}

MinimedKit/PumpEvents/AlarmClockReminderPumpEvent.swift

+4
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ public struct AlarmClockReminderPumpEvent: TimestampedPumpEvent {
3030
"_type": "AlarmClockReminder",
3131
]
3232
}
33+
34+
public var description: String {
35+
return NSLocalizedString("AlarmClockReminder", comment: "The description of AlarmClockReminderPumpEvent")
36+
}
3337
}

MinimedKit/PumpEvents/AlarmSensorPumpEvent.swift

+4
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ public struct AlarmSensorPumpEvent: TimestampedPumpEvent {
3030
"_type": "AlarmSensor",
3131
]
3232
}
33+
34+
public var description: String {
35+
return NSLocalizedString("AlarmSensor", comment: "The description of AlarmSensorPumpEvent")
36+
}
3337
}

MinimedKit/PumpEvents/BasalProfileStartPumpEvent.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ public struct BasalProfileStartPumpEvent: TimestampedPumpEvent {
4444
"profileIndex": profileIndex,
4545
]
4646
}
47-
47+
48+
public var description: String {
49+
return String(format: NSLocalizedString("Basal Profile %1$@: %2$@ U/hour", comment: "The format string description of a BasalProfileStartPumpEvent. (1: The index of the profile)(2: The basal rate)"),profileIndex, rate)
50+
}
4851
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// BolusWizardSetupPumpEvent.swift
3+
// RileyLink
4+
//
5+
// Created by Pete Schwamb on 3/8/16.
6+
// Copyright © 2016 Pete Schwamb. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct BolusWizardSetupPumpEvent: TimestampedPumpEvent {
12+
public let length: Int
13+
public let rawData: NSData
14+
public let timestamp: NSDateComponents
15+
16+
public init?(availableData: NSData, pumpModel: PumpModel) {
17+
if pumpModel.larger {
18+
length = 144
19+
} else {
20+
length = 124
21+
}
22+
23+
guard length <= availableData.length else {
24+
return nil
25+
}
26+
27+
rawData = availableData[0..<length]
28+
29+
timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
30+
}
31+
32+
public var dictionaryRepresentation: [String: AnyObject] {
33+
return [
34+
"_type": "BolusWizardSetup",
35+
]
36+
}
37+
}

MinimedKit/PumpEvents/ChangeBolusWizardSetupPumpEvent.swift

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ChangeBolusWizardSetupPumpEvent.swift
33
// RileyLink
44
//
5-
// Created by Pete Schwamb on 3/8/16.
5+
// Created by Pete Schwamb on 8/29/16.
66
// Copyright © 2016 Pete Schwamb. All rights reserved.
77
//
88

@@ -14,16 +14,12 @@ public struct ChangeBolusWizardSetupPumpEvent: TimestampedPumpEvent {
1414
public let timestamp: NSDateComponents
1515

1616
public init?(availableData: NSData, pumpModel: PumpModel) {
17-
if pumpModel.larger {
18-
length = 144
19-
} else {
20-
length = 124
21-
}
17+
length = 39
2218

2319
guard length <= availableData.length else {
2420
return nil
2521
}
26-
22+
2723
rawData = availableData[0..<length]
2824

2925
timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)

MinimedKit/PumpEvents/PumpAlarmPumpEvent.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import Foundation
1111
public enum PumpAlarmType {
1212
case BatteryOutLimitExceeded
1313
case NoDelivery
14-
case BatteryDepleted
14+
case BatteryDepleted
15+
case AutoOff
1516
case DeviceReset
1617
case ReprogramError
1718
case EmptyReservoir
@@ -25,6 +26,8 @@ public enum PumpAlarmType {
2526
self = .NoDelivery
2627
case 5:
2728
self = .BatteryDepleted
29+
case 6:
30+
self = .AutoOff
2831
case 16:
2932
self = .DeviceReset
3033
case 61:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// RestoreMystery54PumpEvent.swift
3+
// RileyLink
4+
//
5+
// Created by Pete Schwamb on 8/29/16.
6+
// Copyright © 2016 Pete Schwamb. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct RestoreMystery54PumpEvent: TimestampedPumpEvent {
12+
public let length: Int
13+
public let rawData: NSData
14+
public let timestamp: NSDateComponents
15+
16+
public init?(availableData: NSData, pumpModel: PumpModel) {
17+
length = 64
18+
19+
guard length <= availableData.length else {
20+
return nil
21+
}
22+
23+
rawData = availableData[0..<length]
24+
25+
timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
26+
}
27+
28+
public var dictionaryRepresentation: [String: AnyObject] {
29+
return [
30+
"_type": "RestoreMystery54",
31+
]
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// RestoreMystery55PumpEvent.swift
3+
// RileyLink
4+
//
5+
// Created by Pete Schwamb on 8/29/16.
6+
// Copyright © 2016 Pete Schwamb. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public struct RestoreMystery55PumpEvent: TimestampedPumpEvent {
12+
public let length: Int
13+
public let rawData: NSData
14+
public let timestamp: NSDateComponents
15+
16+
public init?(availableData: NSData, pumpModel: PumpModel) {
17+
length = 55
18+
19+
guard length <= availableData.length else {
20+
return nil
21+
}
22+
23+
rawData = availableData[0..<length]
24+
25+
timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
26+
}
27+
28+
public var dictionaryRepresentation: [String: AnyObject] {
29+
return [
30+
"_type": "RestoreMystery55",
31+
]
32+
}
33+
}

MinimedKit/PumpEvents/SelectBasalProfilePumpEvent.swift

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import Foundation
1010

11-
1211
public struct SelectBasalProfilePumpEvent: TimestampedPumpEvent {
1312
public let length: Int
1413
public let rawData: NSData

MinimedKit/PumpEvents/TempBasalDurationPumpEvent.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ public struct TempBasalDurationPumpEvent: TimestampedPumpEvent {
3333

3434
public var dictionaryRepresentation: [String: AnyObject] {
3535
return [
36-
"_type": "TempBasal",
36+
"_type": "TempBasalDuration",
3737
"duration": duration,
3838
]
3939
}
40+
41+
public var description: String {
42+
return String(format: NSLocalizedString("Temporary Basal: %1$d min", comment: "The format string description of a TempBasalDurationPumpEvent. (1: The duration of the temp basal in minutes)"), duration)
43+
}
4044
}

MinimedKit/PumpEvents/TempBasalPumpEvent.swift

+9
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,14 @@ public struct TempBasalPumpEvent: TimestampedPumpEvent {
5252
"temp": rateType.rawValue,
5353
]
5454
}
55+
56+
public var description: String {
57+
switch rateType {
58+
case .Absolute:
59+
return String(format: NSLocalizedString("Temporary Basal: %1$.3f U/hour", comment: "The format string description of a TempBasalPumpEvent. (1: The rate of the temp basal in minutes)"), rate)
60+
case .Percent:
61+
return String(format: NSLocalizedString("Temporary Basal: %1$d%%", comment: "The format string description of a TempBasalPumpEvent. (1: The rate of the temp basal in percent)"), Int(rate))
62+
}
63+
}
5564
}
5665

MinimedKit/PumpMessage.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Foundation
1010

11-
public struct PumpMessage {
11+
public struct PumpMessage : CustomStringConvertible {
1212
public let packetType: PacketType
1313
public let address: NSData
1414
public let messageType: MessageType
@@ -49,5 +49,10 @@ public struct PumpMessage {
4949

5050
return NSData(data: data)
5151
}
52+
53+
public var description: String {
54+
return String(format: NSLocalizedString("PumpMessage(%1$@, %2$@, %3$@, %4$@)", comment: "The format string describing a pump message. (1: The packet type)(2: The message type)(3: The message address)(4: The message data"), String(self.packetType), String(self.messageType), self.address.hexadecimalString, self.messageBody.txData.hexadecimalString)
55+
}
56+
5257
}
5358

MinimedKit/PumpModel.swift

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public enum PumpModel: String {
4141
return generation >= 23
4242
}
4343

44+
// On newer pumps, square wave boluses are added to history on start of delivery, and updated in place
45+
// when delivery is finished
46+
public var appendsSquareWaveToHistoryOnStartOfDelivery: Bool {
47+
return generation >= 23
48+
}
49+
50+
public var hasMySentry: Bool {
51+
return generation >= 23
52+
}
53+
4454
var hasLowSuspend: Bool {
4555
return generation >= 51
4656
}

MinimedKitTests/HistoryPageTests.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class HistoryPageTests: XCTestCase {
201201

202202
let events = page.events
203203

204-
let bwsettings = events[0] as! ChangeBolusWizardSetupPumpEvent
204+
let bwsettings = events[0] as! BolusWizardSetupPumpEvent
205205
var timestamp = NSDateComponents(gregorianYear: 2016, month: 5, day: 29, hour: 20, minute: 16, second: 48)
206206
XCTAssertEqual(bwsettings.timestamp, timestamp)
207207

@@ -333,4 +333,18 @@ class HistoryPageTests: XCTestCase {
333333
XCTAssertEqual(NSDateComponents(gregorianYear: 2007, month: 1, day: 1, hour: 0, minute: 0, second: 0), batteryDepletedAlarm.timestamp)
334334

335335
}
336+
337+
func testSaveSettings() throws {
338+
let pumpModel = PumpModel.Model723
339+
340+
let page = try HistoryPage(pageData: NSData(hexadecimalString: "7b01a91a061510042a0033adb62e065510001601b62e0655103360b633065510001601b6330655103300a838065510001600a8380655107b01a838061510042a00335fa80b085510001601a80b0855103300a422085510001600a4220855107b02a422081510113000336eab33085510001601ab330855103383a838085510001601a838085510337baa38085510001601aa38085510337aa801095510001601a801095510337ca806095510001601a8060955103382a80b095510001601a80b095510337ca810095510001601a810095510337caa10095510001601aa100955103378a815095510001601a8150955103380a81a095510001601a81a095510336caa24095510001601aa240955103300ac29095510001600ac290955107b02ac290915101130003366a833095510001601a8330955103300a938095510001600a9380955107b02a93809151011300033679f2e0a55100016019f2e0a55103373aa330a5510001601aa330a5510338bab380a5510001601ab380a55103383a40b0b5510001601a40b0b55103300a3100b5510001600a3100b55107b02a3100b15101130000100f000f0000000b0214b55103377ab290b5510001601ab290b551033b8a12e0b5510001601a12e0b551033baac330b5510001601ac330b55103376a8380b5510001601a8380b55103300a6010c5510001600a6010c55107b02a6010c1510113000010056005600df00ba094c5510339ba10b0c5510001601a10b0c55103300ae100c5510001600ae100c55107b02ae100c15101130003300ab2e0c5510001601ab2e0c55103300ab060d5510001600ab060d55107b02ab060d15101130002601a62f0d151027000000000000280000000000002601ae2f0d15102701b207000000280000000000005d009f300d1510140084312d15107b0084312d1510003200140197310d15107b0297310d1510113000338caa060e5510001601aa060e5510338da5180e5510001601a5180e55103384b82e0e5510001601b82e0e55103384ba2e0e5510001601ba2e0e551001003c003c003400942f4e55103300ab340e5510001600ab340e55107b03ab340e15101d3400337cab1f0f5510001601ab1f0f5510339aac240f5510001601ac240f551033b1ab290f5510001601ab290f551033b7ac2e0f5510001601ac2e0f551033bbab330f5510001601ab330f55103394ae380f5510001601ae380f5510337bac01105510001601ac011055103300ac0b105510001600ac0b1055107b03ac0b1015101d34003300ad1f105510001601ad1f1055103300ad24105510001600ad241055107b03ad241015101d34000100e600e6001b00a82e5055103379ad33105510001601ad331055103392ad38105510001601ad3810551033a5aa01115510001601aa01115510000004dd")!, pumpModel: pumpModel)
341+
let events = page.events
342+
343+
XCTAssertEqual(125, events.count)
344+
345+
let saveSettings = events[79] as! PlaceholderPumpEvent
346+
let json = saveSettings.dictionaryRepresentation
347+
let displayedType = json["_type"] as! String
348+
XCTAssertEqual("SaveSettings", displayedType)
349+
}
336350
}

MinimedKitTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.10.0</string>
18+
<string>0.11.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

NightscoutUploadKit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.10.0</string>
18+
<string>0.11.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

NightscoutUploadKitTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.10.0</string>
18+
<string>0.11.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)