IOS CoreBluetooth does not scan services in iPad Air

I am working on an application that connects to a BLE peripheral device and receives data from it.

It scans peripheral devices, finds a peripheral device, discovers services, and if the correct service is found, it receives data.

It works fine on the iPhone 5, but when I launch it on the iPad Air, it connects, but does not detect any services and does not receive any data. Both devices run iOS 7.0.4

These are some of the relevant parts of the code.

- (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];
    }
}

Log Out on iPhone 5:

Did discover peripheral. peripheral: <CBPeripheral: 0x14587320 identifier = 3EE10DD6-99CD-  7E9C-C492-087CE3B980E6, Name = "BLE Sens", state = disconnected> rssi: -53, id:     <__NSConcreteUUID 0x145f82f0> 3EE10DD6-99CD-7E9C-C492-087CE3B980E6 advertisementData: {
kCBAdvDataChannel = 38;
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = BLESensor;
kCBAdvDataServiceUUIDs =     (
    "Unknown (<fff0>)"
);
kCBAdvDataTxPowerLevel = 0;
} 

Did connect to peripheral: <CBPeripheral: 0x14587320 identifier = 3EE10DD6-99CD-7E9C-C492-087CE3B980E6, Name = "BLE Sens", state = connected>

Connected
discovered service [Device Information]
discovered service [Unknown (<fff0>)]
discovered service [Unknown (<ffe0>)]
Service found with UUID: Device Information

On iPadAir, it simply gets to the connected part and no services were found:

Did discover peripheral. peripheral: <CBPeripheral: 0x1700a1440 identifier = 23890BB4-FB07-AA1A-8D4F-B1427C859447, Name = "BLE Sens", state = disconnected> rssi: -60, id:   <__NSConcreteUUID 0x17802f740> 23890BB4-FB07-AA1A-8D4F-B1427C859447 advertisementData: {
    kCBAdvDataChannel = 39;
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = BLESensor;
kCBAdvDataServiceUUIDs =     (
    "Unknown (<fff0>)"
);
kCBAdvDataTxPowerLevel = 0;
} 

Did connect to peripheral: <CBPeripheral: 0x1700a1440 identifier = 23890BB4-FB07-AA1A-8D4F-B1427C859447, Name = "BLE Sens", state = connected>
 Connected 
+3
source share
1 answer

Apple , iOS 7.0. iOS 7.1. iOS 7.1, .

0

Source: https://habr.com/ru/post/1539059/


All Articles