Android BLE reconnection failed with reason 0x0013
<p>The BLE peripheral device was connected to the phone initially. After it was disconnected, I tried to reconnect but failed. The adb log was as follows: </p>

<pre><code>[ 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
</code></pre>

<p>The log said the device was not connected because of reason 0x0013. I traced the error in the source code, and found bta_gattc_conn_cback() <a href="http://androidxref.com/5.1.1_r6/xref/external/bluetooth/bluedroid/bta/gatt/bta_gattc_act.c#1788" rel="nofollow noreferrer">here</a>. The "reason" was a "tGATT_DISCONN_REASON" type, which was essentially an integer. However, I didn't find what 0x0013 meant in the code. </p>

<p>The phone was Samsung Galaxy S6 with Android 5.1.1. </p>

<p>Any suggestion is appreciated. </p>