Skip to content

Commit

Permalink
Adding the read clock command
Browse files Browse the repository at this point in the history
  • Loading branch information
loudnate committed Jun 28, 2016
1 parent 19de840 commit 8066268
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
8 changes: 4 additions & 4 deletions RileyLink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1067,13 +1067,13 @@
C1B4A9511D1E610F003B8985 /* UI */ = {
isa = PBXGroup;
children = (
C1B4A9521D1E613A003B8985 /* TextFieldTableViewCell.swift */,
C1B4A9531D1E613A003B8985 /* TextFieldTableViewCell.xib */,
C1B4A9541D1E613A003B8985 /* TextFieldTableViewController.swift */,
C170C9961CECD80000F3D8E5 /* CommandResponseViewController.swift */,
439731261CF21C3C00F474E5 /* RileyLinkDeviceTableViewCell.swift */,
431185A91CF257D10059ED98 /* RileyLinkDeviceTableViewCell.xib */,
C170C9961CECD80000F3D8E5 /* CommandResponseViewController.swift */,
C170C9981CECD80000F3D8E5 /* RileyLinkDeviceTableViewController.swift */,
C1B4A9521D1E613A003B8985 /* TextFieldTableViewCell.swift */,
C1B4A9531D1E613A003B8985 /* TextFieldTableViewCell.xib */,
C1B4A9541D1E613A003B8985 /* TextFieldTableViewController.swift */,
);
path = UI;
sourceTree = "<group>";
Expand Down
27 changes: 25 additions & 2 deletions RileyLinkKit/PumpOps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class PumpOps {
- parameter completion: A closure called after the command is complete. This closure takes a single Result argument:
- Success(units): The reservoir volume, in units of insulin
- Failure(error): An error describing why the command failed.
- Failure(error): An error describing why the command failed
*/
public func readRemainingInsulin(completion: (Either<Double, ErrorType>) -> Void) {
device.runSession { (session) in
Expand Down Expand Up @@ -112,7 +112,30 @@ public class PumpOps {
}
}
}


/**
Reads the pump's clock
This operation is performed asynchronously and the completion will be executed on an arbitrary background queue.
- parameter completion: A closure called after the command is complete. This closure takes a single Result argument:
- Success(clock): The pump's clock
- Failure(error): An error describing why the command failed
*/
public func readTime(completion: (Either<NSDateComponents, ErrorType>) -> Void) {
device.runSession { (session) in
let ops = PumpOpsSynchronous(pumpState: self.pumpState, session: session)

do {
let response: ReadTimeCarelinkMessageBody = try ops.getMessageBodyWithType(.ReadTime)

completion(.Success(response.dateComponents))
} catch let error {
completion(.Failure(error))
}
}
}

/**
Sets a bolus
Expand Down

0 comments on commit 8066268

Please sign in to comment.