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] Peripheral not found when retrieving Services

See original GitHub issue

Version

Tell us which versions you are using:

  • react-native-ble-manager v6.6.8
  • react-native v59.8
  • iOS/Android Android v.25

Expected behaviour

Should return peripheralInfo, as it always did, and still does on iOS.

Actual behaviour

Returns “Peripheral not found”

Steps to reproduce

  1. Connect to device
  2. Call retrieveServices

Stack trace and console log

I debugged already the Android code, but can’t find the reason, why it is not working. The peripherals Map<> is always empty. When a peripheral gets discovered, it is added to the peripherals Map. But when retrieveServices() gets invoked, the Map is always empty. Can someone reproduce the issue?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
NeilMcGuinesscommented, Jun 29, 2020

@BaloMueller I found the root cause for my case. I was calling startScan at every scan stop event if no devices was already connected. The problem was that the setState I was calling right after the connection was not fast enough to prevent the startScan to be called again. As I can see from the native code the “peripherals” map will be empty whenever a new scan starts

Thank you so much for this, this just really helped us out. This should be in the documentation of the scan or retrieveServices function, as many people are likely performing continuously looping scans which will cause problems here.

1reaction
iltumiocommented, Aug 22, 2019

@BaloMueller I found the root cause for my case.
I was calling startScan at every scan stop event if no devices was already connected. The problem was that the setState I was calling right after the connection was not fast enough to prevent the startScan to be called again. As I can see from the native code the “peripherals” map will be empty whenever a new scan starts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android : UUID of Custom Service of my BLE peripheral is not ...
One of My application is working as a Bluetooth peripheral, I add one Custom Service and 3 characteristics in it.
Read more >
Raspberry Pi 3B+ BLE peripheral : Android can't retrieve ...
I saw this topic : Bluetooth low energy gatt services not found on Android but I'm not using my own app for the...
Read more >
Bluetooth permissions - Android Developers
If your app looks for Bluetooth devices, such as BLE peripherals, declare the BLUETOOTH_SCAN permission. If your app makes the current device discoverable...
Read more >
react-native-ble-manager - npm
Note · Remember to use the start method before anything. · If you have problem with old devices try avoid to connect/read/write to...
Read more >
BLE peripheral giving null for per… | Apple Developer Forums
If we start scan giving null instead of service UUID, its hitting didDiscover multiple times giving the subsequent call giving peripheral name. but...
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