Skip to content

Commit c518052

Browse files
authored
Merge pull request #197 from ps2/dev
v0.9.0
2 parents 4c13ed4 + a675d03 commit c518052

27 files changed

+182
-858
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.8.0</string>
18+
<string>0.9.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

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.8.0</string>
18+
<string>0.9.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

MinimedKitTests/Messages/GetBatteryCarelinkMessageBodyTests.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ class GetBatteryCarelinkMessageBodyTests: XCTestCase {
2828
XCTAssertTrue(message.messageBody is GetBatteryCarelinkMessageBody)
2929
let body = message.messageBody as! GetBatteryCarelinkMessageBody
3030
XCTAssertEqual(body.volts, 1.4)
31-
XCTAssertEqual(body.status, "Normal")
31+
32+
if case .Normal = body.status {
33+
// OK
34+
} else {
35+
XCTFail()
36+
}
3237
} else {
3338
XCTFail("\(message) is nil")
3439
}

NightscoutUploadKit/DeviceStatus/LoopEnacted.swift

+15-7
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,28 @@ public struct LoopEnacted {
1313
let duration: NSTimeInterval
1414
let timestamp: NSDate
1515
let received: Bool
16+
let predBGs: PredictedBG?
1617

17-
public init(rate: Double, duration: NSTimeInterval, timestamp: NSDate, received: Bool) {
18+
public init(rate: Double, duration: NSTimeInterval, timestamp: NSDate, received: Bool, predBGs: PredictedBG? = nil) {
1819
self.rate = rate
1920
self.duration = duration
2021
self.timestamp = timestamp
2122
self.received = received
23+
self.predBGs = predBGs
2224
}
2325

2426
public var dictionaryRepresentation: [String: AnyObject] {
25-
return [
26-
"rate": rate,
27-
"duration": duration / 60.0,
28-
"timestamp": TimeFormat.timestampStrFromDate(timestamp),
29-
"recieved": received // [sic]
30-
]
27+
28+
var rval = [String: AnyObject]()
29+
30+
rval["rate"] = rate
31+
rval["duration"] = duration / 60.0
32+
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)
33+
rval["recieved"] = received // [sic]
34+
35+
if let predBGs = predBGs {
36+
rval["predBGs"] = predBGs.dictionaryRepresentation
37+
}
38+
return rval
3139
}
3240
}

NightscoutUploadKit/DeviceStatus/LoopStatus.swift

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ import Foundation
1010

1111
public struct LoopStatus {
1212
let name: String
13+
let version: String
1314
let timestamp: NSDate
14-
15+
1516
let iob: IOBStatus?
1617
let cob: COBStatus?
1718
let suggested: LoopSuggested?
1819
let enacted: LoopEnacted?
1920

20-
let failureReason: String?
21+
let failureReason: ErrorType?
2122

22-
public init(name: String, timestamp: NSDate, glucose: Int? = nil, iob: IOBStatus? = nil, cob: COBStatus? = nil, suggested: LoopSuggested? = nil, enacted: LoopEnacted?, failureReason: String? = nil) {
23+
public init(name: String, version: String, timestamp: NSDate, glucose: Int? = nil, iob: IOBStatus? = nil, cob: COBStatus? = nil, suggested: LoopSuggested? = nil, enacted: LoopEnacted?, failureReason: ErrorType? = nil) {
2324
self.name = name
25+
self.version = version
2426
self.timestamp = timestamp
2527
self.suggested = suggested
2628
self.enacted = enacted
@@ -33,6 +35,7 @@ public struct LoopStatus {
3335
var rval = [String: AnyObject]()
3436

3537
rval["name"] = name
38+
rval["version"] = version
3639
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)
3740

3841
if let suggested = suggested {
@@ -51,6 +54,10 @@ public struct LoopStatus {
5154
rval["cob"] = cob.dictionaryRepresentation
5255
}
5356

57+
if let failureReason = failureReason {
58+
rval["failureReason"] = String(failureReason)
59+
}
60+
5461
return rval
5562
}
5663
}

NightscoutUploadKit/DeviceStatus/LoopSuggested.swift

+14-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import HealthKit
1011

1112
public struct LoopSuggested {
1213
let timestamp: NSDate
@@ -17,18 +18,24 @@ public struct LoopSuggested {
1718
let reason: String?
1819
let tick: Int?
1920
let correction: Double?
21+
let predBGs: PredictedBG?
22+
23+
public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: HKQuantity, bg: HKQuantity, reason: String? = nil, tick: Int? = nil, correction: Double? = nil, predBGs: PredictedBG? = nil) {
24+
25+
// BG values in nightscout are in mg/dL.
26+
let unit = HKUnit.milligramsPerDeciliterUnit()
2027

21-
public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: Int, bg: Int, reason: String? = nil, tick: Int? = nil, correction: Double? = nil) {
2228
self.timestamp = timestamp
2329
self.rate = rate
2430
self.duration = duration
25-
self.eventualBG = eventualBG
26-
self.bg = bg
31+
self.eventualBG = Int(eventualBG.doubleValueForUnit(unit))
32+
self.bg = Int(bg.doubleValueForUnit(unit))
2733
self.reason = reason
2834
self.tick = tick
2935
self.correction = correction
36+
self.predBGs = predBGs
3037
}
31-
38+
3239
public var dictionaryRepresentation: [String: AnyObject] {
3340

3441
var rval = [String: AnyObject]()
@@ -60,6 +67,9 @@ public struct LoopSuggested {
6067
rval["correction"] = correction
6168
}
6269

70+
if let predBGs = predBGs {
71+
rval["predBGs"] = predBGs.dictionaryRepresentation
72+
}
6373

6474
return rval
6575
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// PredictedBG.swift
3+
// RileyLink
4+
//
5+
// Created by Pete Schwamb on 8/8/16.
6+
// Copyright © 2016 Pete Schwamb. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import HealthKit
11+
12+
public struct PredictedBG {
13+
let values: [Int]
14+
let cob: [Int]?
15+
let iob: [Int]?
16+
17+
public init(values: [HKQuantity], cob: [HKQuantity]? = nil, iob: [HKQuantity]? = nil) {
18+
// BG values in nightscout are in mg/dL.
19+
let unit = HKUnit.milligramsPerDeciliterUnit()
20+
self.values = values.map { Int(round($0.doubleValueForUnit(unit))) }
21+
self.cob = cob?.map { Int(round($0.doubleValueForUnit(unit))) }
22+
self.iob = iob?.map { Int(round($0.doubleValueForUnit(unit))) }
23+
}
24+
25+
public var dictionaryRepresentation: [String: AnyObject] {
26+
27+
var rval = [String: AnyObject]()
28+
29+
rval["values"] = values
30+
31+
if let cob = cob {
32+
rval["COB"] = cob
33+
}
34+
35+
if let iob = iob {
36+
rval["IOB"] = iob
37+
}
38+
39+
return rval
40+
}
41+
}

NightscoutUploadKit/DeviceStatus/UploaderStatus.swift

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ public struct UploaderStatus {
1313
public let battery: Int?
1414
public let name: String
1515
public let timestamp: NSDate
16-
16+
17+
public init(name: String, timestamp: NSDate, battery: Float? = nil) {
18+
let intBattery: Int?
19+
if let battery = battery where battery >= 0 {
20+
intBattery = Int(battery * 100)
21+
} else {
22+
intBattery = nil
23+
}
24+
25+
self.init(name: name, timestamp: timestamp, battery: intBattery)
26+
}
27+
1728
public init(name: String, timestamp: NSDate, battery: Int? = nil) {
1829
self.name = name
1930
self.timestamp = timestamp

NightscoutUploadKit/HKUnit.swift

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// HKUnit.swift
3+
// RileyLink
4+
//
5+
// Created by Nate Racklyeft on 8/8/16.
6+
// Copyright © 2016 Pete Schwamb. All rights reserved.
7+
//
8+
9+
import HealthKit
10+
11+
12+
extension HKUnit {
13+
static func milligramsPerDeciliterUnit() -> HKUnit {
14+
return HKUnit.gramUnitWithMetricPrefix(.Milli).unitDividedByUnit(HKUnit.literUnitWithMetricPrefix(.Deci))
15+
}
16+
}

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.8.0</string>
18+
<string>0.9.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.8.0</string>
18+
<string>0.9.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
[![Join the chat at https://gitter.im/ps2/rileylink](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ps2/rileylink?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/ps2/rileylink_ios.svg?branch=master)](https://travis-ci.org/ps2/rileylink_ios)
44

5-
The RileyLink iOS app connects to a RileyLink device via Bluetooth Low Energy (BLE, or Bluetooth Smart) and uploads CGM and pump data to a Nightscout instance via the REST API. The Nightscout web page is also displayed in the App.
5+
The RileyLink iOS app connects to a [RileyLink](https://github.com/ps2/rileylink) via Bluetooth Low Energy (BLE, or Bluetooth Smart) and uploads CGM and pump data to a Nightscout instance via the REST API. The Nightscout web page is also displayed in the App.
6+
7+
### Getting Started
8+
9+
You'll need Xcode, which is available for free, but will only build apps that last a week. To make your apps run longer, you'll have to sign up for a developer account. Or send a message to @ps2 on gitter with your email address, and I'll add you to the distribution list and you can receive builds via testflight.
10+
11+
You'll also need to install [Carthage](https://github.com/Carthage/Carthage) and run `carthage bootstrap` in the checked out directory.
12+
13+
You should not need to change bundle id, or sign the app. Just clicking on the build and run button in Xcode should build and install the app to your connected phone.
614

715
### Configuration
816

0 commit comments

Comments
 (0)