question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Connect and discover services - BleError: Device 00:16:A4:4C:B9:6A was disconnected

See original GitHub issue

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

Should be able to connect and discover services

Current Behavior

Receiving a disconnection error with status code 61 when trying to connect and discover services for a BLE device using an Android phone. The way I have designed my code is that when I receive an error in connection request from react-native-ble-plx library I again try to connect to the BLE device in a loop for 5 attempts, if all the 5 attempts result in error on 6th attempt I pass refershGatt param with value onconnected to the connect call. This does clear the cache and I am able to connect to the device but the service descriptions are empty. The device I try to connect uses Bluetooth dongle so the dongle might be paired to the Android phone in a previous attempt so when I manually unpair/forget the Bluetooth dongle from the paired devices list it does successfully discover the services. I am expecting to connect to the BLE device without manually unpairing the BLE dongle from the paired devices list in the android phone.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Connect to a device using Bluetooth dongle
bleManager.connectToDevice(deviceId)
  1. Then discover the services and characteristics
bleManager.discoverAllServicesAndCharacteristicsForDevice(deviceId)
  1. Disconnect from device
bleManager.cancelDeviceConnection(deviceId)
  1. Connect and try to discover services to a different device using the same Bluetooth dongle but pass refreshgatt parameter with the connect request.
bleManager.connectToDevice(deviceId, { refreshGatt: 'OnConnected' })

Context

  • Library version: 1.0.3
  • Platform: Android
  • Platform logs (logcat):
2020-08-28 17:00:46.338 4052-4719/com.arubacx I/RxBle#RefreshGattCustomOperation: Calling BluetoothGatt.refresh() status: Success
2020-08-28 17:00:46.730 4052-4411/com.arubacx D/RxBle#BluetoothGatt: onConnectionStateChange newState=0 status=61
2020-08-28 17:00:46.733 4052-4411/com.arubacx I/RxBle#ConnectionOperationQueue: Connection operations queue to be terminated (00:16:A4:4C:B9:6A)
2020-08-28 17:00:46.740 4052-4733/com.arubacx W/RxBle#ConnectionOperationQueue: Queue's awaitRelease() has been interrupted abruptly while it wasn't released by the release() method.
    java.lang.InterruptedException
        at java.lang.Object.wait(Native Method)
        at com.polidea.rxandroidble.internal.serialization.QueueSemaphore.awaitRelease(QueueSemaphore.java:15)
        at com.polidea.rxandroidble.internal.serialization.ConnectionOperationQueueImpl$1.run(ConnectionOperationQueueImpl.java:73)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
2020-08-28 17:00:46.763 4052-4733/com.arubacx D/RxBle#ConnectionOperationQueue: FINISHED (13710691) in 462 ms
2020-08-28 17:00:46.763 4052-4733/com.arubacx D/RxBle#Executors$RunnableAdapter: Terminated.
2020-08-28 17:00:46.769 4052-4734/com.arubacx D/RxBle#ClientOperationQueue: QUEUED   DisconnectOperation(239483829)
2020-08-28 17:00:46.770 4052-4713/com.arubacx D/RxBle#ClientOperationQueue: STARTED  DisconnectOperation(239483829)
2020-08-28 17:00:46.776 4052-4713/com.arubacx D/RxBle#ClientOperationQueue: FINISHED DisconnectOperation(239483829) in 6 ms
2020-08-28 17:00:53.558 4052-4734/com.arubacx D/RxBle#ClientOperationQueue: QUEUED   ConnectOperation(258339723)
2020-08-28 17:00:53.559 4052-4713/com.arubacx D/RxBle#ClientOperationQueue: STARTED  ConnectOperation(258339723)
2020-08-28 17:00:53.562 4052-4719/com.arubacx V/RxBle#BleConnectionCompat: Connecting without reflection
2020-08-28 17:00:56.828 4052-4411/com.arubacx D/RxBle#BluetoothGatt: onConnectionStateChange newState=2 status=0
2020-08-28 17:00:56.834 4052-4713/com.arubacx D/RxBle#ClientOperationQueue: FINISHED ConnectOperation(258339723) in 3273 ms
2020-08-28 17:00:56.895 4052-4431/com.arubacx D/RxBle#ConnectionOperationQueue: QUEUED   ServiceDiscoveryOperation(109802079)
2020-08-28 17:00:56.897 4052-4733/com.arubacx D/RxBle#ConnectionOperationQueue: STARTED  ServiceDiscoveryOperation(109802079)
2020-08-28 17:00:56.931 4052-4065/com.arubacx D/RxBle#BluetoothGatt: onServicesDiscovered status=0
2020-08-28 17:00:56.933 4052-4734/com.arubacx V/RxBle#ServiceDiscoveryOperation: Preparing services description
2020-08-28 17:00:56.937 4052-4734/com.arubacx V/RxBle#ServiceDiscoveryOperation: --------------- ====== Printing peripheral content ====== ---------------
    PERIPHERAL ADDRESS: 00:16:A4:4C:B9:6A
    PERIPHERAL NAME: JL668A---------
    -------------------------------------------------------------------------
    --------------- ====== Finished peripheral content ====== ---------------
2020-08-28 17:00:56.942 4052-4733/com.arubacx D/RxBle#ConnectionOperationQueue: FINISHED ServiceDiscoveryOperation(109802079) in 42 ms## 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17

github_iconTop GitHub Comments

2reactions
nolife08021commented, Apr 18, 2022

@Sumukha1791 @jnilesh hi did u guys found any solution for this? I’m facing the same issue.

1reaction
jnileshcommented, Jul 26, 2021

while trying to connect to the device, I too get the same error multipleTimes

Read more comments on GitHub >

github_iconTop Results From Across the Web

BleError: Device 00:16:A4:4C:B9:6A was disconnected · Issue ...
Receiving a disconnection error with status code 61 when trying to connect and discover services for a BLE device using an Android phone....
Read more >
React Native BLE error: device disconnected - Stack Overflow
Trying to write from phone to a device using the method below. We have three packets of data to transmit. The first packet...
Read more >
flutter_blue: working around a misbehaving BLE device and ...
Basically, the device is a bit finicky, and connecting to it goes something like: initiate connect; device connects; (begin service discovery, ...
Read more >
react-native-ble-plx 2.0.2 | Documentation
Connecting and discovering services and characteristics. Once device is scanned it is in disconnected state. We need to connect to it and discover...
Read more >
RxBLELibraries/react-native-ble - Gitter
await device.connect() yields BleError: Device F1:02:00:02:50:49 is not ... using react-native-ble-plx: 2.0.1 and react-native:0.63.1 and an Android device
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found