Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
poszposz committed Mar 5, 2019
2 parents 013bbfd + 33c1a13 commit b390816
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ public extension Peripheral where Type == Connectable {
/// - command: a command to write to the device.
/// - characteristic: a characteristic the command should be directed to.
/// - handler: a completion handler indicating if reuqest was successfull.
/// - type: type of write request
/// - SeeAlso: `Command`
/// - SeeAlso: `Characteristic`
/// - SeeAlso: `CBCharacteristicWriteType`
/// - SeeAlso: `Peripheral.TransmissionError`
public func write(command: Command, characteristic: Characteristic, handler: ((TransmissionError?) -> ())?) {
public func write(command: Command, characteristic: Characteristic, type: CBCharacteristicWriteType = .withResponse, handler: ((TransmissionError?) -> ())?) {
do {
let unwrapped = try validateForTransmission(characteristic, action: .write)
writeHandler = handler
try peripheral?.writeValue(command.convertedData(), for: unwrapped, type: .withResponse)
try peripheral?.writeValue(command.convertedData(), for: unwrapped, type: type)
} catch let error {
guard let conversionError = error as? Command.ConversionError else {
handler?(error as? TransmissionError)
Expand Down

0 comments on commit b390816

Please sign in to comment.