BLE外围设备最初连接到手机。断开连接后,我尝试重新连接但失败了。 adb日志如下:
[ 12-30 17:30:48.121 27906:27906 D/BluetoothGatt ]
connect() - device: 12:34:56:78:9A:BC, auto: false
[ 12-30 17:30:48.121 27906:27906 D/BluetoothGatt ]
registerApp()
[ 12-30 17:30:48.121 27906:27906 D/BluetoothGatt ]
registerApp() - UUID=1d76d00f-0a8e-4924-b416-424b1f67e479
[ 12-30 17:30:48.131 6168: 6248 D/BtGatt.GattService ]
registerClient() - UUID=1d76d00f-0a8e-4924-b416-424b1f67e479
[ 12-30 17:30:48.171 6168: 6247 D/BtGatt.GattService ]
onClientRegistered() - UUID=1d76d00f-0a8e-4924-b416-424b1f67e479, clientIf=7
[ 12-30 17:30:48.171 27906:27918 D/BluetoothGatt ]
onClientRegistered() - status=0 clientIf=7
[ 12-30 17:30:48.171 6168: 6748 D/BtGatt.GattService ]
clientConnect() - address=12:34:56:78:9A:BC, isDirect=true set own addr = false own addr type:0
[ 12-30 17:30:48.171 6168: 6247 D/BtGatt.btif ]
btif_get_device_type: Device [12:34:56:78:9a:bc] type 3, addr. type 0
[ 12-30 17:30:49.401 6168: 6249 W/bt-btif ]
bta_gattc_conn_cback() - cif=4 connected=0 conn_id=4 reason=0x0013
[ 12-30 17:30:49.401 6168: 6249 W/bt-btif ]
bta_gattc_conn_cback() - cif=5 connected=0 conn_id=5 reason=0x0013
[ 12-30 17:30:49.401 6168: 6249 W/bt-btif ]
bta_gattc_conn_cback() - cif=6 connected=0 conn_id=6 reason=0x0013
[ 12-30 17:30:49.401 6168: 6249 W/bt-btif ]
bta_gattc_conn_cback() - cif=7 connected=0 conn_id=7 reason=0x0013
[ 12-30 17:30:49.401 6168: 6249 E/bt-btm ]
btm_sec_disconnected - Clearing Pending flag
[ 12-30 17:30:49.401 6168: 6247 D/BtGatt.GattService ]
onConnected() - clientIf=7, connId=0, address=12:34:56:78:9A:BC
[ 12-30 17:30:49.401 27906:27920 D/BluetoothGatt ]
onClientConnectionState() - status=133 clientIf=7 device=12:34:56:78:9A:BC
日志表示由于原因0x0013,设备未连接。我在源代码中跟踪了错误,找到了bta_gattc_conn_cback()here。 “原因”是“tGATT_DISCONN_REASON”类型,它本质上是一个整数。但是,我没有找到代码中0x0013的含义。
手机是搭载Android 5.1.1的三星Galaxy S6。
任何建议表示赞赏。