Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BleGattCharacteristicException while readCharacteristic #829

Open
mkiisoft opened this issue May 14, 2023 · 12 comments
Open

BleGattCharacteristicException while readCharacteristic #829

mkiisoft opened this issue May 14, 2023 · 12 comments
Labels
bug-android Bug that is caused by Android OS

Comments

@mkiisoft
Copy link

mkiisoft commented May 14, 2023

Describe the bug
I have a BLE device with several (11) characteristics and almost of those working. One in particular is not, but I was able to read it using HTML5 Bluetooth library on Android itself (same phone) and on iOS connecting to the same device (the result on iOS has several trailing zeros).

The following exception is being thrown:

com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException: GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)

Every single other Characteristic works, no problem, still connected (so, it's not a connection issue) right before and right after that one, except for every time I'm reading that Characteristic.

To Reproduce
Steps to reproduce the behavior:

  1. Connect to device
  2. Read Characteristic

Expected behavior
iOS and HTML5/Js native implementations, all of them return a List of int as expected being the following one:

[118, 49, 46, 56, 46, 50, 32, 104, 119, 49, 32, 110, 54, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Smartphone / tablet

  • Device: OnePlus 6T
  • OS: Android 11
  • Package version: 1.17.2

Logs from the application when bug occurs (this will greatly help in quick understanding the problem)
To turn on logs use:

RxBleClient.updateLogOptions(new LogOptions.Builder()
        .setLogLevel(LogConstants.DEBUG)
        .setMacAddressLogSetting(LogConstants.MAC_ADDRESS_FULL)
        .setUuidsLogSetting(LogConstants.UUIDS_FULL)
        .setShouldLogAttributeValues(true)
        .build()
);
com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException: GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)

Additional context
I discarded being my device as I'm getting the data if I use a HTML5/Js library and the data gets as expected.

@mkiisoft mkiisoft added the bug Bug that is caused by the library label May 14, 2023
@dariuszseweryn
Copy link
Owner

What is your device?
Does your device pair/bond?
Does it changes services?
Could you share a full log from the beginning of connection up to the error?

@mkiisoft
Copy link
Author

mkiisoft commented May 14, 2023

@dariuszseweryn Hello, thanks for asking!

I have all in my bug:

Smartphone / tablet

Device: OnePlus 6T
OS: Android 11
Package version: 1.17.2

I sync to a N64 Bluetooth dongle successfully, no error, I can write and read every other characteristic except for that one with this library. It does changes services.

I/app (22867): EVENT: ConnectionStateUpdate(deviceId: 90:38:0C:F5:56:0A, connectionState: DeviceConnectionState.connecting, failure: null)
D/BluetoothGatt(22867): onClientConnectionState() - status=0 clientIf=10 device=90:38:0C:F5:56:0A
I/app (22867): EVENT: ConnectionStateUpdate(deviceId: 90:38:0C:F5:56:0A, connectionState: DeviceConnectionState.connected, failure: null)
I/app (22867): CONNECTED
D/BluetoothGatt(22867): requestConnectionPriority() - params: 1
D/BluetoothGatt(22867): onConnectionUpdated() - Device=90:38:0C:F5:56:0A interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(22867): onConnectionUpdated() - Device=90:38:0C:F5:56:0A interval=12 latency=0 timeout=500 status=0
D/BluetoothGatt(22867): discoverServices() - device: 90:38:0C:F5:56:0A
D/BluetoothGatt(22867): onSearchComplete() = Device=90:38:0C:F5:56:0A Status=0
I/System.out(22867): CHARACTERISTIC: 56830f56-5180-fab0-314b-2fa176799a0c
I/System.out(22867): CHARACTERISTIC_DEVICE_ID: 90:38:0C:F5:56:0A
I/System.out(22867): CHARACTERISTIC_RESULT: CharOperationSuccessful(deviceId=90:38:0C:F5:56:0A, value=[10, 86, -11, 12, 56, -112])
I/app (22867): UPDATE: CharacteristicValue(characteristic: Characteristic(characteristicId: 56830f56-5180-fab0-314b-2fa176799a0c, serviceId: 56830f56-5180-fab0-314b-2fa176799a00, deviceId: 90:38:0C:F5:56:0A), value: ([10, 86, 245, 12, 56, 144]))
I/System.out(22867): CHARACTERISTIC: 56830f56-5180-fab0-314b-2fa176799a09
I/System.out(22867): CHARACTERISTIC_DEVICE_ID: 90:38:0C:F5:56:0A
I/System.out(22867): ERROR: com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException: GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)
I/app (22867): EVENT: CharacteristicValue(characteristic: Characteristic(characteristicId: 56830f56-5180-fab0-314b-2fa176799a09, serviceId: 56830f56-5180-fab0-314b-2fa176799a00, deviceId: 90:38:0C:F5:56:0A), value: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)")))
I/app (22867): UPDATE: CharacteristicValue(characteristic: Characteristic(characteristicId: 56830f56-5180-fab0-314b-2fa176799a09, serviceId: 56830f56-5180-fab0-314b-2fa176799a00, deviceId: 90:38:0C:F5:56:0A), value: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)")))

@dariuszseweryn
Copy link
Owner

Is this the peripheral you connect your phone to?

I asked for logs, please share them but with below settings in your app — it will give more information on the internals of the library. Also timings may be important so please leave timestamps.

RxBleClient.updateLogOptions(new LogOptions.Builder()
        .setLogLevel(LogConstants.VERBOSE)
        .setMacAddressLogSetting(LogConstants.MAC_ADDRESS_FULL)
        .setUuidsLogSetting(LogConstants.UUIDS_FULL)
        .setShouldLogAttributeValues(true)
        .build()
);

@mkiisoft
Copy link
Author

mkiisoft commented May 14, 2023

@dariuszseweryn Correct! I'm able to do all the operations on web with the same Android device to that dongle and with iOS. So far, only that characteristic is the one getting me an exception with this library.

Full log of that event:

2023-05-14 18:22:14.402 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: FINISHED ConnectionPriorityChangeOperation(132136986) in 2012 ms
2023-05-14 18:22:14.413 972-21802/? D/vendor.qti.bluetooth@1.0-wake_lock: Release wakelock is released 
2023-05-14 18:22:14.442 10939-10939/com.ble.app D/RxBle#ConnectionOperationQueue: QUEUED   ServiceDiscoveryOperation(90065876)
2023-05-14 18:22:14.443 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: STARTED  ServiceDiscoveryOperation(90065876)
2023-05-14 18:22:14.444 10939-31169/com.ble.app I/RxBle#ConnectionOperationQueue: RUNNING  ServiceDiscoveryOperation{MAC='90:38:0C:F5:56:0A'}
2023-05-14 18:22:14.446 10939-31154/com.ble.app D/BluetoothGatt: discoverServices() - device: 90:38:0C:F5:56:0A
2023-05-14 18:22:14.446 21694-21711/? D/BtGatt.GattService: discoverServices() - address=90:38:0C:F5:56:0A, connId=268
2023-05-14 18:22:14.447 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(361)] bta_gattc_hdl_event: Event:BTA_GATTC_API_SEARCH_EVT
2023-05-14 18:22:14.447 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(305)] bta_gattc_sm_execute: State 0x02 [GATTC_CONN_ST], Event 0x1f09[BTA_GATTC_API_SEARCH_EVT]
2023-05-14 18:22:14.447 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_act.cc(1030)] bta_gattc_search: conn_id=0x010c
2023-05-14 18:22:14.447 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(341)] bta_gattc_sm_execute: GATTC State Change: 0x02 -> 0x02 after Event 0x1f09
2023-05-14 18:22:14.447 21694-21738/? D/BtGatt.GattService: onSearchCompleted() - connId=268, status=0
2023-05-14 18:22:14.448 21694-21738/? D/bt_bta_gattc: bta_gattc_get_gatt_db
2023-05-14 18:22:14.448 21694-21738/? V/bt_stack: [VERBOSE1:bta_gattc_cache.cc(618)] bta_gattc_get_gatt_db_impl: start_handle 0x0000, end_handle 0xffff
2023-05-14 18:22:14.448 21694-21738/? D/BtGatt.GattService: onGetGattDb() - address=90:38:0C:F5:56:0A
2023-05-14 18:22:14.448 21694-21738/? D/BtGatt.GattService: got service with UUID=00001801-0000-1000-8000-00805f9b34fb id: 1
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=00002a05-0000-1000-8000-00805f9b34fb id: 3
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got service with UUID=00001800-0000-1000-8000-00805f9b34fb id: 20
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=00002a00-0000-1000-8000-00805f9b34fb id: 22
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=00002a01-0000-1000-8000-00805f9b34fb id: 24
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got service with UUID=56830f56-5180-fab0-314b-2fa176799a00 id: 64
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a01 id: 66
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a02 id: 68
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a03 id: 70
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a04 id: 72
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a05 id: 74
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a06 id: 76
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a07 id: 78
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a08 id: 80
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a09 id: 82
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a0a id: 84
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a0b id: 86
2023-05-14 18:22:14.449 21694-21738/? D/BtGatt.GattService: got characteristic with UUID=56830f56-5180-fab0-314b-2fa176799a0c id: 88
2023-05-14 18:22:14.452 10939-31013/com.ble.app D/BluetoothGatt: onSearchComplete() = Device=90:38:0C:F5:56:0A Status=0
2023-05-14 18:22:14.453 10939-31013/com.ble.app I/RxBle#GattCallback: MAC='90:38:0C:F5:56:0A'     onServicesDiscovered(), status=0
2023-05-14 18:22:14.455 10939-31170/com.ble.app V/RxBle#ServiceDiscoveryOperation: Preparing services description
2023-05-14 18:22:14.463 10939-31170/com.ble.app V/RxBle#ServiceDiscoveryOperation: --------------- ====== Printing peripheral content ====== ---------------
    MAC='90:38:0C:F5:56:0A'
    PERIPHERAL NAME: BlueRetro_N64_560A
    -------------------------------------------------------------------------
    
    Primary Service - Generic Attribute (00001801-0000-1000-8000-00805f9b34fb)
    Instance ID: 1
    -> Characteristics:
    	* Service Changed (00002a05-0000-1000-8000-00805f9b34fb)
    	  Properties: [ INDICATE ]
    
    Primary Service - Generic Access (00001800-0000-1000-8000-00805f9b34fb)
    Instance ID: 20
    -> Characteristics:
    	* Device Name (00002a00-0000-1000-8000-00805f9b34fb)
    	  Properties: [ READ ]
    	* Appearance (00002a01-0000-1000-8000-00805f9b34fb)
    	  Properties: [ READ ]
    
    Primary Service - Unknown service (56830f56-5180-fab0-314b-2fa176799a00)
    Instance ID: 64
    -> Characteristics:
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a01)
    	  Properties: [ READ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a02)
    	  Properties: [ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a03)
    	  Properties: [ READ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a04)
    	  Properties: [ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a05)
    	  Properties: [ READ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a06)
    	  Properties: [ READ ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a07)
    	  Properties: [ READ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a08)
    	  Properties: [ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a09) // THIS IS THE ONE
    	  Properties: [ READ ] // THIS IS THE ONE
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a0a)
    	  Properties: [ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a0b)
    	  Properties: [ READ WRITE ]
    	* Unknown characteristic (56830f56-5180-fab0-314b-2fa176799a0c)
    	  Properties: [ READ ]
    --------------- ====== Finished peripheral content ====== ---------------
2023-05-14 18:22:14.464 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: FINISHED ServiceDiscoveryOperation(90065876) in 20 ms
2023-05-14 18:22:14.498 1109-29513/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.518 10939-10939/com.ble.app I/System.out: CHARACTERISTIC: 56830f56-5180-fab0-314b-2fa176799a0c
2023-05-14 18:22:14.518 10939-10939/com.ble.app I/System.out: CHARACTERISTIC_DEVICE_ID: 90:38:0C:F5:56:0A
2023-05-14 18:22:14.521 10939-10939/com.ble.app D/RxBle#ConnectionOperationQueue: QUEUED   CharacteristicReadOperation(77460277)
2023-05-14 18:22:14.522 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: STARTED  CharacteristicReadOperation(77460277)
2023-05-14 18:22:14.522 10939-31169/com.ble.app I/RxBle#ConnectionOperationQueue: RUNNING  CharacteristicReadOperation{MAC='90:38:0C:F5:56:0A', characteristic=[uuid='56830f56-5180-fab0-314b-2fa176799a0c']}
2023-05-14 18:22:14.527 1109-1376/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.527 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(361)] bta_gattc_hdl_event: Event:BTA_GATTC_API_READ_EVT
2023-05-14 18:22:14.527 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(305)] bta_gattc_sm_execute: State 0x02 [GATTC_CONN_ST], Event 0x1f04[BTA_GATTC_API_READ_EVT]
2023-05-14 18:22:14.527 21694-21923/? V/bt_stack: [VERBOSE1:gatt_api.cc(692)] GATTC_Read: conn_id=0x010c, type=0x02
2023-05-14 18:22:14.528 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(341)] bta_gattc_sm_execute: GATTC State Change: 0x02 -> 0x02 after Event 0x1f04
2023-05-14 18:22:14.528 972-972/? D/vendor.qti.bluetooth@1.0-ibs_handler: SerialClockVote: vote for UART CLK ON
2023-05-14 18:22:14.529 972-972/? D/vendor.qti.bluetooth@1.0-wake_lock: Acquire wakelock is acquired 
2023-05-14 18:22:14.529 972-972/? I/vendor.qti.bluetooth@1.0-ibs_handler: DeviceWakeUp: Writing IBS_WAKE_IND
2023-05-14 18:22:14.529 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_WAKE_ACK: 0xFC
2023-05-14 18:22:14.529 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Signal wack_cond_
2023-05-14 18:22:14.529 972-972/? D/vendor.qti.bluetooth@1.0-ibs_handler: DeviceWakeUp: Unblocked from waiting for FC
2023-05-14 18:22:14.540 606-606/? E/SELinux: avc:  denied  { find } for pid=5249 uid=10385 name=tethering scontext=u:r:vendor_systemhelper_app:s0:c512,c768 tcontext=u:object_r:tethering_service:s0 tclass=service_manager permissive=0
2023-05-14 18:22:14.544 1109-29513/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.545 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_WAKE_IND: 0xFD
2023-05-14 18:22:14.545 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Writing IBS_WAKE_ACK
2023-05-14 18:22:14.548 1109-1161/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.561 21694-21923/? V/bt_stack: [VERBOSE1:gatt_main.cc(1086)] gatt_get_ch_state: ch_state=4
2023-05-14 18:22:14.561 21694-21923/? I/bt_stack: [INFO:gatt_main.cc(919)] gatt_data_process op_code = 11, msg_len = 6
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:gatt_cl.cc(1112)] gatt_client_handle_server_rsp op_code: 11, len = 6rsp_code: 11
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:gatt_utils.cc(1191)] gatt_end_operation status=0 op=2 subtype=2
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_act.cc(1483)] bta_gattc_cmpl_cback: conn_id:268 op:2 status:0
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(361)] bta_gattc_hdl_event: Event:BTA_GATTC_OP_CMPL_EVT
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(305)] bta_gattc_sm_execute: State 0x02 [GATTC_CONN_ST], Event 0x1f0f[BTA_GATTC_OP_CMPL_EVT]
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_act.cc(962)] bta_gattc_op_cmpl: op:2
2023-05-14 18:22:14.562 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(341)] bta_gattc_sm_execute: GATTC State Change: 0x02 -> 0x02 after Event 0x1f0f
2023-05-14 18:22:14.566 10939-31013/com.ble.app I/RxBle#GattCallback: MAC='90:38:0C:F5:56:0A'     onCharacteristicRead(), status=0, value=[uuid='56830f56-5180-fab0-314b-2fa176799a0c', hexValue=[0A, 56, F5, 0C, 38, 90]]
2023-05-14 18:22:14.573 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: FINISHED CharacteristicReadOperation(77460277) in 50 ms
2023-05-14 18:22:14.573 10939-10939/com.ble.app I/System.out: RESULT: CharOperationSuccessful(deviceId=90:38:0C:F5:56:0A, value=[10, 86, -11, 12, 56, -112])
2023-05-14 18:22:14.581 1109-29513/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.585 1109-1161/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.594 10939-31110/com.ble.app I/flutter: UPDATE: CharacteristicValue(characteristic: QualifiedCharacteristic(characteristicId: 56830f56-5180-fab0-314b-2fa176799a0c, serviceId: 56830f56-5180-fab0-314b-2fa176799a00, deviceId: 90:38:0C:F5:56:0A), value: Result<List<int>, GenericFailure<CharacteristicValueUpdateError>?>.success([10, 86, 245, 12, 56, 144]))
2023-05-14 18:22:14.600 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_SLEEP_IND: 0xFE
2023-05-14 18:22:14.602 1109-29513/? E/surfaceflinger: [frame_perf] perfboost open boost file failed

// THE ERROR OPERATION
2023-05-14 18:22:14.609 10939-10939/com.ble.app I/System.out: CHARACTERISTIC: 56830f56-5180-fab0-314b-2fa176799a09
2023-05-14 18:22:14.609 10939-10939/com.ble.app I/System.out: CHARACTERISTIC_DEVICE_ID: 90:38:0C:F5:56:0A
2023-05-14 18:22:14.611 10939-10939/com.ble.app D/RxBle#ConnectionOperationQueue: QUEUED   CharacteristicReadOperation(252277398)
2023-05-14 18:22:14.615 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: STARTED  CharacteristicReadOperation(252277398)
2023-05-14 18:22:14.616 10939-31169/com.ble.app I/RxBle#ConnectionOperationQueue: RUNNING  CharacteristicReadOperation{MAC='90:38:0C:F5:56:0A', characteristic=[uuid='56830f56-5180-fab0-314b-2fa176799a09']}
2023-05-14 18:22:14.619 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(361)] bta_gattc_hdl_event: Event:BTA_GATTC_API_READ_EVT
2023-05-14 18:22:14.619 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(305)] bta_gattc_sm_execute: State 0x02 [GATTC_CONN_ST], Event 0x1f04[BTA_GATTC_API_READ_EVT]
2023-05-14 18:22:14.620 21694-21923/? V/bt_stack: [VERBOSE1:gatt_api.cc(692)] GATTC_Read: conn_id=0x010c, type=0x02
2023-05-14 18:22:14.620 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(341)] bta_gattc_sm_execute: GATTC State Change: 0x02 -> 0x02 after Event 0x1f04
2023-05-14 18:22:14.631 1109-1161/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.635 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Received IBS_WAKE_IND: 0xFD
2023-05-14 18:22:14.635 972-21921/? I/vendor.qti.bluetooth@1.0-ibs_handler: ProcessIbsCmd: Writing IBS_WAKE_ACK
2023-05-14 18:22:14.647 1109-29513/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:gatt_main.cc(1086)] gatt_get_ch_state: ch_state=4
2023-05-14 18:22:14.651 21694-21923/? I/bt_stack: [INFO:gatt_main.cc(919)] gatt_data_process op_code = 11, msg_len = 23
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:gatt_cl.cc(1112)] gatt_client_handle_server_rsp op_code: 11, len = 23rsp_code: 11
2023-05-14 18:22:14.651 21694-21923/? E/bt_stack: [ERROR:gatt_cl.cc(1119)] gatt_client_handle_server_rsp: invalid response pkt size: 24, PDU size: 23
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:gatt_utils.cc(1191)] gatt_end_operation status=133 op=2 subtype=2
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_act.cc(1483)] bta_gattc_cmpl_cback: conn_id:268 op:2 status:133
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(361)] bta_gattc_hdl_event: Event:BTA_GATTC_OP_CMPL_EVT
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(305)] bta_gattc_sm_execute: State 0x02 [GATTC_CONN_ST], Event 0x1f0f[BTA_GATTC_OP_CMPL_EVT]
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_act.cc(962)] bta_gattc_op_cmpl: op:2
2023-05-14 18:22:14.651 21694-21923/? V/bt_stack: [VERBOSE1:bta_gattc_main.cc(341)] bta_gattc_sm_execute: GATTC State Change: 0x02 -> 0x02 after Event 0x1f0f
2023-05-14 18:22:14.653 10939-31013/com.ble.app I/RxBle#GattCallback: MAC='90:38:0C:F5:56:0A'     onCharacteristicRead(), status=133, value=[uuid='56830f56-5180-fab0-314b-2fa176799a09', hexValue=null]
2023-05-14 18:22:14.655 10939-31169/com.ble.app D/RxBle#ConnectionOperationQueue: FINISHED CharacteristicReadOperation(252277398) in 43 ms
2023-05-14 18:22:14.656 10939-10939/com.ble.app I/System.out: ERROR!: com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException: GATT exception from MAC='90:38:0C:F5:56:0A', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)
2023-05-14 18:22:14.657 1109-1161/? E/surfaceflinger: [frame_perf] perfboost open boost file failed
2023-05-14 18:22:14.678 10939-31110/com.ble.app I/flutter: EVENT: CharacteristicValue(characteristic: QualifiedCharacteristic(characteristicId: 56830f56-5180-fab0-314b-2fa176799a09, serviceId: 56830f56-5180-fab0-314b-2fa176799a00, deviceId: 90:38:0C:F5:56:0A), value: Result<List<int>, GenericFailure<CharacteristicValueUpdateError>?>.failure(GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "GATT exception from MAC='90:38:0C:F5:56:0A', status 133 (GATT_ERROR), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0x85 here https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)")))

I'm making the Open Source version of Android of the site: https://blueretro.io and while I access that site with the same Android, that characteristic is able to show data on my device.

@dariuszseweryn
Copy link
Owner

If the peripheral has been paired/bonded it may be that something got off with the Android cache. Could you try reboot your phone and retry?
If that does not work, you may try to add an artificial delay between connecting and before the first operation on RxBleConnection happens as Android needs some time to re-establish the bond.

@mkiisoft
Copy link
Author

mkiisoft commented May 16, 2023

@dariuszseweryn I tested both scenarios and same issue with the same characteristic and on Web with the same device I can always get a result. I tried rebooting both devices several times, I also added from 2 to 10 seconds delays with several retries (10 retries) and same error. I did the same right after and right before that characteristic with any other characteristic and I have no issues, I can read and write the other ones, no problem. I'm never losing the connection as I can keep using and doing stuffs with the peripheral, even ms after that attempt of read call.

@dariuszseweryn
Copy link
Owner

Could you try nRF Connect app and see if you could perform the same scenario there?

@mkiisoft
Copy link
Author

mkiisoft commented May 17, 2023

@dariuszseweryn I get the same error "Error 133 (0x85) GATT ERROR". The crazy thing is that I just tested with the Web interface using the same Android and it works. I also tested on iOS and it works:

This is Web Android (same device):
Screenshot

This is the error with nRF Connect (same device, other values are readable, as you can see):
Screenshot_20230517-163946

This is iOS:
IMG_1E0E039D8F2F-1

This is the value I'm getting on iOS/Web: [118, 49, 46, 56, 46, 51, 32, 104, 119, 49, 32, 110, 54, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0]

@dariuszseweryn
Copy link
Owner

dariuszseweryn commented May 17, 2023

It looks like an Android BLE stack bug. Not sure what the web API uses. We could try to dig deeper by getting your phone's BT HCI logs with both app usage and web usage and analysing them — maybe some workaround will pop-up

Edit: you could also try connecting with a different Android device if you have one

@dariuszseweryn dariuszseweryn added bug-android Bug that is caused by Android OS and removed bug Bug that is caused by the library labels May 17, 2023
@mkiisoft
Copy link
Author

@dariuszseweryn I just tested on a Xiaomi MI9T Android 11 and same issue. Will try to dig deeper and I'll talk with the creator of the dongle to see if a firmware update can make it readable for Android.

@qq1023308356
Copy link

qq1023308356 commented Jun 29, 2023

Excuse me, is there any progress on this issue?

@AliAzaz
Copy link

AliAzaz commented Aug 7, 2023

I am also rarely getting the same sort of error:

Caused by com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='XX:XX:XX:XX:XX:XX' with status 8 (GATT_INSUF_AUTHORIZATION or GATT_CONN_TIMEOUT)
       at com.polidea.rxandroidble2.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:80)
       at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:299)
       at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:864)
       at android.bluetooth.BluetoothGatt.-$$Nest$mrunOrQueueCallback()
       at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:294)
       at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:128)
       at android.os.Binder.execTransactInternal(Binder.java:1285)
       at android.os.Binder.execTransact(Binder.java:1244)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-android Bug that is caused by Android OS
Projects
None yet
Development

No branches or pull requests

4 participants