I am developing a BLE application on my Nexus 5 running Android KitKat (4.4.3). I have run into an issue in establishing Bluetooth connection and having difficulties to identify them as an API bug or my misusing of the API. I couldn't re-establish the Bluetooth connection using Gatt service after turning Bluetooth off for a while and then turning it on. I attach below some of the logs related to Bluetooth from the device:
...
07-21 13:26:10.054 D/BleFacade( 1429): onDisconnectCompleted thread start
07-21 13:26:10.054 D/BluetoothGatt( 1429): close()
07-21 13:26:10.054 D/BluetoothGatt( 1429): unregisterApp() - mClientIf=5
07-21 13:26:10.064 D/BleAdapterForK( 1429): startScan (name)BTUDR102
07-21 13:26:10.064 D/BluetoothAdapter( 1429): startLeScan(): null
07-21 13:26:10.064 D/BluetoothAdapter( 1429): onClientRegistered() - status=0 clientIf=5
07-21 13:26:10.064 D/BleAdapterForK( 1429): startScan starts scan
07-21 13:26:10.064 D/BleScan ( 1429): CHANGE SCAN_NEVER to SCAN_ALWAYS_BEFORE_PARTIAL
07-21 13:26:10.064 D/BleScan ( 1429): scan for 30000ms
07-21 13:26:10.064 D/BleFacade( 1429): onDisconnectCompleted thread start scan
07-21 13:26:11.534 D/BleAdapterForK( 1429): onLeScan scanned:BTUDR102
07-21 13:26:11.534 D/BleAdapterForK( 1429): onLeScan target:BTUDR102
07-21 13:26:11.534 D/BleFacade( 1429): onScanResult
07-21 13:26:11.534 D/BleFacade( 1429): onScanResult stops scan and connect device
07-21 13:26:11.584 D/BleScan ( 1429): stop with scanState:BLE_SCAN_STATE_ALWAYS_BEFORE_PARTIAL
07-21 13:26:11.584 D/BluetoothAdapter( 1429): stopLeScan()
07-21 13:26:11.594 D/BleAdapterForK( 1429): stop scan
07-21 13:26:11.614 D/BleScan ( 1429): stop with scanState:BLE_SCAN_STATE_NEVER
07-21 13:26:11.614 D/BluetoothGatt( 1429): connect() - device: 00:80:45:04:D0:02, auto: false
07-21 13:26:11.614 D/BluetoothGatt( 1429): registerApp()
07-21 13:26:11.614 D/BluetoothGatt( 1429): registerApp() - UUID=7e77f3aa-cf13-4b80-acfa-d3bae5d760bd
07-21 13:26:11.624 D/BluetoothGatt( 1429): onClientRegistered() - status=0 clientIf=5
07-21 13:26:11.624 D/BleAdapterForK( 1429): connect connectGatt call is OK
07-21 13:26:41.634 D/BluetoothGatt( 1429): onClientConnectionState() - status=133 clientIf=5 device=00:80:45:04:D0:02
07-21 13:26:41.634 E/BleDataCtrl( 1429): onConnectionStateChange GATT INTERNAL error
07-21 13:26:41.634 E/BleFacade( 1429): onConnectFailed error:-1
07-21 13:26:41.694 D/BleFacade( 1429): onConnectFailed thread start
07-21 13:26:41.694 D/BluetoothGatt( 1429): close()
07-21 13:26:41.694 D/BluetoothGatt( 1429): unregisterApp() - mClientIf=5
07-21 13:26:41.704 D/BluetoothController( 1429): onBleConnectFailed
07-21 13:26:41.704 D/CarCommunicateService( 1429): onDeviceConnectionStateChanged:DEVICE_CONNECTSTATUS_DISCONNECTED
07-21 13:26:41.704 V/CarCommunicateService( 1429): > onDisconnected()
...