public Observable connect()

in rx-central-ble/src/main/java/com/uber/rxcentralble/core/CoreConnectionManager.java [97:117]


  public Observable<Peripheral> connect(
          ScanMatcher scanMatcher, int scanTimeoutMs, int connectionTimeoutMs) {
    if (this.scanMatcher != null && !this.scanMatcher.equals(scanMatcher)) {
      return Observable.error(new ConnectionError(CONNECTION_IN_PROGRESS));
    } else if (sharedPeripheralObservable != null) {
      return sharedPeripheralObservable;
    }

    this.scanTimeoutMs = scanTimeoutMs;
    this.connectionTimeoutMs = connectionTimeoutMs;
    this.scanMatcher = scanMatcher;
    this.sharedPeripheralObservable = bluetoothDetector
            .enabled()
            .distinctUntilChanged()
            .filter(enabled -> enabled)
            .compose(scan(scanner, scanMatcher))
            .switchMap(scanData -> connect(scanData.getBluetoothDevice()))
            .compose(shareConnection());

    return sharedPeripheralObservable;
  }