bt_btm_sec: btm_sec_disconnected clearing pending flag handle: reason:22
程序员文章站
2024-03-24 23:40:28
...
BLE连接遇到的问题
之前连接, 发现服务, 读写都正常, 今天突然点了一下系统蓝牙页面的配对.
之后死活连接不上BLE设备, 一连接立即会断开.
但是手机可以正常连接其他同类型的设备, 别的手机也可以连接这个设备
之前遇到类似的连接问题关闭蓝牙再开启就会正常. 这次关闭蓝牙再开启无效.
进入系统蓝牙设置里面设备尝试取消配对, 结果这个选项找不到了, 连接其他的同类型设备有取消配对选项, 连接蓝牙耳机, 音响也有取消配对选项
重启手机再连接, 无效
删除App重装再连接, 无效
奇怪的地方在于可以正常连接其他同类型的设备, 别的手机也可以连接这个设备, 就是这台手机不能连接这台设备
log如下:
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=3bc43f7d-8407-4d9b-8bfc-e5a4ed46eb87
D/BtGatt.GattService: registerClient() - UUID=3bc43f7d-8407-4d9b-8bfc-e5a4ed46eb87, pid=10004
D/BtGatt.GattService: onClientRegistered() - UUID=3bc43f7d-8407-4d9b-8bfc-e5a4ed46eb87, clientIf=8
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
D/A2dpService: getA2DPService(): returning [email protected]
D/BtGatt.GattService: clientConnect() - address=DF:F8:90:CC:60:49, isDirect=true
D/bt_btif_config: btif_get_address_type: Device [df:f8:90:cc:60:49] address type 1
D/bt_btif_config: btif_get_device_type: Device [df:f8:90:cc:60:49] type 2
W/bt_l2cap: l2cble_init_direct_conn
W/bt_btm: btm_acl_created hci_handle=8 link_role=0 transport=2
E/bt_btm: BTM_SetBlePhy failed, peer does not support request
W/bt_btif: bta_dm_acl_change info: 0x0
W/bt_l2cap: L2CA_SetDesireRole() new:x0, disallow_switch:0
D/bt_btif_dm: remote version info [df:f8:90:cc:60:49]: 0, 0, 0
E/BluetoothRemoteDevices: state12newState0
D/BluetoothRemoteDevices: aclStateChangeCallback: State:Connected to Device:DF:F8:90:CC:60:49
D/BtGatt.GattService: onConnected() - clientIf=8, connId=8, address=DF:F8:90:CC:60:49
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=DF:F8:90:CC:60:49
I/bt_btm_sec: btm_sec_disconnected clearing pending flag handle:8 reason:22
W/bt_btif: btif_gatt_set_encryption_cb() - Encryption failed (1)
W/bt_l2cap: L2CA_SetDesireRole() new:x0, disallow_switch:0
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=DF:F8:90:CC:60:49
I/bt_btm_sec: btm_sec_disconnected clearing pending flag handle:8 reason:22
W/bt_btif: btif_gatt_set_encryption_cb() - Encryption failed (1)
W/bt_l2cap: L2CA_SetDesireRole() new:x0, disallow_switch:0
D/BtGatt.GattService: onDisconnected() - clientIf=8, connId=8, address=DF:F8:90:CC:60:49
D/BluetoothGatt: onClientConnectionState() - status=22 clientIf=8 device=DF:F8:90:CC:60:49
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=8
D/BtGatt.GattService: unregisterClient() - clientIf=8
E/BluetoothRemoteDevices: state12newState1
D/BluetoothRemoteDevices: aclStateChangeCallback: State:DisConnected to Device:DF:F8:90:CC:60:49
看logcat里面的日志btm_sec_disconnected clearing pending flag handle:8 reason:22
找关于这条log的原因, 终于找到了一个思路.
进系统设置, 所有应用. 本机是小米6, 进入应用管理, 右上角弹出菜单选择显示所有应用,
搜索Bluetooth, 找到与之相关的应用, 清除数据.
搜索蓝牙,找到与之相关的应用, 清除数据.
回到系统蓝牙, 这个问题设备的取消配对选项回来了.
正常取消配对, 再回到App就能正常使用了.