Polidea/RxBluetoothKit

DidConnect to peripheral but Observe Connection not receive call back

morris-lu opened this issue · 1 comments

Describe the bug

Hi, thanks for the awesome framework.
Currently, I using establish connection and subscribe observe connection.
Here is my code

BluetoothManager.shared.peripheralManager = self.manager.observeState()
            .startWith(manager.state)
            .filter { $0 == .poweredOn }
            .flatMap { _ in self.manager.scanForPeripherals(withServices: [servicesId]) }
            .flatMap { _ in peripheral.establishConnection() }
            .subscribe(onNext: { peripheral in
                self.devicesTableView.reloadData(with: .fade)
                print("Connected to: \(peripheral)")
            },
                       onError: { error in
                        print("connect error", error)

            }
        )

I got log

didConnect(to: Peripheral(uuid: 62C8B54B-81F7-0E88-284A-A84460190461, name: Optional("E1AA0000          "))) 

but I didn't get call back in observe connection subscribe, when I click establish again I'll receive call back in observe connection. Do I miss any setup? Thank you very much.

Environment:

  • Device: [iPhone X]
  • OS: [iOS 13.3]
  • Library version [e.g. 5.3.0]
  • Swift version [e.g. 5]

Hi, I think it was my fault, I declare let manager = CentralManager(queue: .main) in two classes.

Now I only declare one is success to subscribe connection call back, thanks.