androidreact-nativebluetoothbluetooth-lowenergyreact-native-ble-plx

bluetooth low energy is working between two mobile phone?


i used bluetooth low energy in my mobile app with react-native . and i want to just find other mobile devices, so i can't find any other mobile phone and theirs supported bluetooth low-energy , but i find my Smartwatch , well my question is bluetooth low energy can find other mobile phone or is just for Accessory?

and what are you advicing me to find other mobile phone .

my code

export const App = () => {
    const manager = new BleManager();

    manager.startDeviceScan(null, { scanMode: 2, }, (error, device) => {
        if (error) {
            console.log('error', error)
            return
        }

        if (device !== null) {
              console.log(device)
        }
    }
}

i had edit my android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

i used

  "react": "16.13.1",
  "react-native": "0.63.3", 
 "react-native-ble-plx": "^2.0.1",

Solution

  • Bluetooth Low Energy (BLE) works different than the "old" Bluetooth (Bluetooth Classic). As soon as you turn on Bluetooth your device is visible for Bluetooth Classic scans, but not for BLE scans.

    To find a BLE device it's necessary that the device advertises its present. That's one of the differences between BLE and Bluetooth Classic and allows small accessories to save power. You need to run a GATT Server on your other phone and advertise a service. One very generic tool that would work is nRF Connect.

    Please read more about how BLE works.