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, didDiscoverServices error: NSError?){ | |
| peripheral.discoverCharacteristics(nil, forService: peripheral.services![0]) | |
| } |
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 { |
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
| import CoreBluetooth | |
| import UIKit | |
| class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate { | |
| var centralManager: CBCentralManager! | |
| var peripheral: CBPeripheral! | |
| var currentCharacteristic: CBCharacteristic! = nil | |
| var readRSSITimer: NSTimer! | |
| var RSSIholder: NSNumber = 0 |
OlderNewer