title: Bluetooth connection between 2 iOS devices
body: <p>I am trying out <a href="http://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/_index.html" rel="nofollow noreferrer">Core Bluetooth framework</a> introduced in iOS 5.0. According to many threads (<a href="https://stackoverflow.com/questions/10697728/ios-and-bluetooth-low-energy">one of many</a>) on StackOverflow itself:</p>
  
  <ol>
  <li>Core Bluetooth framework can be used to communicate with <strong>ANY</strong>
  hardware, which has Bluetooth Low Energy (4.0) hardware support.</li>
  <li>We can forget about Made For iPhone/iPod (MFI) program, if you are
  using Core Bluetooth technology.</li>
  </ol>
  
  <p>I have an iPhone 5, iPhone 4S, Google Android Nexus 7 with me, and I am sure at least first 2 has hardware support for BLE. </p>
  
  <h2>My Question is</h2>
  
  <p>Well, I tried below given code on my iPhone 4S/iPhone 5, but it failed to scan and find the iPhone5/iPhone 4S sitting near by. I can confirm, both devices had bluetooth turned ON. The delegate method <code>didDiscoverPeripheral</code> never getting called. 
  What might be the reasons? Am I missing something?</p>
  
  <p>This is my code (stripped down to a small test project).</p>
  
  <h3>ViewController.h</h3>
  
  <pre><code>@interface ViewController:UIViewController&lt;CBCentralManagerDelegate, CBPeripheralDelegate{
  }
  @property (strong, nonatomic) CBCentralManager *mCentralManager;
  @end
  </code></pre>
  
  <h3>ViewController.m</h3>
  
  <pre><code>@implementation ViewController
  @synthesize mCentralManager;
  
  - (void)viewDidLoad{
      [super viewDidLoad];
      mCentralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil];
      [self scanForPeripherals];
  }
  
  - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
      NSLog(@"Received periferal :%@",peripheral);
  }
  
  - (int) scanForPeripherals {
      if (self.mCentralManager.state != CBCentralManagerStatePoweredOn)
      {
          NSLog(@"self.mCentralManagerState : %d",self.mCentralManager.state);
          return -1;
      }
      //Getting here alright.. bluetooth is powered on.
      NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
      //Documentation says passind nil as device UUID, scans and finds every peripherals
      [self.mCentralManager scanForPeripheralsWithServices:nil options:options];
      return 0;
  }
  @end
  </code></pre>