manikavi / BluetoothLeGatt

BluetoothLeGatt WS
Apache License 2.0
0 stars 0 forks source link

onServicesDiscovered received: 129 #1

Open manikavi opened 7 years ago

manikavi commented 7 years ago

10-12 10:23:52.801 7004-7004/com.example.android.bluetoothlegatt I/Device Version:   22
10-12 10:23:52.936 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: startLeScan(): null
10-12 10:23:53.099 7004-7022/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
10-12 10:23:53.215 7004-7064/com.example.android.bluetoothlegatt D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
10-12 10:23:53.245 7004-7004/com.example.android.bluetoothlegatt D/Atlas: Validating map...
10-12 10:23:53.383 7004-7064/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-12 10:23:53.386 7004-7064/com.example.android.bluetoothlegatt I/OpenGLRenderer: Initialized EGL, version 1.4
10-12 10:23:53.417 7004-7064/com.example.android.bluetoothlegatt D/OpenGLRenderer: Enabling debug mode 0
10-12 10:24:52.953 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
10-12 10:25:24.464 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: startLeScan(): null
10-12 10:25:24.502 7004-7021/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
10-12 10:25:25.796 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
10-12 10:25:25.878 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
10-12 10:25:25.881 7004-7004/com.example.android.bluetoothlegatt D/BluetoothAdapter: scan not started yet
10-12 10:25:26.052 7004-7004/com.example.android.bluetoothlegatt D/BluetoothGatt: connect() - device: D0:5F:B8:03:79:70, auto: false
10-12 10:25:26.052 7004-7004/com.example.android.bluetoothlegatt D/BluetoothGatt: registerApp()
10-12 10:25:26.052 7004-7004/com.example.android.bluetoothlegatt D/BluetoothGatt: registerApp() - UUID=36fa7817-cf1f-4980-8a70-fb6becf230a7
10-12 10:25:26.054 7004-7004/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to create a new connection.
10-12 10:25:26.054 7004-7004/com.example.android.bluetoothlegatt I/mConnectionState:  = 1
10-12 10:25:26.055 7004-7022/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
10-12 10:25:26.932 7004-7022/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:5F:B8:03:79:70
10-12 10:25:26.932 7004-7022/com.example.android.bluetoothlegatt I/onConnectionStateChange:   status = 0
10-12 10:25:26.932 7004-7022/com.example.android.bluetoothlegatt I/onConnectionStateChange:   newState = 2
10-12 10:25:26.946 7004-7022/com.example.android.bluetoothlegatt I/mConnectionState:  = 2
10-12 10:25:26.992 7004-7022/com.example.android.bluetoothlegatt I/BluetoothLeService: Connected to GATT server.
10-12 10:25:26.993 7004-7022/com.example.android.bluetoothlegatt D/BluetoothGatt: discoverServices() - device: D0:5F:B8:03:79:70
10-12 10:25:27.001 7004-7004/com.example.android.bluetoothlegatt I/action mGatt ::  action com.example.bluetooth.le.ACTION_GATT_CONNECTED
10-12 10:25:27.011 7004-7022/com.example.android.bluetoothlegatt I/BluetoothLeService: Attempting to start service discovery:true
10-12 10:25:32.836 7004-7004/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection.
10-12 10:25:32.840 7004-7004/com.example.android.bluetoothlegatt I/mConnectionState:  = 1
10-12 10:25:32.843 7004-7004/com.example.android.bluetoothlegatt D/DeviceControlActivity: Connect request result=true
10-12 10:25:32.843 7004-10107/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:5F:B8:03:79:70
10-12 10:25:32.843 7004-10107/com.example.android.bluetoothlegatt I/onConnectionStateChange:   status = 0
10-12 10:25:32.843 7004-10107/com.example.android.bluetoothlegatt I/onConnectionStateChange:   newState = 2
10-12 10:25:32.843 7004-10107/com.example.android.bluetoothlegatt I/mConnectionState:  = 2
10-12 10:25:32.848 7004-10107/com.example.android.bluetoothlegatt I/BluetoothLeService: Connected to GATT server.
10-12 10:25:32.848 7004-10107/com.example.android.bluetoothlegatt D/BluetoothGatt: discoverServices() - device: D0:5F:B8:03:79:70
10-12 10:25:32.860 7004-10107/com.example.android.bluetoothlegatt I/BluetoothLeService: Attempting to start service discovery:true
10-12 10:25:32.863 7004-7004/com.example.android.bluetoothlegatt I/action mGatt ::  action com.example.bluetooth.le.ACTION_GATT_CONNECTED
10-12 10:25:47.277 7004-7022/com.example.android.bluetoothlegatt D/BluetoothGatt: onSearchComplete() = Device=D0:5F:B8:03:79:70 Status=129
10-12 10:25:47.277 7004-7022/com.example.android.bluetoothlegatt I/onServicesDiscovered:   129==0
10-12 10:25:47.278 7004-7022/com.example.android.bluetoothlegatt W/BluetoothLeService: onServicesDiscovered received: 129
10-12 10:25:47.280 7004-10107/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=5 device=D0:5F:B8:03:79:70
10-12 10:25:47.281 7004-10107/com.example.android.bluetoothlegatt I/onConnectionStateChange:   status = 8
10-12 10:25:47.281 7004-10107/com.example.android.bluetoothlegatt I/onConnectionStateChange:   newState = 0
10-12 10:25:47.281 7004-10107/com.example.android.bluetoothlegatt I/mConnectionState:  = 0
10-12 10:25:47.281 7004-10107/com.example.android.bluetoothlegatt I/BluetoothLeService: Disconnected from GATT server.
10-12 10:25:47.292 7004-7004/com.example.android.bluetoothlegatt I/action mGatt ::  action com.example.bluetooth.le.ACTION_GATT_DISCONNECTED
StevenMohr commented 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?

manikavi commented 7 years ago
StevenMohr commented 7 years ago

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 ...

manikavi commented 7 years ago

@StevenMohr

Okay,

manikavi commented 7 years ago

@StevenMohr , did you check that?

StevenMohr commented 7 years ago

@manikavi No, I can't. I don't have a blood pressure meter available. Did the fix change anything?

manikavi commented 7 years ago

No sir,I'm still trying to get readings from BP device

StevenMohr commented 7 years ago

@manikavi Could you push your changes to GitHub?

manikavi commented 7 years ago

@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
manikavi commented 7 years ago

@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

StevenMohr commented 7 years ago

@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.

manikavi commented 7 years ago

@StevenMohr , According to the status code we have to establish the connection with remote device again?

StevenMohr commented 7 years ago

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.