作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我有一个使用 BTLE 连接到设备 (arduino) 的 iOS 应用程序。在我的 iPad iOS 7 上一切正常。升级到 iOS 8 后,CBCentralManager 找不到任何外围设备。
- (void)startScanningForSupportedUUIDs
{
[self.centralManager scanForPeripheralsWithServices:nil options:nil];
}
我不知道可能是什么问题。
最佳答案
我有解决方案,由于某些原因,在 iOS 8 中实例化 CBManager 后会有一些延迟。需要在CBCentralManager开启时开始扫描,在这个方法中:
-(void)centralManagerDidUpdateState:(CBCentralManager *)central{
switch (central.state) {
case CBCentralManagerStatePoweredOff:
NSLog(@"CoreBluetooth BLE hardware is powered off");
break;
case CBCentralManagerStatePoweredOn:
{
NSLog(@"CoreBluetooth BLE hardware is powered on and ready");
NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID], nil];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[centralManager scanForPeripheralsWithServices:uuidArray options:options];
}
break;
case CBCentralManagerStateResetting:
NSLog(@"CoreBluetooth BLE hardware is resetting");
break;
case CBCentralManagerStateUnauthorized:
NSLog(@"CoreBluetooth BLE state is unauthorized");
break;
case CBCentralManagerStateUnknown:
NSLog(@"CoreBluetooth BLE state is unknown");
break;
case CBCentralManagerStateUnsupported:
NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform");
break;
default:
break;
}
关于iOS8 和 BTLE | CBCentralManager 无法找到外围设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25389358/
我有一个基于 Java 的应用程序 (Android),我希望能够在后台执行可能长时间的操作。 AsyncTask 上的 Android 文档建议不要将它们用于可能运行时间超过几秒的任务(这是为什么?
所以我有外围 BLE 设备,我需要一些标识符以便稍后与另一部 iPhone 共享。示例我将 iPhone 'A' 连接到外围设备。 iPhone 'A' 将外围设备的标识符保存到数据库中,稍后我可以轻
当我指定这样的服务时: centralManager.scanForPeripherals(withServices:[BEAN_SERVICE_UUID],选项:[CBCentralManagerS
我是一名优秀的程序员,十分优秀!