randdusing / cordova-plugin-bluetoothle

Bluetooth Low Energy Phonegap Plugin
803 stars 353 forks source link

Android 10, no devices detected during scan #680

Open oxsmose opened 3 years ago

oxsmose commented 3 years ago

Hello,

I deciced to switch on Android device but unfortunatly scann function resturn no devices: Initialization return "enable"scan return "scanStarted" but no devices found.

I use the following function: bluetoothle.startScan(startScanSuccess, handleError, { services: [] });

Any idea of what I did wrong ?

If I go in android bluetooth setup the device is detected and I can can pair it. The device has a passcode. Not sure if it can explain the issue.

I checked the XML file:

<config-file target="AndroidManifest.xml" parent="/manifest">
      <uses-permission android:name="android.permission.BLUETOOTH"/>
      <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    </config-file>

FINE_LOCATION is there.

ab12gu commented 3 years ago

Do you have the code example for your startScanSuccess function?

grassick commented 2 years ago

Here's the one I'm using. Same issue on Android 11 with SGH-I337M:

bluetoothle.startScan(function(s) { console.log("success"); console.log(s) }, function(e) { console.error(e) }, { services: []});

It doesn't find any devices. But if device is already paired, it works great. Previous calls were:

bluetoothle.initialize(function(r) { console.log(r) }, { request: true })

which returned {status: "enabled"}

grassick commented 2 years ago

I needed to do bluetoothle.requestPermission(requestPermissionSuccess, requestPermissionError); first!