title: CoreBluetooth connect to only nearest RSSI (BLE)
body: <p>I am looking for a way to connect to <strong>only</strong> the <strong>nearest</strong> peripheral based on the RSSI. My goal is to leave other peripherals listed but only have the closest peripheral connect.</p>
  
  <p>Since RSSI is only available <strong>while the device is connected</strong>, would it make sense to wait till all the devices are connected then determine the closest peripheral based on the RSSI then disconnect the rest?</p>
  
  <h2>Connect</h2>
  
  <pre><code>- (void) connectToPeripheral:(CBPeripheral *)peripheral
  {
      NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],CBConnectPeripheralOptionNotifyOnDisconnectionKey,nil];
      [myCBCentralManager connectPeripheral:peripheral options:options];
  }
  </code></pre>
  
  <h2>Delegates used</h2>
  
  <pre><code>- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
  
  - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error;
  
  - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral;
  </code></pre>
  
  <h2>CBPeripheral</h2>
  
  <pre><code>/*!
   *  @property RSSI
   *
   *  @discussion While connected, the RSSI of the link in decibels.
   */
  @property(retain, readonly) NSNumber *RSSI;
  </code></pre>