BLE 应用程序无法通过 device.connectGatt 连接到配对设备

问题描述

我制作了一个安卓应用程序,它可以连接到 BLE 设备并读取特征并获得通知。该应用程序适用于我直接从该应用程序连接的 BLE 设备。但是,当我尝试连接到已与手机蓝牙配对的设备时,出现以下错误:

2021-01-13 11:00:21.792 11478-11478/com.example.wbdmx I/BluetoothDevice: connectGatt
2021-01-13 11:00:21.793 11478-11478/com.example.wbdmx D/BluetoothGatt: connect() - device: 00:13:01:10:BB:31,auto: false
2021-01-13 11:00:21.793 11478-11478/com.example.wbdmx D/BluetoothGatt: registerApp()
2021-01-13 11:00:21.793 11478-11478/com.example.wbdmx D/BluetoothGatt: registerApp() - UUID=a48bfab1-2223-452a-b804-d988600dfbb3
2021-01-13 11:00:21.796 11478-11531/com.example.wbdmx D/OpenGLRenderer:   HWUI Binary is  enabled
2021-01-13 11:00:21.796 11478-11531/com.example.wbdmx D/OpenGLRenderer: disableOutlineDraw is true
2021-01-13 11:00:21.797 11478-11497/com.example.wbdmx D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7
2021-01-13 11:00:21.821 11478-11478/com.example.wbdmx W/InputMethodManager: startInputReason = 1
2021-01-13 11:00:21.825 11478-11531/com.example.wbdmx D/OpenGLRenderer:   HWUI Binary is  enabled
2021-01-13 11:00:21.825 11478-11531/com.example.wbdmx D/OpenGLRenderer: disableOutlineDraw is true
2021-01-13 11:00:21.840 11478-11624/com.example.wbdmx D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=00:13:01:10:BB:31
2021-01-13 11:00:21.840 11478-11624/com.example.wbdmx W/onConnectionStateChange: state133
2021-01-13 11:00:22.006 11478-11531/com.example.wbdmx W/libEGL: EGLNativeWindowType 0x7a17374010 disconnect failed
2021-01-13 11:00:22.013 11478-11478/com.example.wbdmx D/ViewRootImpl[MainActivity]: surface should not be released
2021-01-13 11:00:23.400 11478-11478/com.example.wbdmx D/AwareBitmapCacher: handleInit switch not opened pid=11478
2021-01-13 11:00:23.679 11478-11531/com.example.wbdmx W/libEGL: EGLNativeWindowType 0x7a04679010 disconnect failed

即使我在我的应用程序上扫描后发现了配对的设备,我也无法连接到它的 Gatt。 要详细了解我如何连接设备,您可以查看代码 here

解决方法

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

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

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