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.

Detection of BLE device is not stable - most of the time device not found

See original GitHub issue

Disclaimer

Before you will post a new issue to the RxAndroidBle library consider if you are filling a bug/feature request or a general question about:

  • Usage of RxJava
  • Usage of Bluetooth Low Energy
  • Usage of RxAndroidBle
  • Weird behaviour of the peripheral you are using
  • Other not directly related to a new feature request or a bug

If any of the above points seems to match your use case — consider using Google or creating a question on www.stackoverflow.com with a tag rxandroidble where it will be easier to access by other people with similar questions. Issues that are not bugs or feature requests will be closed.

Summary

First thanks for this amazing library! it helps us a lot! Now, I am developing an Android app for a Heart rate sensor The device is scanned and connection is established basically everything works fine but it’s not very stable and users starts to get annoying about this problem. Since user needs to send measurement of the device to the app successfully, the app must always find the device in the scan but unfortunately some times the device is not detected and not found in scan result and i can’t figure out what could be the reason that can make the device not visible to Android!

Library version

1.5.0

Minimum code snippet reproducing the issue

This is what i am using for Scanning:

private Observable<RxBleScanResult> prepareBleScanResultObservable() {
    return Observable.defer(() -> rxBleClient.scanBleDevices())
           .filter(rxBleScanResult -> {
                String name = rxBleScanResult.getBleDevice().getName();
                return !TextUtils.isEmpty(name));
            })
            .observeOn(AndroidSchedulers.mainThread())
            .doOnUnsubscribe(() -> scanBleDevicesSubscription = null)
            .take(7, TimeUnit.SECONDS);
}

BTW, i am not disconnecting from the device, and even if i disconnect i still get the same problem.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dariuszseweryncommented, Dec 25, 2018

BT 4.0 devices are not able to be connected and advertise at the same time. If you do not disconnect you may not expect that you will be able to scan the device. Different Android phones have different performance in regards how they scan. It may be that they will not scan the HRM in 7 seconds window. This has nothing to do with the library. Why do you think the thing you experience is a library issue?

0reactions
desnykicommented, Mar 4, 2019

Two reasons generally come to mind. Your advertisement interval is long so the scan and advertisements fail to be synchronized.

Scan with the ScanSettings.SCAN_MODE_LOW_LATENCY flag to see if this is true.

Second, you peripheral isn’t advertising because it still thinks you are connected. Implement some sort of heart beat to see if the connection is valid and reset the ble state if it’s not. You can quickly test for this by simply power cycling your peripheral.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detection of BLE device is not stable - most of the ... - GitHub
The device is scanned and connection is established basically everything works fine but it's not very stable and users starts to get annoying ......
Read more >
How to detect when a BLE device is not in range anymore?
An option is to do a fresh scan every 5 mins, but you can't tell when all nearby devices have been discovered, so...
Read more >
BLE scan may freeze randomly | Apple Developer Forums
When it's detected, i'm checking if the last detection was more than 10 minutes ago. If that's the case, i connect to the...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
Can't connect two devices? Try these 16 tips to solve your Bluetooth pairing problems.
Read more >
What is a Beacon? The Complete Guide to Bluetooth Beacons
Bluetooth beacons are small, wireless, high-tech devices that transmits a continuous radio signal. Visit the website to learn more about how it works!...
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