但是我的代码没有调用dIDConect函数
这是我的代码:
func centralManager(_ central: CBCentralManager,dIDdiscover peripheral: CBPeripheral,advertisementData: [String : Any],RSSi RSSI: NSNumber) { let device = (advertisementData as NSDictionary) .object(forKey: CBAdvertisementDataLocalnameKey) as? Nsstring if device?.contains(BEAN_name) == true { print("DID discover peripheral",peripheral) self.bluetoothManager.stopScan() self._peripheral = peripheral self._peripheral.delegate = self central.connect(peripheral,options: nil) }}func centralManager( central: CBCentralManager,dIDConnect peripheral: CBPeripheral) { //cant call this print("connected to \(BEAN_name)") peripheral.discoverServices(nil) }
日志:
BLE service is powered onDID discover peripheral <CBPeripheral: 0x1740eef00,IDentifIEr = 4872623B-F872-443A-8A96-F4E1F84D6841,name = Godoor in :),state = disconnected>解决方法 我创建了一个演示项目,它扫描蓝牙LE设备并将其显示在列表中:
在github上查看:quickies/BluetoothScanner.ios
截图
总结以上是内存溢出为你收集整理的如何在ios swift中连接蓝牙低能耗?全部内容,希望文章能够帮你解决如何在ios swift中连接蓝牙低能耗?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)