Under iOS 5 once I connected to my BONDED peripheral, services are discovered fine and I am able to complete my connection and interact with the device.
However, under iOS 6, this is not the case. Once connected, peripheral data seems to be NULL. The only thing I get access to is the UUID. Name and Services are both NIL. I have tried [peripheral discoverServices:nil]; as well as [peripheral discoverServices:kMyServiceUUID]; and it appears to connect, but again, services are nil and I cannot complete my connection and interact with the peripheral.
In didConnectPeripheral I do the following:
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { self.activePeripheral = peripheral; if([self.activePeripheral.services count] == 0) { NSArray * pServices = [NSArray arrayWithObjects: [CBUUID UUIDWithString:kMyServiceUUID], nil]; [peripheral discoverServices:pServices]; } }
In didDiscoverServices, I do the following:
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { if(peripheral.services) { for (int i = 0; i<[peripheral.services count]; i++) { CBService *s = [peripheral.services objectAtIndex:i]; [peripheral discoverCharacteristics:nil forService:s]; } } else { if(peripheral.isConnected) { [peripheral performSelector:@selector(discoverServices:) withObject:nil afterDelay:2.0]; } } }
I am just not sure why the name and the services are blank after I have connected to this BONDED peripheral, and a NON-BONDED peripheral with the same services connects and discovers all services as expected.
Any insight into this issue is greatly appreciated. |