Instantly share code, notes, and snippets.

Embed
What would you like to do?
func centralManager(central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber) {
guard let packet = advertisementData[CBAdvertisementDataLocalNameKey] as? String else {
return
}
let version = Int(packet[packet.startIndex..<packet.startIndex.advancedBy(2)])
let channel = Int(packet[packet.startIndex.advancedBy(2)..<packet.startIndex.advancedBy(4)])
let cardRawValue = Int(packet[packet.startIndex.advancedBy(4)..<packet.startIndex.advancedBy(6)], radix: 16)
let card = Card(rawValue: cardRawValue)
let name = packet[packet.startIndex.advancedBy(6)..<packet.endIndex]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment