我刚开始使用BLE,目前正在尝试制作一个可以连接到我的自定义BLE设备的简单应用程序。我能够发现BLE设备,但由于某种原因我无法连接到它。我尝试使用“浅蓝色”对其进行检查,它显示我的设备可连接并且似乎工作正常。但是在我发现设备后,在我的应用程序中,CB管理器尝试连接到它并且似乎“卡住”了?永远不会触发函数“didConnectperipheral”,并且peripheral的状态永远是“connecting”。我如何识别问题?我可以在连接方法中包含任何选项,或者以某种方式跟踪连接过程吗?我将不胜感激任何在何处寻找问题的建议。在XCode8.2.1中工作,使用Swift3。测试手机上安装
我有一个使用BTLE连接到设备(arduino)的iOS应用程序。在我的iPadiOS7上一切正常。升级到iOS8后,CBCentralManager找不到任何外围设备。-(void)startScanningForSupportedUUIDs{[self.centralManagerscanForPeripheralsWithServices:niloptions:nil];}我不知道可能是什么问题。 最佳答案 我有解决方案,由于某些原因,在iOS8中实例化CBManager后会有一些延迟。需要在CBCentralManager开
我有一个使用BTLE连接到设备(arduino)的iOS应用程序。在我的iPadiOS7上一切正常。升级到iOS8后,CBCentralManager找不到任何外围设备。-(void)startScanningForSupportedUUIDs{[self.centralManagerscanForPeripheralsWithServices:niloptions:nil];}我不知道可能是什么问题。 最佳答案 我有解决方案,由于某些原因,在iOS8中实例化CBManager后会有一些延迟。需要在CBCentralManager开
有很多相关问题,但(显然)没有答案。所以...我的iOS应用程序在后台时确实从我的BLE设备获取更新。如果我与BLE设备失去联系,那么在centralManager:didDisconnectPeripheral:中调用-[CBCentralManagercancelPeripheralConnection:]——否则我将永远不会重新连接到丢失的外围设备。然后我调用[(re)call-[CBCentralManagerscanForPeripheralsWithServices:options:]。日志记录显示didDisconnectPeripheral调用及其包含的调用都发生在后台
有很多相关问题,但(显然)没有答案。所以...我的iOS应用程序在后台时确实从我的BLE设备获取更新。如果我与BLE设备失去联系,那么在centralManager:didDisconnectPeripheral:中调用-[CBCentralManagercancelPeripheralConnection:]——否则我将永远不会重新连接到丢失的外围设备。然后我调用[(re)call-[CBCentralManagerscanForPeripheralsWithServices:options:]。日志记录显示didDisconnectPeripheral调用及其包含的调用都发生在后台
当我在iPhone5上运行使用CoreBluetooth的应用程序时,我不断收到此错误:isnotpoweredon但是当我调用state在我程序的唯一一个CBCentralManager对象上,它返回5,即CBCentralManagerStatePoweredOn。所以它已打开,但我收到此错误。iPhone的蓝牙也已启用。一般来说,这会在什么时候发生?我什至不知道程序运行时发生了什么,因为我收到的消息看起来像是相互冲突的。 最佳答案 您必须先等到centralManager在应用程序启动时从centralManagerDidUp
当我在iPhone5上运行使用CoreBluetooth的应用程序时,我不断收到此错误:isnotpoweredon但是当我调用state在我程序的唯一一个CBCentralManager对象上,它返回5,即CBCentralManagerStatePoweredOn。所以它已打开,但我收到此错误。iPhone的蓝牙也已启用。一般来说,这会在什么时候发生?我什至不知道程序运行时发生了什么,因为我收到的消息看起来像是相互冲突的。 最佳答案 您必须先等到centralManager在应用程序启动时从centralManagerDidUp
publicclassBLE:NSObject,CBCentralManagerDelegate{varcentralManager:CBCentralManager!publicoverrideinit(){super.init()self.centralManager=CBCentralManager.init(delegate:self,queue:nil)}publicfunccentralManagerDidUpdateState(_central:CBCentralManager){switchcentral.state{case.unknown:print("unknow
publicclassBLE:NSObject,CBCentralManagerDelegate{varcentralManager:CBCentralManager!publicoverrideinit(){super.init()self.centralManager=CBCentralManager.init(delegate:self,queue:nil)}publicfunccentralManagerDidUpdateState(_central:CBCentralManager){switchcentral.state{case.unknown:print("unknow
所以我要迁移到iOS10,但我还需要我的代码才能在iOS9上运行。我正在使用CoreBluetooth和CBCentralManagerDelegate。我可以让我的代码适用于iOS10,但我需要回退才能适用于iOS9。funccentralManagerDidUpdateState(_central:CBCentralManager){if#available(iOS10.0,*){switchcentral.state{caseCBManagerState.unauthorized:print("ThisappisnotauthorisedtouseBluetoothlowener