Skip to content

Commit

Permalink
Merge pull request #491 from ps2/dev
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
ps2 authored Jan 26, 2019
2 parents 483b228 + fe95f89 commit fcbf6b9
Show file tree
Hide file tree
Showing 170 changed files with 7,933 additions and 426 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode9.4
osx_image: xcode10
xcode_project: RileyLink.xcodeproj
xcode_scheme: RileyLink
script:
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "LoopKit/LoopKit" == 2.1.5
github "LoopKit/LoopKit" ~> 2.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "LoopKit/LoopKit" "v2.1.5"
github "LoopKit/LoopKit" "v2.2.1"
5 changes: 5 additions & 0 deletions Common/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ extension Data {
var value = value.littleEndian
self.init(buffer: UnsafeBufferPointer(start: &value, count: 1))
}

init<T: FixedWidthInteger>(bigEndian value: T) {
var value = value.bigEndian
self.init(buffer: UnsafeBufferPointer(start: &value, count: 1))
}
}

// String conversion methods, adapted from https://stackoverflow.com/questions/40276322/hex-binary-string-conversion-in-swift/40278391#40278391
Expand Down
4 changes: 4 additions & 0 deletions Common/NumberFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ extension NumberFormatter {
return nil
}
}

func string(from number: Double) -> String? {
return string(from: NSNumber(value: number))
}
}
8 changes: 8 additions & 0 deletions Common/TimeInterval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ extension TimeInterval {
var milliseconds: Double {
return self * 1000
}

init(hundredthsOfMilliseconds: Double) {
self.init(hundredthsOfMilliseconds / 100000)
}

var hundredthsOfMilliseconds: Double {
return self * 100000
}

var minutes: Double {
return self / 60.0
Expand Down
11 changes: 11 additions & 0 deletions Common/TimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ extension TimeZone {
var fixed: TimeZone {
return TimeZone(secondsFromGMT: secondsFromGMT())!
}

/// This only works for fixed utc offset timezones
func scheduleOffset(forDate date: Date) -> TimeInterval {
var calendar = Calendar.current
calendar.timeZone = self
let components = calendar.dateComponents([.day , .month, .year], from: date)
guard let startOfSchedule = calendar.date(from: components) else {
fatalError("invalid date")
}
return date.timeIntervalSince(startOfSchedule)
}
}
2 changes: 1 addition & 1 deletion Crypto/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>2.0.7</string>
<string>2.1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Binary file added Images/errors_when_building.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/rileylink_ios_omnipod_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/rileylink_ios_paired_omnipod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/rileylink_ios_setup.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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>2.0.7</string>
<string>2.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 1 addition & 0 deletions MinimedKit/Models/PumpColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public enum PumpColor: String {
case clear = "L"
case purple = "P"
case smoke = "S"
case pink = "H"
}
6 changes: 4 additions & 2 deletions MinimedKit/PumpManager/MinimedPumpManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public class MinimedPumpManager: RileyLinkPumpManager, PumpManager {
pumpOps.runSession(withName: "Tune pump", using: device) { (session) in
do {
let scanResult = try session.tuneRadio()
self.log.error("Device %{public}@ auto-tuned to %{public}@ MHz", device.name ?? "", String(describing: scanResult.bestFrequency))
self.log.default("Device %{public}@ auto-tuned to %{public}@ MHz", device.name ?? "", String(describing: scanResult.bestFrequency))
} catch let error {
self.log.error("Device %{public}@ auto-tune failed with error: %{public}@", device.name ?? "", String(describing: error))
self.rileyLinkDeviceProvider.deprioritize(device, completion: nil)
Expand All @@ -230,6 +230,8 @@ public class MinimedPumpManager: RileyLinkPumpManager, PumpManager {
private func updatePumpStatus(_ status: MySentryPumpStatusMessageBody, from device: RileyLinkDevice) {
dispatchPrecondition(condition: .onQueue(queue))

log.default("MySentry message received")

var pumpDateComponents = status.pumpDateComponents
var glucoseDateComponents = status.glucoseDateComponents

Expand Down Expand Up @@ -407,7 +409,7 @@ public class MinimedPumpManager: RileyLinkPumpManager, PumpManager {
return
}

self.log.debug("Pump data is stale, fetching.")
self.log.default("Pump data is stale, fetching.")

rileyLinkDeviceProvider.getDevices { (devices) in
guard let device = devices.firstConnected else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/PumpManager/PumpMessageSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protocol PumpMessageSender {
/// - retryCount: The number of times to repeat the send & listen sequence
/// - Returns: The packet reply
/// - Throws: LocalizedError
func sendAndListen(_ data: Data, repeatCount: Int, timeout: TimeInterval, retryCount: Int) throws -> RFPacket?
func sendAndListen(_ data: Data, repeatCount: Int, timeout: TimeInterval, retryCount: Int) throws -> RFPacket

/// - Throws: LocalizedError
func listen(onChannel channel: Int, timeout: TimeInterval) throws -> RFPacket?
Expand Down
23 changes: 18 additions & 5 deletions MinimedKit/PumpManager/PumpOps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import RileyLinkKit
import RileyLinkBLEKit
import os.log


public protocol PumpOpsDelegate: class {
Expand All @@ -18,6 +19,8 @@ public protocol PumpOpsDelegate: class {

public class PumpOps {

private let log = OSLog(category: "PumpOps")

public let pumpSettings: PumpSettings

private var pumpState: PumpState {
Expand Down Expand Up @@ -69,10 +72,15 @@ public class PumpOps {
sessionQueue.async {
let semaphore = DispatchSemaphore(value: 0)

device.runSession(withName: name) { (session) in
let session = PumpOpsSession(settings: self.pumpSettings, pumpState: self.pumpState, session: session, delegate: self)
device.runSession(withName: name) { (commandSession) in
let session = PumpOpsSession(settings: self.pumpSettings, pumpState: self.pumpState, session: commandSession, delegate: self)
self.sessionDevice = device
self.configureDevice(device, with: session)
if !commandSession.firmwareVersion.isUnknown {
self.configureDevice(device, with: session)
} else {
self.log.error("Skipping device configuration due to unknown firmware version")
}

block(session)
self.sessionDevice = nil
semaphore.signal()
Expand All @@ -88,10 +96,13 @@ public class PumpOps {
return
}

log.default("Configuring RileyLinkDevice: %{public}@", String(describing: device.deviceURI))

do {
_ = try session.configureRadio(for: pumpSettings.pumpRegion, frequency: pumpState.lastValidFrequency)
} catch {
} catch let error {
// Ignore the error and let the block run anyway
log.error("Error configuring device: %{public}@", String(describing: error))
return
}

Expand All @@ -108,7 +119,9 @@ public class PumpOps {

NotificationCenter.default.removeObserver(self, name: .DeviceRadioConfigDidChange, object: device)
NotificationCenter.default.removeObserver(self, name: .DeviceConnectionStateDidChange, object: device)
configuredDevices.remove(device)

// TODO: Unsafe access
self.configuredDevices.remove(device)
}

public func getPumpState(_ completion: @escaping (_ state: PumpState) -> Void) {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKitTests/HistoryPageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class HistoryPageTests: XCTestCase {
XCTAssertEqual(126, events.count)

let alarm = events[9] as! PumpAlarmPumpEvent
XCTAssertEqual("unknownType(21)", "\(alarm.alarmType)")
XCTAssertEqual("unknownType(rawType: 21)", "\(alarm.alarmType)")
XCTAssertEqual(DateComponents(gregorianYear: 2007, month: 1, day: 1, hour: 0, minute: 0, second: 0), alarm.timestamp)

let batteryDepletedAlarm = events[13] as! PumpAlarmPumpEvent
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>2.0.7</string>
<string>2.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
9 changes: 7 additions & 2 deletions MinimedKitTests/PumpOpsSynchronousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class PumpMessageSenderStub: PumpMessageSender {
throw PumpOpsError.noResponse(during: "Tests")
}

func sendAndListen(_ data: Data, repeatCount: Int, timeout: TimeInterval, retryCount: Int) throws -> RFPacket? {
func sendAndListen(_ data: Data, repeatCount: Int, timeout: TimeInterval, retryCount: Int) throws -> RFPacket {
guard let decoded = MinimedPacket(encodedData: data),
let messageType = MessageType(rawValue: decoded.data[4])
else {
Expand Down Expand Up @@ -356,7 +356,12 @@ class PumpMessageSenderStub: PumpMessageSender {

var encoded = MinimedPacket(outgoingData: response.txData).encodedData()
encoded.insert(contentsOf: [0, 0], at: 0)
return RFPacket(rfspyResponse: encoded)

guard let rfPacket = RFPacket(rfspyResponse: encoded) else {
throw PumpOpsError.noResponse(during: data)
}

return rfPacket
}

func listen(onChannel channel: Int, timeout: TimeInterval) throws -> RFPacket? {
Expand Down
1 change: 1 addition & 0 deletions MinimedKitUI/CommandResponseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ extension CommandResponseViewController {
str += String(format: LocalizedString("Battery: %1$@ volts\n", comment: "The format string describing pump battery voltage: (1: battery voltage)"), measurementFormatter.string(from: status.batteryVolts))
str += String(format: LocalizedString("Suspended: %1$@\n", comment: "The format string describing pump suspended state: (1: suspended)"), String(describing: status.suspended))
str += String(format: LocalizedString("Bolusing: %1$@\n", comment: "The format string describing pump bolusing state: (1: bolusing)"), String(describing: status.bolusing))

response = str
} catch let error {
response = String(describing: error)
Expand Down
2 changes: 1 addition & 1 deletion MinimedKitUI/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>2.0.7</string>
<string>2.1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions MinimedKitUI/MinimedKitUI.xcassets/5xx Pink.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "5xx Pink.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "5xx Small Pink.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
12 changes: 12 additions & 0 deletions MinimedKitUI/MinimedKitUI.xcassets/7xx Pink.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "7xx Pink.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "7xx Small Pink.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
4 changes: 2 additions & 2 deletions MinimedKitUI/MinimedPumpSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class MinimedPumpSettingsViewController: RileyLinkSettingsViewController {

title = LocalizedString("Pump Settings", comment: "Title of the pump settings view controller")

tableView.rowHeight = UITableViewAutomaticDimension
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 44

tableView.sectionHeaderHeight = UITableViewAutomaticDimension
tableView.sectionHeaderHeight = UITableView.automaticDimension
tableView.estimatedSectionHeaderHeight = 55

tableView.register(SettingsTableViewCell.self, forCellReuseIdentifier: SettingsTableViewCell.className)
Expand Down
2 changes: 2 additions & 0 deletions MinimedKitUI/PumpModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extension UIImage {
return "Purple"
case .smoke?:
return "Smoke"
case .pink?:
return "Pink"
case .none:
return "Outline"
}
Expand Down
4 changes: 2 additions & 2 deletions MinimedKitUI/Setup/MinimedPumpIDSetupViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class MinimedPumpIDSetupViewController: SetupTableViewController {

continueState = .inputSettings

NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidHide), name: .UIKeyboardDidHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidHide), name: UIResponder.keyboardDidHideNotification, object: nil)
}

override func setEditing(_ editing: Bool, animated: Bool) {
Expand Down Expand Up @@ -332,7 +332,7 @@ class MinimedPumpIDSetupViewController: SetupTableViewController {
extension MinimedPumpIDSetupViewController: UIPickerViewDelegate, UIPickerViewDataSource {
private static let regionRows: [RegionCode] = [.northAmerica, .canada, .worldWide]

private static let colorRows: [PumpColor] = [.blue, .clear, .purple, .smoke]
private static let colorRows: [PumpColor] = [.blue, .clear, .purple, .smoke, .pink]

private enum PickerViewComponent: Int {
case region
Expand Down
2 changes: 1 addition & 1 deletion MinimedKitUI/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"No response" = "Brak odpowiedzi";

/* The title of the cell showing the last idle */
"On Idle" = "Wsrzymany";
"On Idle" = "Wstrzymany";

/* The title text for the preferred insulin data source config */
"Preferred Data Source" = "Preferowane źródło danych";
Expand Down
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>2.0.7</string>
<string>2.1.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>2.0.7</string>
<string>2.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit fcbf6b9

Please sign in to comment.