We developing device based on Nordic nRF51 bluetooth low energy chip, whitch acts in peripheral mode, and have android application, whitch acts as bluetooth central. Application starts advertising and our device makes pair with phone (popup dialog requesting PIN code appears).
We faced really strange problem on some phones, especially on Xiaomi phones (I use Xiaomi Redmi Note 3 Pro): bluetooth pairing works correctly only when phone connected to ADB:
- I start advertising without USB cable connected to phone
- PIN code dialog appeared
- I enter valid PIN code
- I can see that bluetooth pair has been created, but device stops communication and makes disconnect right after bluetooth pair has been created.
If I plug USB cable to phone to see logcat in Android studio everything works perfectly - Bluetooth pairing works fine and device can do communication to phone! This problem occures only in some models of phones. I also tried to modify "Release" settings in Android studio to disable optimisation and add bebug information in release build, but it is not solves the problem.
Logcat (Pairing works normally):
D/GATT: StartSearch
[ 02-08 15:31:58.797 5676: 5875 E/ ]
GKI_timer_update no work to be done when expected work
D/BluetoothGattServer: registerCallback()
D/BluetoothGattServer: registerCallback() - UUID=042e51cd-6278-4200-9b36-480576e8bcc0
D/BluetoothGattServer: onServerRegistered() - status=0 serverIf=5
D/BluetoothGattServer: addService() - service: 6e400004-b5a3-f393-e0a9-e50e24dcca9e
D/BluetoothGattServer: onServiceAdded() - service=6e400004-b5a3-f393-e0a9-e50e24dcca9estatus=0
D/GattServer: Our gatt server service was added.
D/BluetoothLeAdvertiser: onClientRegistered() - status=0 clientIf=6
D/advertise: onStartSuccess
[ 02-08 15:31:59.397 5676: 5875 E/ ]
GKI_timer_update no work to be done when expected work
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state
D/GattServer: 2
[ 02-08 15:31:59.407 5676: 5875 E/ ]
GKI_timer_update no work to be done when expected work
D/GattServer: Our gatt server descriptor was written.
I/GattServer: SUBSCRIBE !!!
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state
D/GattServer: 0
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state
D/GattServer: 2
D/QueryManager: Send command 06 02 62
[ 02-08 15:32:14.757 5676: 5875 E/ ]
GKI_timer_update no work to be done when expected work
D/Gatt: Send data 00 06 02 62 00 , MAC: F9:D4:DB:18:27:49
D/GattServer: onNotificationSent
D/GattServer: We have received a write request for one of our hosted characteristics: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D/GattServer: data = 00 02 06 62 9B C1 C1 C1 C1 C1 C1 C1 00
D/QueryManager: Send command 06 02 22 00
D/GattServer: onNotificationSent
D/Gatt: Send data 00 06 02 22 C1 00 , MAC: F9:D4:DB:18:27:49
D/GattServer: We have received a write request for one of our hosted characteristics: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
D/GattServer: data = 00 02 06 22 C1 00
D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=5 device=F9:D4:DB:18:27:49
D/GattServer: Our gatt server connection state changed, new state
D/GattServer: 0
May be there is some way to display logcat in app without making ADB conenction without USB or I missed something in log.
I also don't understand this line: GKI_timer_update no work to be done when expected work