Created
July 26, 2016 14:38
-
-
Save ryanjjones10/ea1a2eaf7586922e9d081d496daf2f74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?){ | |
for characteristic in service.characteristics! { | |
let thisCharacteristic = characteristic as CBCharacteristic | |
if thisCharacteristic.UUID == txCharacteristic{ | |
self.currentCharacteristic = thisCharacteristic | |
let openValue = "1".dataUsingEncoding(NSUTF8StringEncoding)! | |
self.peripheral.writeValue(openValue, forCharacteristic: self.currentCharacteristic, type: CBCharacteristicWriteType.WithResponse) | |
} | |
} | |
if let error = error { | |
print("characteristics error", error) | |
} | |
} | |
func peripheral(peripheral: CBPeripheral, didUpdateValueForCharacteristic characteristic: CBCharacteristic, error: NSError?){ | |
if let error = error { | |
print("updated error", error) | |
} | |
} | |
func peripheral(peripheral: CBPeripheral, didWriteValueForCharacteristic characteristic: CBCharacteristic, error: NSError?){ | |
if let error = error { | |
print("Writing error", error) | |
} else { | |
print("Succeeded") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment