title: iOS CoreBluetooth : centralManager:didConnectPeripheral / didFailToConnectPeripheral: not getting called
body: <p>I'm pulling my hair out of this problems. I'm trying to <strong>connect to BLE devices</strong>, can't see what I've done wrong in my code below.</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
  
      _cm = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
  }
  
  - (void)viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
  }
  
  
  - (void)didReceiveMemoryWarning {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  + (NSString*)UUIDString:(CFUUIDRef)uuid {
      CFStringRef string = CFUUIDCreateString(NULL, uuid);
      return (__bridge_transfer NSString*)string;
  }
  
  - (void)centralManagerDidUpdateState:(CBCentralManager *)central {
      if (central.state == CBCentralManagerStatePoweredOn) {
          [self scanForPeripherals];
      }
  }
  
  - (void)centralManager:(CBCentralManager *)central
   didDiscoverPeripheral:(CBPeripheral *)peripheral
       advertisementData:(NSDictionary *)advertisementData
                    RSSI:(NSNumber *)RSSI {
  //    NSLog(@"Received peripheral : \n%@", peripheral);
  //    NSLog(@"Adv data : %@", advertisementData);
  
      [peripheral setDelegate:self];
      [central connectPeripheral:peripheral options:nil];
      [peripheral readRSSI];
  }
  
  - (int)scanForPeripherals {
      NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSNumber numberWithBool:NO], CBCentralManagerScanOptionAllowDuplicatesKey,
                               nil];
  
      [_cm scanForPeripheralsWithServices:nil options:options];
      return 0;
  }
  
  - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
      NSLog(@"didConnectPeripheral");
  }
  
  - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
      NSLog(@"didDisconnectPeripheral");
  }
  
  - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
      NSLog(@"failed to connect");
  }
  
  - (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
      NSLog(@"didReadRSSI");
  }
  </code></pre>
  
  <p>These devices are not my own. I don't know its proximity UUID, but as far as I know, It won't be needed in connecting via CoreBluetooth right?</p>
  
  <p>All of the devices are discovered in <code>didDiscoverPeripheral:</code>, in the selector I tried to connect them. But there's nothing comes after that.</p>
  
  <p>Am I to expect a dialog with Pairing Password Request when I called to <code>didDiscoverPeripheral:</code>?
  If so I don't see any dialog, why is that?</p>
  
  <p>From apple documents, It clearly stated that after trying to connect to a device you should get a called to either <code>didConnectPeripheral</code> or <code>didFailToConnectPeripher</code> but I got none.</p>
  
  <p>Any thoughts? I've been trying for almost a week now.
  Appreciate every helps, thanks.</p>