title: Minimal iOS BluetoothManager Example
body: <p>I've been constructing a minimal example for detecting nearby Bluetooth devices using the BluetoothManager private framework in iOS 5.0.</p>
  
  <p>Using an answer found in this question: <a href="https://stackoverflow.com/questions/6520185/finding-generic-bluetooth-devices-within-reach/">Finding generic Bluetooth devices within reach</a></p>
  
  <p>Here's my viewDidLoad method to register for the BluetoothAvailabilityChangedNotification. I also register for the BluetoothDeviceDiscoveredNotification as well.</p>
  
  <pre><code>[[NSNotificationCenter defaultCenter]
      addObserver:self
      selector:@selector(bluetoothAvailabilityChanged:)
      name:@"BluetoothAvailabilityChangedNotification"
      object:nil];
  
  btCont = [BluetoothManager sharedInstance];
  
  [[NSNotificationCenter defaultCenter]
      addObserver:self
      selector:@selector(deviceDiscovered:)
      name:@"BluetoothDeviceDiscoveredNotification"
      object:nil];
  </code></pre>
  
  <p>When I get the Bluetooth availability changed notification, I set the device scanning enabled, as outlined in one of the answers in the aforementioned link.</p>
  
  <pre><code>- (void)bluetoothAvailabilityChanged:(NSNotification *)notification
  {
      NSLog(@"BT State: %d", [btCont enabled]);
      [btCont setDeviceScanningEnabled:YES];
  }
  </code></pre>
  
  <p>For completeness, here's the deviceDiscovered notification method.</p>
  
  <pre><code>- (void)deviceDiscovered:(NSNotification *) notification
  {
      NSLog(@"Discovered one!");
  }
  </code></pre>
  
  <p>The logs produced by running the test application are as follows:</p>
  
  <pre><code>BTM: attaching to BTServer
  BTM: posting notification BluetoothAvailabilityChangedNotification
  BT State: 1
  BTM: setting device scanning enabled
  </code></pre>
  
  <p>Unfortunately, the phone isn't picking up any Bluetooth devices at all, even though I know there are proximate discoverable devices (verified using an Android device).</p>
  
  <p>Some things I have tried already:</p>
  
  <ul>
  <li>Calling [btCont setPowered: YES]; and registering for the associated power state change notification, executing setDeviceScanningEnabled:YES in the callback</li>
  <li>Calling [btCont resetDeviceScanning] prior to the setDeviceScanningEnabled call</li>
  <li>Calling the scanForConnectableDevices:(unsigned int)arg1; method, guessing that arg1 may be some kind of timeout value. I've tried a variety of values with no success.</li>
  </ul>
  
  <p>Any thoughts would be much appreciated.
  Thanks!</p>