简体   繁体   中英

How to check if any bluetooth device is connected in react native

I've been attempting to detect whether a bluetooth device is connected to an android phone once a button is clicked. If detected, I would like to interact with this device from within my app. The device I'm talking about is http://www.senanetworks.com/sd1000-01.html .

I've used the example code of https://www.npmjs.com/package/react-native-ble-manager to test it out, but unfortunately, it's not picking up this device even though the regular settings app does. Additionally, checking for already connected peripherals does not work if I connected to the device outside of the app. Any tips on how to do this?

The device you are using, the Parani-SD1000 Bluetooth Serial Adapter, does state in its specs that it uses Bluetooth 2.0. You are using a library for Bluetooth Low Energy devices, but BLE was only introduced with Bluetooth 4.0.

Your devices definitely uses Bluetooth Classic (also nown as Bluetooth Serial), thats also the reason why it shows up in the settings of your mobile phone. You need to use a library like react-native-bluetooth-serial . You can use the isConnected() method to detect wether or not it is connected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM