Skip to content

Instantly share code, notes, and snippets.

@ryanjjones10
Created July 26, 2016 14:38
Show Gist options
  • Save ryanjjones10/ea1a2eaf7586922e9d081d496daf2f74 to your computer and use it in GitHub Desktop.
Save ryanjjones10/ea1a2eaf7586922e9d081d496daf2f74 to your computer and use it in GitHub Desktop.
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