Open manikavi opened 7 years ago
Error 129 (0x81) means GATT_INTERNAL_ERROR (see https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.3_r1.1/stack/include/gatt_api.h). That's unfortunately not very precise. Could you tell me on which kind of smartphone that occurs?
When I read the log you attached I can see that discoverServices was started twice. That might be an issue and might result in an error for the search. I would introduce a boolean flag like discoveryIsInProgress in your BluetoothLeService and only a start a new service discovery if another one isn't in progress. The problem might be that a second discovery is started while the first is in progress. The Bluetooth LE stack is really fragile ...
@StevenMohr
Okay,
@StevenMohr , did you check that?
@manikavi No, I can't. I don't have a blood pressure meter available. Did the fix change anything?
No sir,I'm still trying to get readings from BP device
@manikavi Could you push your changes to GitHub?
@StevenMohr ,
This Log is From Same Phone,now didnt get 129 error,did n't do any modification in code,I think I clicked on Scan menu which appears on top right corner twice ,so discoverServices() function is called twice
10-13 10:24:11.832 3996-3996/com.example.android.bluetoothlegatt I/art: Late-enabling -Xcheck:jni
10-13 10:24:12.204 3996-3996/com.example.android.bluetoothlegatt I/Device Version: 22
10-13 10:24:12.285 3996-3996/com.example.android.bluetoothlegatt D/BluetoothAdapter: startLeScan(): null
10-13 10:24:12.408 3996-4013/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
10-13 10:24:12.467 3996-4051/com.example.android.bluetoothlegatt D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
10-13 10:24:12.517 3996-3996/com.example.android.bluetoothlegatt D/Atlas: Validating map...
10-13 10:24:12.706 3996-4051/com.example.android.bluetoothlegatt I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016_msm8226_LA.BF.1.1.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.03.00
Build Date: 02/11/15 Wed
Local Branch:
Remote Branch: quic/LA.BF.1.1.1_rb1.10
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016 + 62ca4eb + acd831d + 9f8b442 + e027a02 + cba30ba + 53c303a + a649d79 + 23e16f8 + 5e97da7 + cbd2a44 + 33d072a + 7aacf06 + 72b33e7 + 28f6f60 + b4c13d8 + NOTHING
10-13 10:24:12.713 3996-4051/com.example.android.bluetoothlegatt I/OpenGLRenderer: Initialized EGL, version 1.4
10-13 10:24:12.836 3996-4051/com.example.android.bluetoothlegatt D/OpenGLRenderer: Enabling debug mode 0
10-13 10:25:12.336 3996-3996/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
10-13 10:25:17.509 3996-3996/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
10-13 10:25:17.511 3996-3996/com.example.android.bluetoothlegatt D/BluetoothAdapter: scan not started yet
10-13 10:25:17.738 3996-3996/com.example.android.bluetoothlegatt I/BluetoothLeService: Going to connect with D0:5F:B8:03:79:70
10-13 10:25:17.744 3996-3996/com.example.android.bluetoothlegatt D/BluetoothGatt: connect() - device: D0:5F:B8:03:79:70, auto: false
10-13 10:25:17.745 3996-3996/com.example.android.bluetoothlegatt D/BluetoothGatt: registerApp()
10-13 10:25:17.745 3996-3996/com.example.android.bluetoothlegatt D/BluetoothGatt: registerApp() - UUID=9e0e8f07-5c3d-475e-84bd-fde1b458d870
10-13 10:25:17.747 3996-4013/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
10-13 10:25:17.749 3996-3996/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to create a new connection.
10-13 10:25:17.749 3996-3996/com.example.android.bluetoothlegatt I/mConnectionState: = 1
10-13 10:25:17.841 3996-4013/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:5F:B8:03:79:70
10-13 10:25:17.841 3996-4013/com.example.android.bluetoothlegatt I/onConnectionStateChange: status = 0
10-13 10:25:17.841 3996-4013/com.example.android.bluetoothlegatt I/onConnectionStateChange: newState = 2
10-13 10:25:17.843 3996-4013/com.example.android.bluetoothlegatt I/mConnectionState: = 2
10-13 10:25:17.917 3996-4013/com.example.android.bluetoothlegatt I/BluetoothLeService: Connected to GATT server.
10-13 10:25:17.917 3996-4013/com.example.android.bluetoothlegatt D/BluetoothGatt: discoverServices() - device: D0:5F:B8:03:79:70
10-13 10:25:17.921 3996-3996/com.example.android.bluetoothlegatt I/action mGatt :: action com.example.bluetooth.le.ACTION_GATT_CONNECTED
10-13 10:25:17.934 3996-4013/com.example.android.bluetoothlegatt I/BluetoothLeService: Attempting to start service discovery:true
10-13 10:25:20.480 3996-4013/com.example.android.bluetoothlegatt D/BluetoothGatt: onSearchComplete() = Device=D0:5F:B8:03:79:70 Status=0
10-13 10:25:20.480 3996-4013/com.example.android.bluetoothlegatt I/onServicesDiscovered: 0==0
10-13 10:25:20.484 3996-3996/com.example.android.bluetoothlegatt I/action mGatt :: action com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED
10-13 10:25:22.788 3996-3996/com.example.android.bluetoothlegatt I/BluetoothLeService: Going to connect with D0:5F:B8:03:79:70
10-13 10:25:22.788 3996-3996/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection.
10-13 10:25:22.799 3996-3996/com.example.android.bluetoothlegatt I/mConnectionState: = 1
10-13 10:25:22.799 3996-3996/com.example.android.bluetoothlegatt D/DeviceControlActivity: Connect request result=true
10-13 10:25:26.552 3996-3996/com.example.android.bluetoothlegatt I/GOOD: readCharacteristic()
10-13 10:25:26.554 3996-3996/com.example.android.bluetoothlegatt I/GOOD: setCharacteristicNotification()
10-13 10:25:26.555 3996-3996/com.example.android.bluetoothlegatt D/BluetoothGatt: setCharacteristicNotification() - uuid: 00002a35-0000-1000-8000-00805f9b34fb enable: true
10-13 10:25:29.106 3996-6342/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=19 clientIf=5 device=D0:5F:B8:03:79:70
10-13 10:25:29.106 3996-6342/com.example.android.bluetoothlegatt I/onConnectionStateChange: status = 19
10-13 10:25:29.108 3996-6342/com.example.android.bluetoothlegatt I/onConnectionStateChange: newState = 0
10-13 10:25:29.108 3996-6342/com.example.android.bluetoothlegatt I/mConnectionState: = 0
10-13 10:25:29.108 3996-6342/com.example.android.bluetoothlegatt I/BluetoothLeService: Disconnected from GATT server.
10-13 10:25:29.112 3996-3996/com.example.android.bluetoothlegatt I/action mGatt :: action com.example.bluetooth.le.ACTION_GATT_DISCONNECTED
@StevenMohr ,
In this link ,there is no description for status 19,What could be the reason for this?
https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#GATT_SUCCESS
@manikavi Yes, the error codes are mostly not included in the official docs. You have to search for them in the Android source code. Error code 19 (0x13) is supposed to be GATT_CONN_TERMINATE_PEER_USER. This means that the device you're connected to terminated the connection. So we have to look into the read measurements part.
@StevenMohr , According to the status code we have to establish the connection with remote device again?
When the peer device resets the connection, it usually means that there was some kind of timeout or the device couldn't process one of our request. Looking at the code it might be the case that the device is waiting for requests and then terminates the connection. You should get rid of the part of DeviceControlActivity where it shows the available services. After you discovered the services, choose the blood pressure service and asks for the measurements without waiting for some UI input.