Skip to content

Instantly share code, notes, and snippets.

@AminPlusPlus
Created July 9, 2020 02:20
Show Gist options
  • Save AminPlusPlus/9a65910f869f6e74a3e7ebe06ae443f6 to your computer and use it in GitHub Desktop.
Save AminPlusPlus/9a65910f869f6e74a3e7ebe06ae443f6 to your computer and use it in GitHub Desktop.
Connect Peripheral
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
guard peripheral.name != nil else {return}
if peripheral.name! == "Thunder Sense #33549" {
print("Sensor Found!")
//stopScan
cbCentralManager.stopScan()
//connect
cbCentralManager.connect(peripheral, options: nil)
self.peripheral = peripheral
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment