Following connection to a BLE device which is advertising a specific service I'm interested in, in order to discover this service, I'm calling:
[self.peripheral discoverServices:@[[self.class serviceUUID]]];
The - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error
delegate method gets called with no error, yet the number of services returned for the peripheral is 0, and therefore no characteristics are further discovered. Does anyone have any idea why this is happening? Thanks in advance!
Below is the full body of the delegate method.
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
if (error) {
NSLog(@"didDiscoverServices failed: %@", error);
return;
}
NSLog(@"didDiscoverServices succeeded for peripheral: %@.", peripheral.name);
NSLog(@"Number of services: %d", peripheral.services.count);
for (CBService *s in peripheral.services) {
NSLog (@"Discovered service UUID: %@", s.UUID);
if ([s.UUID isEqual:[self.class serviceUUID]]) {
NSLog(@"Discover characteristics...");
[self.peripheral discoverCharacteristics:@[[self.class controlPointCharacteristicUUID], [self.class packetCharacteristicUUID]] forService:s];
}
}
}
The console shows:
2014-11-27 15:54:51.933 k[197:13362] didDiscoverServices succeeded for peripheral: BootK
2014-11-27 15:54:51.934 k[197:13362] Number of services: 0