Skip to content

Commit

Permalink
Merge pull request #197 from ps2/dev
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
ps2 authored Aug 11, 2016
2 parents 4c13ed4 + a675d03 commit c518052
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 858 deletions.
2 changes: 1 addition & 1 deletion MinimedKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.9.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion MinimedKitTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.9.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ class GetBatteryCarelinkMessageBodyTests: XCTestCase {
XCTAssertTrue(message.messageBody is GetBatteryCarelinkMessageBody)
let body = message.messageBody as! GetBatteryCarelinkMessageBody
XCTAssertEqual(body.volts, 1.4)
XCTAssertEqual(body.status, "Normal")

if case .Normal = body.status {
// OK
} else {
XCTFail()
}
} else {
XCTFail("\(message) is nil")
}
Expand Down
22 changes: 15 additions & 7 deletions NightscoutUploadKit/DeviceStatus/LoopEnacted.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@ public struct LoopEnacted {
let duration: NSTimeInterval
let timestamp: NSDate
let received: Bool
let predBGs: PredictedBG?

public init(rate: Double, duration: NSTimeInterval, timestamp: NSDate, received: Bool) {
public init(rate: Double, duration: NSTimeInterval, timestamp: NSDate, received: Bool, predBGs: PredictedBG? = nil) {
self.rate = rate
self.duration = duration
self.timestamp = timestamp
self.received = received
self.predBGs = predBGs
}

public var dictionaryRepresentation: [String: AnyObject] {
return [
"rate": rate,
"duration": duration / 60.0,
"timestamp": TimeFormat.timestampStrFromDate(timestamp),
"recieved": received // [sic]
]

var rval = [String: AnyObject]()

rval["rate"] = rate
rval["duration"] = duration / 60.0
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)
rval["recieved"] = received // [sic]

if let predBGs = predBGs {
rval["predBGs"] = predBGs.dictionaryRepresentation
}
return rval
}
}
13 changes: 10 additions & 3 deletions NightscoutUploadKit/DeviceStatus/LoopStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import Foundation

public struct LoopStatus {
let name: String
let version: String
let timestamp: NSDate

let iob: IOBStatus?
let cob: COBStatus?
let suggested: LoopSuggested?
let enacted: LoopEnacted?

let failureReason: String?
let failureReason: ErrorType?

public init(name: String, timestamp: NSDate, glucose: Int? = nil, iob: IOBStatus? = nil, cob: COBStatus? = nil, suggested: LoopSuggested? = nil, enacted: LoopEnacted?, failureReason: String? = nil) {
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) {
self.name = name
self.version = version
self.timestamp = timestamp
self.suggested = suggested
self.enacted = enacted
Expand All @@ -33,6 +35,7 @@ public struct LoopStatus {
var rval = [String: AnyObject]()

rval["name"] = name
rval["version"] = version
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp)

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

if let failureReason = failureReason {
rval["failureReason"] = String(failureReason)
}

return rval
}
}
Expand Down
18 changes: 14 additions & 4 deletions NightscoutUploadKit/DeviceStatus/LoopSuggested.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import HealthKit

public struct LoopSuggested {
let timestamp: NSDate
Expand All @@ -17,18 +18,24 @@ public struct LoopSuggested {
let reason: String?
let tick: Int?
let correction: Double?
let predBGs: PredictedBG?

public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: HKQuantity, bg: HKQuantity, reason: String? = nil, tick: Int? = nil, correction: Double? = nil, predBGs: PredictedBG? = nil) {

// BG values in nightscout are in mg/dL.
let unit = HKUnit.milligramsPerDeciliterUnit()

public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: Int, bg: Int, reason: String? = nil, tick: Int? = nil, correction: Double? = nil) {
self.timestamp = timestamp
self.rate = rate
self.duration = duration
self.eventualBG = eventualBG
self.bg = bg
self.eventualBG = Int(eventualBG.doubleValueForUnit(unit))
self.bg = Int(bg.doubleValueForUnit(unit))
self.reason = reason
self.tick = tick
self.correction = correction
self.predBGs = predBGs
}

public var dictionaryRepresentation: [String: AnyObject] {

var rval = [String: AnyObject]()
Expand Down Expand Up @@ -60,6 +67,9 @@ public struct LoopSuggested {
rval["correction"] = correction
}

if let predBGs = predBGs {
rval["predBGs"] = predBGs.dictionaryRepresentation
}

return rval
}
Expand Down
41 changes: 41 additions & 0 deletions NightscoutUploadKit/DeviceStatus/PredictedBG.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// PredictedBG.swift
// RileyLink
//
// Created by Pete Schwamb on 8/8/16.
// Copyright © 2016 Pete Schwamb. All rights reserved.
//

import Foundation
import HealthKit

public struct PredictedBG {
let values: [Int]
let cob: [Int]?
let iob: [Int]?

public init(values: [HKQuantity], cob: [HKQuantity]? = nil, iob: [HKQuantity]? = nil) {
// BG values in nightscout are in mg/dL.
let unit = HKUnit.milligramsPerDeciliterUnit()
self.values = values.map { Int(round($0.doubleValueForUnit(unit))) }
self.cob = cob?.map { Int(round($0.doubleValueForUnit(unit))) }
self.iob = iob?.map { Int(round($0.doubleValueForUnit(unit))) }
}

public var dictionaryRepresentation: [String: AnyObject] {

var rval = [String: AnyObject]()

rval["values"] = values

if let cob = cob {
rval["COB"] = cob
}

if let iob = iob {
rval["IOB"] = iob
}

return rval
}
}
13 changes: 12 additions & 1 deletion NightscoutUploadKit/DeviceStatus/UploaderStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ public struct UploaderStatus {
public let battery: Int?
public let name: String
public let timestamp: NSDate


public init(name: String, timestamp: NSDate, battery: Float? = nil) {
let intBattery: Int?
if let battery = battery where battery >= 0 {
intBattery = Int(battery * 100)
} else {
intBattery = nil
}

self.init(name: name, timestamp: timestamp, battery: intBattery)
}

public init(name: String, timestamp: NSDate, battery: Int? = nil) {
self.name = name
self.timestamp = timestamp
Expand Down
16 changes: 16 additions & 0 deletions NightscoutUploadKit/HKUnit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// HKUnit.swift
// RileyLink
//
// Created by Nate Racklyeft on 8/8/16.
// Copyright © 2016 Pete Schwamb. All rights reserved.
//

import HealthKit


extension HKUnit {
static func milligramsPerDeciliterUnit() -> HKUnit {
return HKUnit.gramUnitWithMetricPrefix(.Milli).unitDividedByUnit(HKUnit.literUnitWithMetricPrefix(.Deci))
}
}
2 changes: 1 addition & 1 deletion NightscoutUploadKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.9.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion NightscoutUploadKitTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.0</string>
<string>0.9.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

[![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)

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.
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.

### Getting Started

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.

You'll also need to install [Carthage](https://github.com/Carthage/Carthage) and run `carthage bootstrap` in the checked out directory.

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.

### Configuration

Expand Down
Loading

0 comments on commit c518052

Please sign in to comment.