0

I am using the polidea library(1.4.2) successfully with a lot of devices, however, with the Huawei P9 I cannot connect at all. The piece of code I can share is the following:

public Flowable<Integer> connectToRobot(String address) {
    initBleDevice(address);
    initInternalLibrary(); -> cannot share code for this.
    return RxJavaInterop.toV2Flowable(rxBleDevice.establishConnection(false))
            .observeOn(AndroidSchedulers.mainThread())
            .delay(5, TimeUnit.SECONDS)
            .doOnNext(conn -> connection = conn)
            .flatMap(new Function<RxBleConnection, Publisher<Observable<byte[]>>>() {
                @Override
                public Publisher<Observable<byte[]>> apply(@NonNull RxBleConnection conn) throws Exception {
                    return RxJavaInterop.toV2Flowable(connection.setupNotification(UUID.fromString(notifyCharacteristic)))
                            .observeOn(AndroidSchedulers.mainThread())
                            .doOnNext(observable -> internalMethod()// cannot share)
                            .doOnNext(observable -> observable.subscribe(new Action1<byte[]>() {
                                @Override
                                public void call(byte[] bytes) {
                                    //internal code
                                }
                            }, new Action1<Throwable>() {
                                @Override
                                public void call(Throwable throwable) {
                                    Log.e(TAG, "Throwable in receiving byte data." + throwable);
                                }
                            }))
                            .onErrorResumeNext(throwable -> {
                                return Flowable.error(new RobBleCoreException(throwable));
                            });
                }
            })

 private void initBleDevice(String address) {
    this.rxBleDevice = rxBleClient.getBleDevice(address);
}

I thought a delay would fix the issue but it seems that it is not. Can anyone tell me why this code can work with a lot of devices:

  • Samsung S6, 7Edge - Android 7
  • Pixel - 8.0
  • Moto E4 - Android 6
  • Huawei tablets - Android 4.4.2
  • ...other devices as well

but cannot work with Huawei P9(model EVAL-L19) Android 7 and also P8, Android 6 or 7.0(not sure, I am waiting for a detailed bug report). During debug I noticed a disconnect exception being received.

 exception:cc.robart.bluetooth.sdk.exceptions.RobBleCoreException: BleDisconnectedException{bluetoothDeviceAddress='34:15:13:E2:18:CA'}
Andrei T
  • 2,985
  • 3
  • 21
  • 28
  • 1
    Do you have more logs from the device? So far it seems that it is a problem with Huawei BLE stack on newer OSes. If that is the case then sniffing BLE could give a hint on what could be done from the peripheral side to workawound the issue. – Dariusz Seweryn Nov 14 '17 at 22:20
  • I contacted support from your company as I have no time to waste back and forth. We discovered this on a few more devices, like Moto G4 for example. – Andrei T Nov 17 '17 at 10:04

0 Answers0