0

I have an android application that has BLE GATT Server running so the android phone would be a peripheral device and other devices can connect to it.

Sometimes the connections works fine, but very often when I try to pair the external device to the phone I got these errors:

 aclStateChangeCallback: device is NULL, address=81:6C:0F:1A:6C:37, newState=0
 bt_btm: btm_ble_read_remote_features_complete: failed for handle: 0x0010, status 0x1a
 bt_stack: [ERROR:gatt_db.cc(93)] gatts_check_attr_readability: GATT_READ_NOT_PERMIT

After pairing, I am connected to the device, 1 characteristic is written and just before the 2nd characteristic is read the device is disconnected. Always the time before disconnect is 9 seconds after connection is established.

Absolutely the same device and application are sometimes paired and work correct, sometimes are not.. Do you have any idea what might be causing the problem?

Here is some more information from logcat:

2019-03-18 18:48:29.132 20305-20329/? E/BluetoothRemoteDevices: aclStateChangeCallback: device is NULL, address=81:6C:0F:1A:6C:37, newState=0
2019-03-18 18:48:29.134 21813-21831/com.test I/GattServerCallback: BluetoothDevice CONNECTED: 81:6C:0F:1A:6C:37, state: 0, newState: 2
2019-03-18 18:48:29.167 20305-20357/? E/bt_btm: btm_ble_read_remote_features_complete: failed for handle: 0x0010, status 0x1a
2019-03-18 18:48:32.629 21813-21813/com.test D/TestApp: getCharacteristicValue characteristic: 3291dcea-0189-3A9c-b193-26ec13029190
2019-03-18 18:48:32.667 20305-20357/? E/bt_stack: [ERROR:gatt_db.cc(93)] gatts_check_attr_readability: GATT_READ_NOT_PERMIT
2019-03-18 18:48:38.867 20305-20357/? I/bt_btm_sec: btm_sec_disconnected clearing pending flag handle:10 reason:8
2019-03-18 18:48:38.870 20305-20329/? W/bt_btif: btif_av_move_idle: ACL Disconnected state 0 bd_addr=81:6C:0F:1A:6C:37 peer_bda=00:00:00:00:00:00
2019-03-18 18:48:38.871 21813-21831/com.test D/BluetoothGattServer: onServerConnectionState() - status=0 serverIf=7 device=81:6C:0F:1A:6C:37
2019-03-18 18:48:38.871 21813-21831/com.test D/GattServerCallback: onDeviceDisconnect
2019-03-18 18:48:38.871 20305-20329/? E/BluetoothRemoteDevices: aclStateChangeCallback: device is NULL, address=81:6C:0F:1A:6C:37, newState=1
2019-03-18 18:48:38.883 21813-21831/com.test I/GattServerCallback: BluetoothDevice DISCONNECTED: 81:6C:0F:1A:6C:37, state: 0, newState: 0

Here is a picture of the HCI log: enter image description here

Frame 37885 is the disconnected event. The message is Connection Timeout. Frame 37883 is the GATT_READ_NOT_PERMIT event. So it seems that communication stops after the GATT_READ_NOT_PERMIT event.

Here is an image of the correct flow when everything is working fine. The difference is that the frame with handle id = 3(Service Changed) is missing. So I guess this might be related to this event - Service Changed.. I am not sure when this is triggered and if this is requested by the central device but it is always after the 1st read of characteristics.

enter image description here

This is the log with the Disconnect message:

enter image description here

Radoslav Ignatov
  • 143
  • 3
  • 16
  • Can you check the reason/error code in the Disconnected event in the hci snoop log? – Emil Mar 18 '19 at 17:54
  • @Emil I added a screen shot of the HCI log. What I can see is that there is a read request with handle 3 and UUID - Service Changed, but I can't figure it out what does this mean.. I get disconnected after this error response. – Radoslav Ignatov Mar 19 '19 at 14:01
  • And where is the Disconnected event in your log? What's the error code for that? I'm not sure that the GATT read is related. – Emil Mar 19 '19 at 15:38
  • @Emil I updated the question. The error is Connection Timeout and I am sure it is related to the GATT_READ_NOT_PERMIT because the communication stops after that error. – Radoslav Ignatov Mar 19 '19 at 16:46
  • Connection Timeout has nothing to do with high level operations such as GATT. It just means the radios failed to communicate with each other. Either one of the radios is bad or one of the clocks drift more than they should, leading to synchronization issues. You could try different connection parameters, even though that doesn't solve the root cause. – Emil Mar 19 '19 at 17:58
  • Do you have any idea how I can see the UUID of the attribute in the HCI log? I can only see the handle now. @Emil I also added a picture with the log when the app works. After receiving read request for attribute with handle 3 it stops working. – Radoslav Ignatov Mar 21 '19 at 15:11

0 Answers0