1
votes

Can i connect two idevice using core bluetooth framework?I am using following code snippet:

cBCM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

[cBCM scanForPeripheralsWithServices:nil options:nil];


- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {

}

but the delegates are not firing at all. any solution?

1

1 Answers

1
votes

Instead of trying to fire didDiscoverCharacteristicsForService you should try the didDiscoverPeripheral which will fire on all periperals. The didDiscoverChar... will only trigger if you have found a specific characteristic within the peripherals properties.

When didDiscover... triggers you can try printing out it's name by

// Discovered peripheral
- (void) centralManager:(CBCentralManager *)central 
didDiscoverPeripheral:(CBPeripheral *)peripheral 
  advertisementData:(NSDictionary *)advertisementData 
               RSSI:(NSNumber *)RSSI 
{
    // Print out the name parameter of the discovered peripheral
    @NSSlog ("Discovered peripheral: %@", [peripheral name];
}