[Android] Empty array of services is returned
See original GitHub issueExpected Behavior
After calling bleManager.discoverAllServicesAndCharacteristicsForDevice()
, calling .services()
on the returned bleDevice should return a non-empty list of services.
Current Behavior
Calling .services()
returns an empty array. This might be a pairing issue, since if I pair with the device via Android’s bluetooth menu, it seems to connect without issue and properly returns a non-empty list of services. Restarting the phone also seems to “fix” the issue for me.
I assume this issue is related to https://github.com/Polidea/react-native-ble-plx/issues/488 and the “known bug”. Calling connectToDevice()
seems to work fine, and the resulting device has the correct name/id.
Steps to Reproduce
- Put device in pairing mode
- Connect to device using
bleManager.connectToDevice()
. - Call
discoverAllServicesAndCharacteristicsForDevice()
with the device or using bleManager. - Attempt to get services using
.services()
on the device. - An empty services array is returned.
Context
- Library version: 2.0.1
- Platform and version: Android 10 (SDK 29)
- Phone: Samsung Galaxy S20
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:20 (1 by maintainers)
Top Results From Across the Web
[Android] Empty array of services is returned #766 - GitHub
Calling .services() returns an empty array. This might be a pairing issue, since if I pair with the device via Android's bluetooth menu, ......
Read more >How to handle empty array return in API response in retrofit 2 ...
can anyone help me in this ? This is a 3rd party API which I am not able to modify response from server...
Read more >Return an empty array or collection instead of a null
Returning a null value rather than a zero-length array or collection may lead to denial-of-service vulnerabilities when the client code fails to handle...
Read more >ArrayAdapter | Android Developers
You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data...
Read more >Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually still don’t know. I’m running a Bluez server. And whenever a connection request comes in it gets disconnected by the server. So a server side issue, unrelated to this library.
I think I have a related issue.
I am trying to find my device by serviceUUID and that does not work.
The above code never finds anything.
If I remove the uuids argument to make it find everything, then manually filter on the MAC address to get the reported device object. Getting it’s
.serviceUUIDs
also returns null.My
.name
field is also empty on Discovery.