iOS CoreBluetooth不扫描iPad Air中的服务

我正在开发一个连接到BLE外设的应用程序,并从中接收数据。

它扫描外围设备,查找外围设备,发现服务,如果找到了正确的服务,它会接收数据。

它在iPhone 5上运行良好,但是当我在iPad Air上运行它时,它会连接,但不会发现任何服务,也不会收到任何数据。 两台设备都运行iOS 7.0.4

这是代码的一些相关部分

- (void)startScan { [manager scanForPeripheralsWithServices:nil options:nil]; } - (void)stopScan { [manager stopScan]; } - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { NSLog(@"Did discover peripheral. peripheral: %@ rssi: %@, id: %@ advertisementData: %@ ", peripheral, RSSI, peripheral.identifier, advertisementData); if(![self.dicoveredPeripherals containsObject:peripheral]) [self.dicoveredPeripherals addObject:peripheral]; [manager retrievePeripheralsWithIdentifiers:[NSArray arrayWithObject:(id)peripheral.identifier]]; [manager connectPeripheral:peripheral options:[NSDictionary dictionaryWithObject: [NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey]]; } - (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals { NSLog(@"Retrieved peripheral: %lu - %@", (unsigned long)[peripherals count], peripherals); [self stopScan]; /* If there are any known devices, automatically connect to it.*/ if([peripherals count] >= 1) { testPeripheral = [peripherals objectAtIndex:0]; [manager connectPeripheral:testPeripheral options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBConnectPeripheralOptionNotifyOnDisconnectionKey]]; } } - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { NSLog(@"Did connect to peripheral: %@", peripheral); [self.delegate statusMessage:[NSString stringWithFormat:@"Did connect to peripheral: %@\n", peripheral]]; [peripheral setDelegate:self]; [peripheral discoverServices:nil]; } - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { for (CBService *service in peripheral.services) { NSLog(@"discovered service [%@]",service.UUID); [peripheral discoverCharacteristics:nil forService:service]; } } 

iPhone 5上的日志输出是:

 Did discover peripheral. peripheral:  rssi: -53, id:  3EE10DD6-99CD-7E9C-C492-087CE3B980E6 advertisementData: { kCBAdvDataChannel = 38; kCBAdvDataIsConnectable = 1; kCBAdvDataLocalName = BLESensor; kCBAdvDataServiceUUIDs = ( "Unknown ()" ); kCBAdvDataTxPowerLevel = 0; } Did connect to peripheral:  Connected discovered service [Device Information] discovered service [Unknown ()] discovered service [Unknown ()] Service found with UUID: Device Information 

在iPadAir上,它只是到达连接的部分,没有找到任何服务:

 Did discover peripheral. peripheral:  rssi: -60, id:  23890BB4-FB07-AA1A-8D4F-B1427C859447 advertisementData: { kCBAdvDataChannel = 39; kCBAdvDataIsConnectable = 1; kCBAdvDataLocalName = BLESensor; kCBAdvDataServiceUUIDs = ( "Unknown ()" ); kCBAdvDataTxPowerLevel = 0; } Did connect to peripheral:  Connected 

Apple承认这是iOS 7.0中的一个问题。 他们承诺在iOS 7.1中解决它。 我用iOS 7.1测试了它,它就解决了。