RxAndroidBle - android naugat 中的 writeCharacterstics 失败

问题描述

我正在尝试使用 RxAndroidBLE API 在 BLE 设备上扫描、连接和执行写入操作。我正在使用以下代码进行 writeCharacterstic 操作

bluetoothGattcharacteristics.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
    final disposable disposable = connectionObservable
            .firstOrError()
            .flatMap(rxBleConnection -> rxBleConnection.writeCharacteristic(bluetoothGattcharacteristics,data))
            .subscribe(
                    characteristicValue -> {
                        onWriteSuccess();
                    },throwable -> {
                        onWriteFailure(throwable);
                    }
            );

代码在 android 9 或更高版本中运行良好(未在 android 8 上测试)。但在 android 7 上,writeCharacterstic 失败并显示错误 com.polidea.rxandroidble2.exceptions.BleGattCallbackTimeoutException: GATT exception from MAC address F6:91:6D:C6:37:1F,with type BleGattOperation{description='CHaraCTERISTIC_WRITE'}

我使用最新版本的 RxAndroidBLE i.e. 1.11.1。请建议..

更新

进一步研究,发现如果设备状态已经绑定在连接上(蓝牙设备保存在手机配对设备列表中),则写入操作失败。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)