How can I list connected devices?
See original GitHub issueQuestion
How can I list the connected devices?
Steps:
- I start the device scan
- I find the device by name and connect to it to check the services and characteristics
- I make some changes on the app and run it again
- This time the scan doesn’t include my device, as it says on the introduction: “However when device is connected it won’t broadcast and needs to be disconnected from central to be scanned again.”
- Ok, so how can I find the connected device so I can disconnect it, or use it?
I tried
let connectedDevices = await manager.connectedDevices(null) or ()
- gives an error - Attempt to invoke interface method ‘int.com.facebook.react.bridge.ReadableArray.size()’ on a null object reference
let connectedDevices = await manager.connectedDevices([])
- gives an empty array
The connectedDevices
method needs a serviceUUIDs parameter but how can I get the connected devices regardless of their serviceUUIDs?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How to See Who's Connected to Your Wi-Fi Network
The best way to check who is connected to your network is with your router's app or web interface. Try typing “10.0.0.1” or...
Read more >How to Find Devices On Your Network - Comparitech
Enter the net view command to view devices connected to your network You will then see a list of devices connected to your...
Read more >3 Ways to See Who Is Connected to Your Wireless Network
1. Open a browser. You can use a web browser to log in to the web interface for your wireless router. You can...
Read more >How to see all the devices connected to your network
Log into your router to see the most up-to-date information about which devices are connected. Most models will support this as it's a ......
Read more >How to See Who's On Your Wi-Fi - PCMag
You can open your router's management page by typing its IP address in your browser's address bar. Once there, look for an option...
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
This is still an issue: I specifically run into it during development all the time with the following set up on Android:
connectedDevices()
. I get 0 devices listed even though my BLE device is happily still connected to my Android phone.I can verify this is the problem because I use this (unacceptable for production) quick workaround: if you disable and enable Bluetooth on your Android phone, that will disconnect from your BLE hardware, and now your app state will match the hardware.
While dev mode is the easiest to reproduce this in, it’s relatively easy to see how this would happen in production: literally any crash in your app or killing of your app by a 3rd party service or Android OS will cause this bad state to exist
Until this issue is resolved I have resorted to a dual- library approach: using this library and ALSO react-native-ble-manager together. This is the only solution as of December 2021 that doesn’t require a user to disable and enable Bluetooth on Android.
My shim:
And an excerpt of how I use it (in my React Native provider load function):
@nbastoWM Did u ever solve this? I’m getting the same error “Attempt to invoke interface method ‘int com.facebook.react.bridge.ReadableArray.size()’ on a null object reference”. However only on android, on iOS it works fine.